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 +-${BUILDDATE} 10.endif 11.if defined(EC2PUBLIC) && !empty(EC2PUBLIC) 12PUBLISH= --public 13.endif 14.if defined(EC2PUBLICSNAP) && !empty(EC2PUBLICSNAP) 15PUBLICSNAP= --publicsnap 16.endif 17.if defined(EC2SNSTOPIC) && !empty(EC2SNSTOPIC) 18EC2SNSREL= ${REVISION}-${BRANCH} 19EC2SNSVERS= ${GITBRANCH}@${GITREV} 20.endif 21.if ${TARGET_ARCH} != "amd64" 22EC2ARCH= --${TARGET_ARCH:S/aarch64/arm64/} 23.endif 24 25CLEANFILES+= ec2ami 26 27.if !exists(/usr/local/bin/bsdec2-image-upload) 28CW_EC2_PORTINSTALL= cw-ec2-portinstall 29CLEANFILES+= ${CW_EC2_PORTINSTALL} 30.else 31CW_EC2_PORTINSTALL= 32.endif 33 34cw-ec2-portinstall: 35.if exists(${PORTSDIR}/net/bsdec2-image-upload/Makefile) 36 env - UNAME_r=${UNAME_r} PATH=$$PATH make -C ${PORTSDIR}/net/bsdec2-image-upload BATCH=1 all install clean 37.else 38. if !exists(/usr/local/sbin/pkg-static) 39 env ASSUME_ALWAYS_YES=yes pkg bootstrap -y 40. endif 41 env ASSUME_ALWAYS_YES=yes pkg install -y net/bsdec2-image-upload 42.endif 43 @touch ${.TARGET} 44 45ec2ami: cw-ec2 ${CW_EC2_PORTINSTALL} 46.if !defined(AWSKEYFILE) || !exists(${AWSKEYFILE}) 47 @echo "--------------------------------------------------------------" 48 @echo ">>> AWSKEYFILE must point at AWS keys for EC2 AMI creation" 49 @echo "--------------------------------------------------------------" 50 @false 51.endif 52.if !defined(AWSREGION) 53 @echo "--------------------------------------------------------------" 54 @echo ">>> AWSREGION must be specified EC2 AMI creation" 55 @echo "--------------------------------------------------------------" 56 @false 57.endif 58.if !defined(AWSBUCKET) 59 @echo "--------------------------------------------------------------" 60 @echo ">>> AWSBUCKET must be specified for EC2 AMI creation" 61 @echo "--------------------------------------------------------------" 62 @false 63.endif 64 /usr/local/bin/bsdec2-image-upload ${PUBLISH} ${PUBLICSNAP} \ 65 ${EC2ARCH} --sriov --ena \ 66 ${.OBJDIR}/ec2.raw \ 67 "${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX}" \ 68 "${TYPE}/${TARGET} ${GITBRANCH}@${GITREV}" \ 69 ${AWSREGION} ${AWSBUCKET} ${AWSKEYFILE} \ 70 ${EC2SNSTOPIC} ${EC2SNSREL} ${EC2SNSVERS} 71 @touch ${.TARGET} 72