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