Raspi-image-spec/raspi_master.yaml

165 lines
5.3 KiB
YAML
Raw Normal View History

# See https://wiki.debian.org/RaspberryPi3 for known issues and more details.
steps:
- mkimg: "{{ output }}"
size: 1500M
- mklabel: msdos
device: "{{ output }}"
- mkpart: primary
fs-type: 'fat32'
device: "{{ output }}"
start: 4MiB
end: 20%
tag: /boot
- mkpart: primary
device: "{{ output }}"
start: 20%
end: 100%
tag: /
- kpartx: "{{ output }}"
- mkfs: vfat
partition: /boot
label: RASPIFIRM
- mkfs: ext4
partition: /
label: RASPIROOT
- mount: /
- mount: /boot
mount-on: /
dirname: '/boot/firmware'
- unpack-rootfs: /
- qemu-debootstrap: __RELEASE__
mirror: http://deb.debian.org/debian
target: /
arch: __ARCH__
components:
- main
- contrib
- non-free
unless: rootfs_unpacked
- create-file: /etc/apt/sources.list
trailing-newline: '1'
contents: |
deb http://deb.debian.org/debian __RELEASE__ main contrib non-free
deb http://security.debian.org/debian-security __SECURITY_SUITE__ main contrib non-free
Generate recipes using a Python script instead of multiplying sed calls. This is a proof of concept rather than an ideal, final situation. It can be used this way: for v in 1 2 3 4 ; do for s in buster bullseye; do ./generate-recipe.py $v $s done done and it has been verified to produce very similar results compared to the existing many-sed approach. Differences are as follows: - Missing newline after some backports stanza, due to the removal of the other APT line. There's already MR#51 that aims at fixing some newline-related issues anyway, so this can be addressed separately. - Less schizophrenia in the generated sources.list for buster/4, as we are now only showing a reason for enabling the backports, instead of starting by explaining why backports are disabled by default. - Dropping APT::Default-Release = buster in the buster/4 case, which is no longer needed as we are pulling things from buster-backports rather than pulling them from unstable (see 57e90df103). - No longer trying to fix the firmware package name by throwing a broken sed at rpi-reconfigure-raspi-firmware.service in the buster/4 case: the syntax was buggy and fixing it would have made us try to replace raspi-firmware with raspi-firmware/buster-backports, while the correct thing to do is to not touch it in the first place (raspi-firmware is the correct name for the firmware package, pulled from buster-backports). As a side effect, this transforms the existing __EXTRA_SHELL_CMDS__ into a slightly more explicit __EXTRA_ROOT_SHELL_CMDS__ which now has its __EXTRA_CHROOT_SHELL_CMDS__ twin. That's the entry point that was missing and made 45cb5619d4 necessary in the past.
2021-08-28 03:01:30 +01:00
__BACKPORTS__
unless: rootfs_unpacked
- copy-file: /etc/initramfs-tools/hooks/rpi-resizerootfs
src: rootfs/etc/initramfs-tools/hooks/rpi-resizerootfs
perm: 0755
unless: rootfs_unpacked
- copy-file: /etc/initramfs-tools/scripts/local-bottom/rpi-resizerootfs
src: rootfs/etc/initramfs-tools/scripts/local-bottom/rpi-resizerootfs
perm: 0755
unless: rootfs_unpacked
- chroot: /
shell: |
apt-get update
unless: rootfs_unpacked
- apt: install
packages:
- ca-certificates
- dosfstools
- iw
- parted
- ssh
- wpasupplicant
- __LINUX_IMAGE__
- __RASPI_FIRMWARE__
- __WIRELESS_FIRMWARE__
tag: /
unless: rootfs_unpacked
- cache-rootfs: /
unless: rootfs_unpacked
- shell: |
echo "__HOST__-$(date +%Y%m%d)" > "${ROOT?}/etc/hostname"
# Allow root logins locally with no password
sed -i 's,root:[^:]*:,root::,' "${ROOT?}/etc/shadow"
2020-08-15 06:06:18 +01:00
install -m 644 -o root -g root rootfs/etc/fstab "${ROOT?}/etc/fstab"
2020-08-15 06:06:18 +01:00
install -m 644 -o root -g root rootfs/etc/network/interfaces.d/eth0 "${ROOT?}/etc/network/interfaces.d/eth0"
install -m 600 -o root -g root rootfs/etc/network/interfaces.d/wlan0 "${ROOT?}/etc/network/interfaces.d/wlan0"
2020-08-15 06:06:18 +01:00
install -m 755 -o root -g root rootfs/usr/local/sbin/rpi-set-sysconf "${ROOT?}/usr/local/sbin/rpi-set-sysconf"
install -m 644 -o root -g root rootfs/etc/systemd/system/rpi-set-sysconf.service "${ROOT?}/etc/systemd/system/"
install -m 644 -o root -g root rootfs/boot/firmware/sysconf.txt "${ROOT?}/boot/firmware/sysconf.txt"
mkdir -p "${ROOT?}/etc/systemd/system/basic.target.requires/"
ln -s /etc/systemd/system/rpi-set-sysconf.service "${ROOT?}/etc/systemd/system/basic.target.requires/rpi-set-sysconf.service"
# Resize script is now in the initrd for first boot; no need to ship it.
rm -f "${ROOT?}/etc/initramfs-tools/hooks/rpi-resizerootfs"
rm -f "${ROOT?}/etc/initramfs-tools/scripts/local-bottom/rpi-resizerootfs"
install -m 644 -o root -g root rootfs/etc/systemd/system/rpi-reconfigure-raspi-firmware.service "${ROOT?}/etc/systemd/system/"
mkdir -p "${ROOT?}/etc/systemd/system/multi-user.target.requires/"
ln -s /etc/systemd/system/rpi-reconfigure-raspi-firmware.service "${ROOT?}/etc/systemd/system/multi-user.target.requires/rpi-reconfigure-raspi-firmware.service"
__FIX_FIRMWARE_PKG_NAME__
install -m 644 -o root -g root rootfs/etc/systemd/system/rpi-generate-ssh-host-keys.service "${ROOT?}/etc/systemd/system/"
ln -s /etc/systemd/system/rpi-generate-ssh-host-keys.service "${ROOT?}/etc/systemd/system/multi-user.target.requires/rpi-generate-ssh-host-keys.service"
rm -f "${ROOT?}"/etc/ssh/ssh_host_*_key*
Generate recipes using a Python script instead of multiplying sed calls. This is a proof of concept rather than an ideal, final situation. It can be used this way: for v in 1 2 3 4 ; do for s in buster bullseye; do ./generate-recipe.py $v $s done done and it has been verified to produce very similar results compared to the existing many-sed approach. Differences are as follows: - Missing newline after some backports stanza, due to the removal of the other APT line. There's already MR#51 that aims at fixing some newline-related issues anyway, so this can be addressed separately. - Less schizophrenia in the generated sources.list for buster/4, as we are now only showing a reason for enabling the backports, instead of starting by explaining why backports are disabled by default. - Dropping APT::Default-Release = buster in the buster/4 case, which is no longer needed as we are pulling things from buster-backports rather than pulling them from unstable (see 57e90df103). - No longer trying to fix the firmware package name by throwing a broken sed at rpi-reconfigure-raspi-firmware.service in the buster/4 case: the syntax was buggy and fixing it would have made us try to replace raspi-firmware with raspi-firmware/buster-backports, while the correct thing to do is to not touch it in the first place (raspi-firmware is the correct name for the firmware package, pulled from buster-backports). As a side effect, this transforms the existing __EXTRA_SHELL_CMDS__ into a slightly more explicit __EXTRA_ROOT_SHELL_CMDS__ which now has its __EXTRA_CHROOT_SHELL_CMDS__ twin. That's the entry point that was missing and made 45cb5619d4 necessary in the past.
2021-08-28 03:01:30 +01:00
__EXTRA_ROOT_SHELL_CMDS__
root-fs: /
# Copy the relevant device tree files to the boot partition
- chroot: /
shell: |
install -m 644 -o root -g root __DTB__ /boot/firmware/
# Clean up archive cache (likely not useful) and lists (likely outdated) to
# reduce image size by several hundred megabytes.
- chroot: /
shell: |
apt-get clean
rm -rf /var/lib/apt/lists
# Modify the kernel commandline we take from the firmware to boot from
# the partition labeled raspiroot instead of forcing it to mmcblk0p2
#
# These changes will be overwritten after the hardware is probed
# after dpkg reconfigures raspi-firmware (upon first boot).
- chroot: /
shell: |
sed -i 's/^/console=__SERIAL_CONSOLE__ /' /boot/firmware/cmdline.txt
sed -i 's/.dev.mmcblk0p2/LABEL=RASPIROOT/' /boot/firmware/cmdline.txt
Generate recipes using a Python script instead of multiplying sed calls. This is a proof of concept rather than an ideal, final situation. It can be used this way: for v in 1 2 3 4 ; do for s in buster bullseye; do ./generate-recipe.py $v $s done done and it has been verified to produce very similar results compared to the existing many-sed approach. Differences are as follows: - Missing newline after some backports stanza, due to the removal of the other APT line. There's already MR#51 that aims at fixing some newline-related issues anyway, so this can be addressed separately. - Less schizophrenia in the generated sources.list for buster/4, as we are now only showing a reason for enabling the backports, instead of starting by explaining why backports are disabled by default. - Dropping APT::Default-Release = buster in the buster/4 case, which is no longer needed as we are pulling things from buster-backports rather than pulling them from unstable (see 57e90df103). - No longer trying to fix the firmware package name by throwing a broken sed at rpi-reconfigure-raspi-firmware.service in the buster/4 case: the syntax was buggy and fixing it would have made us try to replace raspi-firmware with raspi-firmware/buster-backports, while the correct thing to do is to not touch it in the first place (raspi-firmware is the correct name for the firmware package, pulled from buster-backports). As a side effect, this transforms the existing __EXTRA_SHELL_CMDS__ into a slightly more explicit __EXTRA_ROOT_SHELL_CMDS__ which now has its __EXTRA_CHROOT_SHELL_CMDS__ twin. That's the entry point that was missing and made 45cb5619d4 necessary in the past.
2021-08-28 03:01:30 +01:00
__EXTRA_CHROOT_SHELL_CMDS__
# TODO(https://github.com/larswirzenius/vmdb2/issues/24): remove once vmdb
# clears /etc/resolv.conf on its own.
- shell: |
rm "${ROOT?}/etc/resolv.conf"
root-fs: /
# Clear /etc/machine-id and /var/lib/dbus/machine-id, as both should
# be auto-generated upon first boot. From the manpage
# (machine-id(5)):
#
# For normal operating system installations, where a custom image is
# created for a specific machine, /etc/machine-id should be
# populated during installation.
#
# Note this will also trigger ConditionFirstBoot=yes for systemd.
- chroot: /
shell: |
rm -f /etc/machine-id /var/lib/dbus/machine-id