xref: /freebsd/release/tools/ec2-builder.conf (revision 24e4dcf4ba5e9dedcf89efd358ea3e1fe5867020)
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# Equivalent to INSTALLOPTS for pkgbase
15vm_extra_filter_base_packages() {
16	grep -v \
17		-e '.*-dbg$' \
18		-e '.*-lib32$' \
19		-e '^FreeBSD-tests.*' \
20		-e '^FreeBSD-lldb.*'
21}
22
23# Packages to install into the image we're creating.  In addition to packages
24# present on all EC2 AMIs, we install:
25# * ec2-scripts, which provides a range of EC2ification startup scripts,
26# * isc-dhcp44-client, used for IPv6 network setup, and
27# * py-awscli, to make it easier for users to create AMIs.
28export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} ec2-scripts \
29    isc-dhcp44-client devel/py-awscli"
30
31# Services to enable in rc.conf(5).
32export VM_RC_LIST="${VM_RC_LIST} ec2_configinit ec2_ephemeral_swap \
33    ec2_fetchkey ec2_loghostkey sshd"
34
35vm_extra_pre_umount() {
36	# Any EC2 ephemeral disks seen when the system first boots will
37	# be "new" disks; there is no "previous boot" when they might have
38	# been seen and used already.
39	touch ${DESTDIR}/var/db/ec2_ephemeral_diskseen
40	metalog_add_data ./var/db/ec2_ephemeral_diskseen
41
42	# Configuration common to all EC2 AMIs
43	ec2_common
44
45	# Standard FreeBSD network configuration
46	ec2_base_networking
47
48	# Grab a copy of the ec2-base disk image, and compress it
49	zstd < ${EC2BASEIMG} > ${DESTDIR}/image.zst
50	metalog_add_data ./image.zst
51
52	# Disable fortune so we don't have extra noise at login
53	chmod a-x ${DESTDIR}/usr/bin/fortune
54
55	# Install the AMI-building script
56	install -m 755 ${WORLDDIR}/release/tools/mkami.sh ${DESTDIR}/bin/mkami
57	metalog_add_data ./bin/mkami 0755
58
59	# Install an /etc/rc which juggles disks around for us
60	install -m 755 ${WORLDDIR}/release/tools/rc.amibuilder ${DESTDIR}/etc
61	metalog_add_data ./etc/rc.amibuilder 0755
62
63	# We want to mount from the UFS disk and juggle disks first
64	cat >> ${DESTDIR}/boot/loader.conf <<-EOF
65		vfs.root.mountfrom="ufs:/dev/gpt/rootfs"
66		init_script="/etc/rc.amibuilder"
67	EOF
68	metalog_add_data ./boot/loader.conf
69
70	return 0
71}
72