#!/bin/sh12. ${WORLDDIR}/release/tools/ec2.conf34# Build with a 7.9 GB partition; this is enough for our stripped-down5# base system plus the compressed ec2-base image.6export VMSIZE=8000m78# Flags to installworld/kernel: We don't want debug symbols (kernel or9# userland), 32-bit libraries, tests, or the debugger.10export INSTALLOPTS="WITHOUT_DEBUG_FILES=YES WITHOUT_KERNEL_SYMBOLS=YES \11WITHOUT_LIB32=YES WITHOUT_TESTS=YES WITHOUT_LLDB=YES"1213# Packages to install into the image we're creating. In addition to packages14# present on all EC2 AMIs, we install:15# * ec2-scripts, which provides a range of EC2ification startup scripts,16# * isc-dhcp44-client, used for IPv6 network setup, and17# * py-awscli, to make it easier for users to create AMIs.18export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} ec2-scripts \19isc-dhcp44-client devel/py-awscli"2021# Services to enable in rc.conf(5).22export VM_RC_LIST="${VM_RC_LIST} ec2_configinit ec2_ephemeral_swap \23ec2_fetchkey ec2_loghostkey sshd"2425vm_extra_pre_umount() {26# Any EC2 ephemeral disks seen when the system first boots will27# be "new" disks; there is no "previous boot" when they might have28# been seen and used already.29touch ${DESTDIR}/var/db/ec2_ephemeral_diskseen3031# Configuration common to all EC2 AMIs32ec2_common3334# Standard FreeBSD network configuration35ec2_base_networking3637# Grab a copy of the ec2-base disk image, and compress it38zstd < ${EC2BASEIMG} > ${DESTDIR}/image.zst3940# Disable fortune so we don't have extra noise at login41chmod a-x ${DESTDIR}/usr/bin/fortune4243# Install the AMI-building script44install -m 755 ${WORLDDIR}/release/tools/mkami.sh ${DESTDIR}/bin/mkami4546# Install an /etc/rc which juggles disks around for us47install -m 755 ${WORLDDIR}/release/tools/rc.amibuilder ${DESTDIR}/etc4849# We want to mount from the UFS disk and juggle disks first50cat >> ${DESTDIR}/boot/loader.conf <<-EOF51vfs.root.mountfrom="ufs:/dev/gpt/rootfs"52init_script="/etc/rc.amibuilder"53EOF5455return 056}575859