4 # Makefile for creating an EC2 AMI from a disk image.
7 .if ${BRANCH} == "CURRENT" || ${BRANCH} == "STABLE" || ${BRANCH} == "PRERELEASE"
8 AMINAMESUFFIX!= date +-${BUILDDATE}
10 .if defined(EC2PUBLIC) && !empty(EC2PUBLIC)
13 .if defined(EC2PUBLICSNAP) && !empty(EC2PUBLICSNAP)
14 PUBLICSNAP= --publicsnap
16 .if defined(EC2SNSTOPIC) && !empty(EC2SNSTOPIC)
17 EC2SNSREL= ${REVISION}-${BRANCH}
18 EC2SNSVERS= ${GITBRANCH}@${GITREV}
20 .if defined(SSMPREFIX) && !empty(SSMPREFIX)
21 SSMOPTS= --ssm-name ${SSMPREFIX}/${TARGET_ARCH:S/aarch64/arm64/}/base/ufs/${REVISION}/${BRANCH}
23 .if ${TARGET_ARCH} != "amd64"
24 EC2ARCH= --${TARGET_ARCH:S/aarch64/arm64/}
26 .if !defined(AMIBOOTMETHOD)
27 AMIBOOTMETHOD= UEFI-PREFERRED
29 .if ${AMIBOOTMETHOD} == "UEFI" && ${TARGET_ARCH} == "amd64"
32 .if ${AMIBOOTMETHOD} == "UEFI-PREFERRED" && ${TARGET_ARCH} == "amd64"
33 BOOTMODEOPT= --uefi-preferred
38 .if !exists(/usr/local/bin/bsdec2-image-upload)
39 CW_EC2_PORTINSTALL= cw-ec2-portinstall
40 CLEANFILES+= ${CW_EC2_PORTINSTALL}
46 .if exists(${PORTSDIR}/net/bsdec2-image-upload/Makefile)
47 env - UNAME_r=${UNAME_r} PATH=$$PATH make -C ${PORTSDIR}/net/bsdec2-image-upload BATCH=1 all install clean
49 . if !exists(/usr/local/sbin/pkg-static)
50 env ASSUME_ALWAYS_YES=yes pkg bootstrap -y
52 env ASSUME_ALWAYS_YES=yes pkg install -y net/bsdec2-image-upload
56 ec2ami: cw-ec2 ${CW_EC2_PORTINSTALL}
57 .if !defined(AWSKEYFILE) || !exists(${AWSKEYFILE})
58 @echo "--------------------------------------------------------------"
59 @echo ">>> AWSKEYFILE must point at AWS keys for EC2 AMI creation"
60 @echo "--------------------------------------------------------------"
63 .if !defined(AWSREGION)
64 @echo "--------------------------------------------------------------"
65 @echo ">>> AWSREGION must be specified EC2 AMI creation"
66 @echo "--------------------------------------------------------------"
69 .if !defined(AWSBUCKET)
70 @echo "--------------------------------------------------------------"
71 @echo ">>> AWSBUCKET must be specified for EC2 AMI creation"
72 @echo "--------------------------------------------------------------"
75 /usr/local/bin/bsdec2-image-upload ${PUBLISH} ${PUBLICSNAP} \
76 ${EC2ARCH} ${SSMOPTS} ${BOOTMODEOPT} --sriov --ena \
78 "${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX} ${AMIBOOTMETHOD}" \
79 "${TYPE}/${TARGET} ${GITBRANCH}@${GITREV}" \
80 ${AWSREGION} ${AWSBUCKET} ${AWSKEYFILE} \
81 ${EC2SNSTOPIC} ${EC2SNSREL} ${EC2SNSVERS}