#!/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, or tests.10export INSTALLOPTS="WITHOUT_DEBUG_FILES=YES WITHOUT_KERNEL_SYMBOLS=YES \11WITHOUT_LIB32=YES WITHOUT_TESTS=YES"1213# Equivalent to INSTALLOPTS for pkgbase14vm_extra_filter_base_packages() {15grep -v \16-e '.*-dbg$' \17-e '.*-lib32$' \18-e '^FreeBSD-set-tests'19}2021# Packages to install into the image we're creating. In addition to packages22# present on all EC2 AMIs, we install:23# * ec2-scripts, which provides a range of EC2ification startup scripts,24# * isc-dhcp44-client, used for IPv6 network setup, and25# * py-awscli, to make it easier for users to create AMIs.26export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} ec2-scripts \27isc-dhcp44-client devel/py-awscli"2829# Services to enable in rc.conf(5).30export VM_RC_LIST="${VM_RC_LIST} ec2_configinit ec2_ephemeral_swap \31ec2_fetchkey ec2_loghostkey sshd"3233vm_extra_pre_umount() {34# Any EC2 ephemeral disks seen when the system first boots will35# be "new" disks; there is no "previous boot" when they might have36# been seen and used already.37touch ${DESTDIR}/var/db/ec2_ephemeral_diskseen38metalog_add_data ./var/db/ec2_ephemeral_diskseen3940# Configuration common to all EC2 AMIs41ec2_common4243# Standard FreeBSD network configuration44ec2_base_networking4546# Grab a copy of the ec2-base disk image, and compress it47zstd < ${EC2BASEIMG} > ${DESTDIR}/image.zst48metalog_add_data ./image.zst4950# Disable fortune so we don't have extra noise at login51chmod a-x ${DESTDIR}/usr/bin/fortune5253# Install the AMI-building script54install -m 755 ${WORLDDIR}/release/tools/mkami.sh ${DESTDIR}/bin/mkami55metalog_add_data ./bin/mkami 07555657# Install an /etc/rc which juggles disks around for us58install -m 755 ${WORLDDIR}/release/tools/rc.amibuilder ${DESTDIR}/etc59metalog_add_data ./etc/rc.amibuilder 07556061# We want to mount from the UFS disk and juggle disks first62cat >> ${DESTDIR}/boot/loader.conf <<-EOF63vfs.root.mountfrom="ufs:/dev/gpt/rootfs"64init_script="/etc/rc.amibuilder"65EOF66metalog_add_data ./boot/loader.conf6768# Add files from packages which weren't recorded in metalog69metalog_add_data ./usr/local/etc/dhclient.conf7071return 072}737475