mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-22 03:04:34 +01:00
c482d65cd1
Starting in September 2021 EC2 AMI names have included the boot method: "BIOS", "UEFI", or "UEFI-PREFERRED". The third option became available in June 2023 and allows AMIs to boot via UEFI on EC2 instance types which support that, but fall back to (much slower) BIOS booting on the instance types which don't support UEFI. Since UEFI-PREFERRED is basically a best-of-both-worlds option and is now the default, there's no point mentioning it in the AMI names. If for some reason an AMI is built with the boot method forced to BIOS or UEFI, that will still be included in the AMI name. This will not be MFCed, in case anyone has scripts which look at the AMI names on 13.x/14.x. Sponsored by: Amazon
101 lines
3.2 KiB
Makefile
101 lines
3.2 KiB
Makefile
#
|
|
#
|
|
#
|
|
# Makefile for creating an EC2 AMI from a disk image.
|
|
#
|
|
|
|
.if ${BRANCH} == "CURRENT" || ${BRANCH} == "STABLE" || ${BRANCH} == "PRERELEASE"
|
|
AMINAMESUFFIX!= date +-${BUILDDATE}
|
|
.endif
|
|
.if defined(EC2PUBLIC) && !empty(EC2PUBLIC)
|
|
PUBLISH= --public
|
|
.endif
|
|
.if defined(EC2PUBLICSNAP) && !empty(EC2PUBLICSNAP)
|
|
PUBLICSNAP= --publicsnap
|
|
.endif
|
|
.if defined(EC2SNSTOPIC) && !empty(EC2SNSTOPIC)
|
|
EC2SNSREL= ${REVISION}-${BRANCH}
|
|
EC2SNSVERS= ${GITBRANCH}@${GITREV}
|
|
.endif
|
|
.if ${TARGET_ARCH} != "amd64"
|
|
EC2ARCH= --${TARGET_ARCH:S/aarch64/arm64/}
|
|
.endif
|
|
.if !defined(AMIBOOTMETHOD)
|
|
AMIBOOTMETHOD= UEFI-PREFERRED
|
|
.endif
|
|
.if ${AMIBOOTMETHOD} == "UEFI" && ${TARGET_ARCH} == "amd64"
|
|
BOOTMODEOPT= --uefi
|
|
.endif
|
|
.if ${AMIBOOTMETHOD} == "UEFI-PREFERRED" && ${TARGET_ARCH} == "amd64"
|
|
BOOTMODEOPT= --uefi-preferred
|
|
.endif
|
|
.if ${AMIBOOTMETHOD} == "UEFI-PREFERRED"
|
|
AMIBASENAME=${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX}
|
|
.else
|
|
AMIBASENAME=${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX} ${AMIBOOTMETHOD}
|
|
.endif
|
|
|
|
CLEANFILES+= ec2ami
|
|
|
|
.if !exists(/usr/local/bin/bsdec2-image-upload)
|
|
CW_EC2_PORTINSTALL= cw-ec2-portinstall
|
|
CLEANFILES+= ${CW_EC2_PORTINSTALL}
|
|
.else
|
|
CW_EC2_PORTINSTALL=
|
|
.endif
|
|
|
|
cw-ec2-portinstall:
|
|
.if !exists(/usr/local/bin/bsdec2-image-upload)
|
|
. if !exists(${PORTSDIR}/net/bsdec2-image-upload/Makefile)
|
|
. if !exists(/usr/local/sbin/pkg-static)
|
|
env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf
|
|
. endif
|
|
env ASSUME_ALWAYS_YES=yes pkg install -y net/bsdec2-image-upload
|
|
. else
|
|
env UNAME_r=${UNAME_r} make -C ${PORTSDIR}/net/bsdec2-image-upload \
|
|
BATCH=1 WRKDIRPREFIX=/tmp/ports DISTDIR=/tmp/distfiles \
|
|
all install clean
|
|
. endif
|
|
.endif
|
|
@touch ${.TARGET}
|
|
|
|
.for _FS in ${EC2_FSLIST}
|
|
.for _FL in ${EC2_FLAVOURS:tl}
|
|
.if defined(SSMPREFIX) && !empty(SSMPREFIX)
|
|
SSMOPTS_${_FL}_${_FS}= --ssm-name ${SSMPREFIX}/${TARGET_ARCH:S/aarch64/arm64/}/${_FL}/${_FS}/${REVISION}/${BRANCH}
|
|
.endif
|
|
EC2AMILIST+= ec2ami-${_FL}-${_FS}
|
|
CLEANFILES+= ec2ami-${_FL}-${_FS}
|
|
ec2ami-${_FL}-${_FS}: cw-ec2-${_FL}-${_FS} ${CW_EC2_PORTINSTALL}
|
|
.if !defined(AWSKEYFILE) || !exists(${AWSKEYFILE})
|
|
@echo "--------------------------------------------------------------"
|
|
@echo ">>> AWSKEYFILE must point at AWS keys for EC2 AMI creation"
|
|
@echo "--------------------------------------------------------------"
|
|
@false
|
|
.endif
|
|
.if !defined(AWSREGION)
|
|
@echo "--------------------------------------------------------------"
|
|
@echo ">>> AWSREGION must be specified EC2 AMI creation"
|
|
@echo "--------------------------------------------------------------"
|
|
@false
|
|
.endif
|
|
.if !defined(AWSBUCKET)
|
|
@echo "--------------------------------------------------------------"
|
|
@echo ">>> AWSBUCKET must be specified for EC2 AMI creation"
|
|
@echo "--------------------------------------------------------------"
|
|
@false
|
|
.endif
|
|
/usr/local/bin/bsdec2-image-upload ${PUBLISH} ${PUBLICSNAP} \
|
|
${EC2ARCH} ${SSMOPTS_${_FL}_${_FS}} ${BOOTMODEOPT} --sriov --ena \
|
|
${.OBJDIR}/${EC2-${_FL:tu}${_FS:tu}IMAGE} \
|
|
"${AMIBASENAME} ${_FL} ${_FS:tu}" \
|
|
"${TYPE}/${TARGET} ${GITBRANCH}@${GITREV}" \
|
|
${AWSREGION} ${AWSBUCKET} ${AWSKEYFILE} \
|
|
${EC2SNSTOPIC} ${EC2SNSREL} ${EC2SNSVERS}
|
|
@touch ${.TARGET}
|
|
.endfor
|
|
.endfor
|
|
|
|
ec2ami: ec2ami-base-${VMFS}
|
|
ec2amis: ${EC2AMILIST}
|