1# 2# 3# 4# Makefile for creating an EC2 AMI from a disk image. 5# 6 7.if ${BRANCH} == "CURRENT" || ${BRANCH} == "STABLE" || ${BRANCH} == "PRERELEASE" 8AMINAMESUFFIX!= date +-${BUILDDATE} 9.endif 10.if defined(EC2PUBLIC) && !empty(EC2PUBLIC) 11PUBLISH= --public 12.endif 13.if defined(EC2PUBLICSNAP) && !empty(EC2PUBLICSNAP) 14PUBLICSNAP= --publicsnap 15.endif 16.if defined(EC2SNSTOPIC) && !empty(EC2SNSTOPIC) 17EC2SNSREL= ${REVISION}-${BRANCH} 18EC2SNSVERS= ${GITBRANCH}@${GITREV} 19.endif 20.if ${TARGET_ARCH} != "amd64" 21EC2ARCH= --${TARGET_ARCH:S/aarch64/arm64/} 22.endif 23.if !defined(AMIBOOTMETHOD) 24AMIBOOTMETHOD= UEFI-PREFERRED 25.endif 26.if ${AMIBOOTMETHOD} == "UEFI" && ${TARGET_ARCH} == "amd64" 27BOOTMODEOPT= --uefi 28.endif 29.if ${AMIBOOTMETHOD} == "UEFI-PREFERRED" && ${TARGET_ARCH} == "amd64" 30BOOTMODEOPT= --uefi-preferred 31.endif 32 33CLEANFILES+= ec2ami 34 35.if !exists(/usr/local/bin/bsdec2-image-upload) 36CW_EC2_PORTINSTALL= cw-ec2-portinstall 37CLEANFILES+= ${CW_EC2_PORTINSTALL} 38.else 39CW_EC2_PORTINSTALL= 40.endif 41 42cw-ec2-portinstall: 43.if exists(${PORTSDIR}/net/bsdec2-image-upload/Makefile) 44 env - UNAME_r=${UNAME_r} PATH=$$PATH make -C ${PORTSDIR}/net/bsdec2-image-upload BATCH=1 all install clean 45.else 46. if !exists(/usr/local/sbin/pkg-static) 47 env ASSUME_ALWAYS_YES=yes pkg bootstrap -y 48. endif 49 env ASSUME_ALWAYS_YES=yes pkg install -y net/bsdec2-image-upload 50.endif 51 @touch ${.TARGET} 52 53.for _FS in ${EC2_FSLIST} 54.for _FL in ${EC2_FLAVOURS:tl} 55.if defined(SSMPREFIX) && !empty(SSMPREFIX) 56SSMOPTS_${_FL}_${_FS}= --ssm-name ${SSMPREFIX}/${TARGET_ARCH:S/aarch64/arm64/}/${_FL}/${_FS}/${REVISION}/${BRANCH} 57.endif 58EC2AMILIST+= ec2ami-${_FL}-${_FS} 59ec2ami-${_FL}-${_FS}: cw-ec2-${_FL}-${_FS} ${CW_EC2_PORTINSTALL} 60.if !defined(AWSKEYFILE) || !exists(${AWSKEYFILE}) 61 @echo "--------------------------------------------------------------" 62 @echo ">>> AWSKEYFILE must point at AWS keys for EC2 AMI creation" 63 @echo "--------------------------------------------------------------" 64 @false 65.endif 66.if !defined(AWSREGION) 67 @echo "--------------------------------------------------------------" 68 @echo ">>> AWSREGION must be specified EC2 AMI creation" 69 @echo "--------------------------------------------------------------" 70 @false 71.endif 72.if !defined(AWSBUCKET) 73 @echo "--------------------------------------------------------------" 74 @echo ">>> AWSBUCKET must be specified for EC2 AMI creation" 75 @echo "--------------------------------------------------------------" 76 @false 77.endif 78 /usr/local/bin/bsdec2-image-upload ${PUBLISH} ${PUBLICSNAP} \ 79 ${EC2ARCH} ${SSMOPTS_${_FL}_${_FS}} ${BOOTMODEOPT} --sriov --ena \ 80 ${.OBJDIR}/${EC2-${_FL:tu}${_FS:tu}IMAGE} \ 81 "${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX} ${AMIBOOTMETHOD} ${_FL} ${_FS:tu}" \ 82 "${TYPE}/${TARGET} ${GITBRANCH}@${GITREV}" \ 83 ${AWSREGION} ${AWSBUCKET} ${AWSKEYFILE} \ 84 ${EC2SNSTOPIC} ${EC2SNSREL} ${EC2SNSVERS} 85 @touch ${.TARGET} 86.endfor 87.endfor 88 89ec2ami: ec2ami-base-${VMFS} 90ec2amis: ${EC2AMILIST} 91