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.if defined(SSMPREFIX) && !empty(SSMPREFIX) 55SSMOPTS_${_FS}= --ssm-name ${SSMPREFIX}/${TARGET_ARCH:S/aarch64/arm64/}/base/${_FS}/${REVISION}/${BRANCH} 56.endif 57EC2AMILIST+= ec2ami-${_FS} 58ec2ami-${_FS}: cw-ec2-${_FS} ${CW_EC2_PORTINSTALL} 59.if !defined(AWSKEYFILE) || !exists(${AWSKEYFILE}) 60 @echo "--------------------------------------------------------------" 61 @echo ">>> AWSKEYFILE must point at AWS keys for EC2 AMI creation" 62 @echo "--------------------------------------------------------------" 63 @false 64.endif 65.if !defined(AWSREGION) 66 @echo "--------------------------------------------------------------" 67 @echo ">>> AWSREGION must be specified EC2 AMI creation" 68 @echo "--------------------------------------------------------------" 69 @false 70.endif 71.if !defined(AWSBUCKET) 72 @echo "--------------------------------------------------------------" 73 @echo ">>> AWSBUCKET must be specified for EC2 AMI creation" 74 @echo "--------------------------------------------------------------" 75 @false 76.endif 77 /usr/local/bin/bsdec2-image-upload ${PUBLISH} ${PUBLICSNAP} \ 78 ${EC2ARCH} ${SSMOPTS_${_FS}} ${BOOTMODEOPT} --sriov --ena \ 79 ${.OBJDIR}/${EC2${_FS:tu}IMAGE} \ 80 "${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX} ${AMIBOOTMETHOD} ${_FS:tu}" \ 81 "${TYPE}/${TARGET} ${GITBRANCH}@${GITREV}" \ 82 ${AWSREGION} ${AWSBUCKET} ${AWSKEYFILE} \ 83 ${EC2SNSTOPIC} ${EC2SNSREL} ${EC2SNSVERS} 84 @touch ${.TARGET} 85.endfor 86 87ec2ami: ec2ami-${VMFS} 88ec2amis: ${EC2AMILIST} 89