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