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} 2>/dev/null | 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} 2>/dev/null || true 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(EC2PUBLICSNAP) && !empty(EC2PUBLICSNAP) 39PUBLICSNAP= --publicsnap 40.endif 41.if defined(EC2SNSTOPIC) && !empty(EC2SNSTOPIC) 42EC2SNSREL= ${REVISION}-${BRANCH} 43EC2SNSVERS= ${EC2_SVNBRANCH}@${EC2_SVNREV} 44.endif 45.if ${TARGET_ARCH} != "amd64" 46EC2ARCH= --${TARGET_ARCH:S/aarch64/arm64/} 47.endif 48 49CLEANFILES+= ec2ami 50 51.if !exists(/usr/local/bin/bsdec2-image-upload) 52CW_EC2_PORTINSTALL= cw-ec2-portinstall 53CLEANFILES+= ${CW_EC2_PORTINSTALL} 54.else 55CW_EC2_PORTINSTALL= 56.endif 57 58cw-ec2-portinstall: 59.if exists(${PORTSDIR}/net/bsdec2-image-upload/Makefile) 60 env - PATH=$$PATH make -C ${PORTSDIR}/net/bsdec2-image-upload BATCH=1 all install clean 61.else 62. if !exists(/usr/local/sbin/pkg-static) 63 env ASSUME_ALWAYS_YES=yes pkg bootstrap -y 64. endif 65 env ASSUME_ALWAYS_YES=yes pkg install -y net/bsdec2-image-upload 66.endif 67 @touch ${.TARGET} 68 69ec2ami: cw-ec2 ${CW_EC2_PORTINSTALL} 70.if !defined(AWSKEYFILE) || !exists(${AWSKEYFILE}) 71 @echo "--------------------------------------------------------------" 72 @echo ">>> AWSKEYFILE must point at AWS keys for EC2 AMI creation" 73 @echo "--------------------------------------------------------------" 74 @false 75.endif 76.if !defined(AWSREGION) 77 @echo "--------------------------------------------------------------" 78 @echo ">>> AWSREGION must be specified EC2 AMI creation" 79 @echo "--------------------------------------------------------------" 80 @false 81.endif 82.if !defined(AWSBUCKET) 83 @echo "--------------------------------------------------------------" 84 @echo ">>> AWSBUCKET must be specified for EC2 AMI creation" 85 @echo "--------------------------------------------------------------" 86 @false 87.endif 88 /usr/local/bin/bsdec2-image-upload ${PUBLISH} ${PUBLICSNAP} \ 89 ${EC2ARCH} --sriov --ena \ 90 ${.OBJDIR}/ec2.raw \ 91 "${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX}" \ 92 "${TYPE}/${TARGET} ${EC2_SVNBRANCH}@${EC2_SVNREV}" \ 93 ${AWSREGION} ${AWSBUCKET} ${AWSKEYFILE} \ 94 ${EC2SNSTOPIC} ${EC2SNSREL} ${EC2SNSVERS} 95 @touch ${.TARGET} 96