HardenedBSD/release/Makefile.ec2
Colin Percival b43d7aa09b EC2: Default to UEFI booting
This reduces the FreeBSD boot time by approximately 5 seconds,
roughly equally divided betwenn two factors:
* Disk I/O is faster in the EFI loader since it can perform larger
I/Os.  (The BIOS loader is limited due to the use of bounce buffers
in sub-1M memory.)
* The EFI console is much faster than the VGA console.

Note however that not all EC2 instance types support UEFI; as a
general rule the newer instances (based on Amazon's "Nitro" platform)
support UEFI but the older instances (based on Xen) do not.

X-MFC:	TBD based on tradeoff between performance and compatibility
Relnotes:	yes
Sponsored by:	https://www.patreon.com/cperciva
2021-09-16 12:23:19 -07:00

81 lines
2.5 KiB
Makefile

#
# $FreeBSD$
#
#
# 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 defined(SSMPREFIX) && !empty(SSMPREFIX)
SSMOPTS= --ssm-name ${SSMPREFIX}/${TARGET_ARCH:S/aarch64/arm64/}/base/ufs/${REVISION}/${BRANCH}
.endif
.if ${TARGET_ARCH} != "amd64"
EC2ARCH= --${TARGET_ARCH:S/aarch64/arm64/}
.endif
.if !defined(AMIBOOTMETHOD)
AMIBOOTMETHOD= UEFI
.endif
.if ${AMIBOOTMETHOD} == "UEFI" && ${TARGET_ARCH} == "amd64"
BOOTMODEOPT= --uefi
.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(${PORTSDIR}/net/bsdec2-image-upload/Makefile)
env - UNAME_r=${UNAME_r} PATH=$$PATH make -C ${PORTSDIR}/net/bsdec2-image-upload BATCH=1 all install clean
.else
. if !exists(/usr/local/sbin/pkg-static)
env ASSUME_ALWAYS_YES=yes pkg bootstrap -y
. endif
env ASSUME_ALWAYS_YES=yes pkg install -y net/bsdec2-image-upload
.endif
@touch ${.TARGET}
ec2ami: cw-ec2 ${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} ${BOOTMODEOPT} --sriov --ena \
${.OBJDIR}/ec2.raw \
"${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX} ${AMIBOOTMETHOD}" \
"${TYPE}/${TARGET} ${GITBRANCH}@${GITREV}" \
${AWSREGION} ${AWSBUCKET} ${AWSKEYFILE} \
${EC2SNSTOPIC} ${EC2SNSREL} ${EC2SNSVERS}
@touch ${.TARGET}