1# 2# $FreeBSD$ 3# 4# 5# Makefile for creating an EC2 AMI from a disk image. 6# 7 8# Figure out where SVN is 9.if !defined(SVN_CMD) || empty(SVN_CMD) 10. for _P in /usr/bin /usr/local/bin 11. for _S in svn svnlite 12. if exists(${_P}/${_S}) 13SVN_CMD= ${_P}/${_S} 14. endif 15. endfor 16. endfor 17.endif 18.if exists(${SRCTOP}/.svn) 19. if empty(EC2_SVNBRANCH) 20 EC2_SVNBRANCH!= ${SVN_CMD} info --show-item relative-url ${WORLDDIR} | sed -e 's/\^\///' 21. export EC2_SVNBRANCH 22. endif 23. if empty(EC2_SVNREV) 24 EC2_SVNREV!= ${SVN_CMD} info --show-item last-changed-revision ${WORLDDIR} 25. export EC2_SVNREV 26. endif 27.else 28EC2_SVNBRANCH= unknown 29EC2_SVNREV= unknown 30.endif 31 32.if ${BRANCH} == "CURRENT" || ${BRANCH} == "STABLE" || ${BRANCH} == "PRERELEASE" 33AMINAMESUFFIX!= date +-%Y-%m-%d 34.endif 35.if defined(EC2PUBLIC) && !empty(EC2PUBLIC) 36PUBLISH= --public 37.endif 38.if defined(EC2SNSTOPIC) && !empty(EC2SNSTOPIC) 39EC2SNSREL= ${REVISION}-${BRANCH} 40EC2SNSVERS= ${EC2_SVNBRANCH}@${EC2_SVNREV} 41.endif 42 43CLEANFILES+= ec2ami 44 45.if !exists(/usr/local/bin/bsdec2-image-upload) 46CW_EC2_PORTINSTALL= cw-ec2-portinstall 47CLEANFILES+= ${CW_EC2_PORTINSTALL} 48.else 49CW_EC2_PORTINSTALL= 50.endif 51 52cw-ec2-portinstall: 53.if exists(${PORTSDIR}/net/bsdec2-image-upload/Makefile) 54 env - PATH=$$PATH make -C ${PORTSDIR}/net/bsdec2-image-upload BATCH=1 all install clean 55.else 56. if !exists(/usr/local/sbin/pkg-static) 57 env ASSUME_ALWAYS_YES=yes pkg bootstrap -y 58. endif 59 env ASSUME_ALWAYS_YES=yes pkg install -y net/bsdec2-image-upload 60.endif 61 @touch ${.TARGET} 62 63ec2ami: cw-ec2 ${CW_EC2_PORTINSTALL} 64.if !defined(AWSKEYFILE) || !exists(${AWSKEYFILE}) 65 @echo "--------------------------------------------------------------" 66 @echo ">>> AWSKEYFILE must point at AWS keys for EC2 AMI creation" 67 @echo "--------------------------------------------------------------" 68 @false 69.endif 70.if !defined(AWSREGION) 71 @echo "--------------------------------------------------------------" 72 @echo ">>> AWSREGION must be specified EC2 AMI creation" 73 @echo "--------------------------------------------------------------" 74 @false 75.endif 76.if !defined(AWSBUCKET) 77 @echo "--------------------------------------------------------------" 78 @echo ">>> AWSBUCKET must be specified for EC2 AMI creation" 79 @echo "--------------------------------------------------------------" 80 @false 81.endif 82 /usr/local/bin/bsdec2-image-upload ${PUBLISH} --sriov --ena \ 83 ${.OBJDIR}/ec2.raw \ 84 "${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX}" \ 85 "${TYPE}/${TARGET} ${EC2_SVNBRANCH}@${EC2_SVNREV}" \ 86 ${AWSREGION} ${AWSBUCKET} ${AWSKEYFILE} \ 87 ${EC2SNSTOPIC} ${EC2SNSREL} ${EC2SNSVERS} 88 @touch ${.TARGET} 89