1#!/bin/sh 2 3. ${WORLDDIR}/release/tools/ec2.conf 4 5# Build with a 7.9 GB partition; this is enough for our stripped-down 6# base system plus the compressed ec2-base image. 7export VMSIZE=8000m 8 9# Flags to installworld/kernel: We don't want debug symbols (kernel or 10# userland), 32-bit libraries, tests, or the debugger. 11export INSTALLOPTS="WITHOUT_DEBUG_FILES=YES WITHOUT_KERNEL_SYMBOLS=YES \ 12 WITHOUT_LIB32=YES WITHOUT_TESTS=YES WITHOUT_LLDB=YES" 13 14# Packages to install into the image we're creating. In addition to packages 15# present on all EC2 AMIs, we install: 16# * ec2-scripts, which provides a range of EC2ification startup scripts, 17# * isc-dhcp44-client, used for IPv6 network setup, and 18# * py-awscli, to make it easier for users to create AMIs. 19export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} ec2-scripts \ 20 isc-dhcp44-client devel/py-awscli" 21 22# Services to enable in rc.conf(5). 23export VM_RC_LIST="${VM_RC_LIST} ec2_configinit ec2_ephemeral_swap \ 24 ec2_fetchkey ec2_loghostkey sshd" 25 26vm_extra_pre_umount() { 27 # Any EC2 ephemeral disks seen when the system first boots will 28 # be "new" disks; there is no "previous boot" when they might have 29 # been seen and used already. 30 touch ${DESTDIR}/var/db/ec2_ephemeral_diskseen 31 metalog_add_data ./var/db/ec2_ephemeral_diskseen 32 33 # Configuration common to all EC2 AMIs 34 ec2_common 35 36 # Standard FreeBSD network configuration 37 ec2_base_networking 38 39 # Grab a copy of the ec2-base disk image, and compress it 40 zstd < ${EC2BASEIMG} > ${DESTDIR}/image.zst 41 metalog_add_data ./image.zst 42 43 # Disable fortune so we don't have extra noise at login 44 chmod a-x ${DESTDIR}/usr/bin/fortune 45 46 # Install the AMI-building script 47 install -m 755 ${WORLDDIR}/release/tools/mkami.sh ${DESTDIR}/bin/mkami 48 metalog_add_data ./bin/mkami 0755 49 50 # Install an /etc/rc which juggles disks around for us 51 install -m 755 ${WORLDDIR}/release/tools/rc.amibuilder ${DESTDIR}/etc 52 metalog_add_data ./etc/rc.amibuilder 0755 53 54 # We want to mount from the UFS disk and juggle disks first 55 cat >> ${DESTDIR}/boot/loader.conf <<-EOF 56 vfs.root.mountfrom="ufs:/dev/gpt/rootfs" 57 init_script="/etc/rc.amibuilder" 58 EOF 59 metalog_add_data ./boot/loader.conf 60 61 return 0 62} 63