2017-10-08 21:18:48 +01:00
|
|
|
# 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: 0%
|
|
|
|
end: 20%
|
2019-01-13 13:38:36 +00:00
|
|
|
tag: /boot
|
2017-10-08 21:18:48 +01:00
|
|
|
|
|
|
|
- mkpart: primary
|
|
|
|
device: "{{ output }}"
|
|
|
|
start: 20%
|
|
|
|
end: 100%
|
2019-01-13 13:38:36 +00:00
|
|
|
tag: /
|
2018-12-31 18:58:41 +00:00
|
|
|
|
|
|
|
- kpartx: "{{ output }}"
|
2017-10-08 21:18:48 +01:00
|
|
|
|
|
|
|
- mkfs: vfat
|
2019-01-13 13:38:36 +00:00
|
|
|
partition: /boot
|
2018-12-05 00:39:03 +00:00
|
|
|
label: RASPIFIRM
|
2017-10-08 21:18:48 +01:00
|
|
|
|
|
|
|
- mkfs: ext4
|
2019-01-13 13:38:36 +00:00
|
|
|
partition: /
|
2018-12-05 00:39:03 +00:00
|
|
|
label: RASPIROOT
|
2017-10-08 21:18:48 +01:00
|
|
|
|
2019-01-13 13:38:36 +00:00
|
|
|
- mount: /
|
2017-10-08 21:18:48 +01:00
|
|
|
|
2019-01-13 13:38:36 +00:00
|
|
|
- mount: /boot
|
|
|
|
mount-on: /
|
2017-10-08 21:18:48 +01:00
|
|
|
dirname: '/boot/firmware'
|
|
|
|
|
2019-01-13 13:38:36 +00:00
|
|
|
- unpack-rootfs: /
|
2019-01-02 08:40:34 +00:00
|
|
|
|
2017-10-08 21:18:48 +01:00
|
|
|
# We need to use Debian buster (currently testing) instead of Debian stretch
|
|
|
|
# (currently stable) for:
|
|
|
|
#
|
2018-01-08 21:46:02 +00:00
|
|
|
# linux ≥ 4.14
|
2017-10-08 21:18:48 +01:00
|
|
|
# Which includes the sdhost driver for faster SD card access and making the
|
2018-01-08 21:46:02 +00:00
|
|
|
# WiFi chip available, and has the WiFi driver enabled.
|
2017-10-08 21:18:48 +01:00
|
|
|
#
|
2018-01-08 21:46:02 +00:00
|
|
|
# raspi3-firmware ≥ 1.20171201-1
|
2017-10-08 21:18:48 +01:00
|
|
|
# Which includes a recent enough firmware version to correctly pass the MAC
|
|
|
|
# address to the kernel. This is a regression with Linux ≥ 4.12, see
|
|
|
|
# https://github.com/raspberrypi/firmware/issues/846
|
2018-01-08 21:46:02 +00:00
|
|
|
# Also, this package contains a Raspberry Pi 3-specific firmware file
|
|
|
|
# required by the WiFi driver.
|
2017-10-08 21:18:48 +01:00
|
|
|
- qemu-debootstrap: buster
|
2018-01-08 21:45:15 +00:00
|
|
|
mirror: http://deb.debian.org/debian
|
2019-01-13 13:38:36 +00:00
|
|
|
target: /
|
2017-10-08 21:18:48 +01:00
|
|
|
arch: arm64
|
|
|
|
components:
|
|
|
|
- main
|
|
|
|
- contrib
|
|
|
|
- non-free
|
2019-01-02 08:40:34 +00:00
|
|
|
unless: rootfs_unpacked
|
2017-10-08 21:18:48 +01:00
|
|
|
|
|
|
|
# TODO(https://bugs.debian.org/877855): remove this workaround once
|
|
|
|
# debootstrap is fixed
|
2019-01-13 13:38:36 +00:00
|
|
|
- chroot: /
|
2017-10-08 21:18:48 +01:00
|
|
|
shell: |
|
2018-01-08 21:45:15 +00:00
|
|
|
echo 'deb http://deb.debian.org/debian buster main contrib non-free' > /etc/apt/sources.list
|
2017-10-08 21:18:48 +01:00
|
|
|
apt-get update
|
2019-01-02 08:40:34 +00:00
|
|
|
unless: rootfs_unpacked
|
2017-10-08 21:18:48 +01:00
|
|
|
|
|
|
|
- apt: install
|
|
|
|
packages:
|
|
|
|
- ssh
|
2018-07-10 12:11:05 +01:00
|
|
|
- parted
|
2017-10-08 21:18:48 +01:00
|
|
|
- dosfstools
|
|
|
|
# Contains /lib/firmware/brcm/brcmfmac43430-sdio.bin (required for WiFi).
|
|
|
|
- firmware-brcm80211
|
|
|
|
- wireless-tools
|
|
|
|
- wpasupplicant
|
2018-11-24 21:44:40 +00:00
|
|
|
- raspi3-firmware
|
|
|
|
- linux-image-arm64
|
2019-01-13 13:38:36 +00:00
|
|
|
tag: /
|
2019-01-02 08:40:34 +00:00
|
|
|
unless: rootfs_unpacked
|
|
|
|
|
2019-01-13 13:38:36 +00:00
|
|
|
- cache-rootfs: /
|
2019-01-02 08:40:34 +00:00
|
|
|
unless: rootfs_unpacked
|
2017-10-08 21:18:48 +01:00
|
|
|
|
|
|
|
- shell: |
|
2019-07-19 01:18:59 +01:00
|
|
|
echo "rpi" > "${ROOT?}/etc/hostname"
|
2017-10-08 21:18:48 +01:00
|
|
|
|
|
|
|
# '..VyaTFxP8kT6' is crypt.crypt('raspberry', '..')
|
|
|
|
sed -i 's,root:[^:]*,root:..VyaTFxP8kT6,' "${ROOT?}/etc/shadow"
|
|
|
|
|
|
|
|
sed -i 's,#PermitRootLogin prohibit-password,PermitRootLogin yes,g' "${ROOT?}/etc/ssh/sshd_config"
|
|
|
|
|
|
|
|
install -m 644 -o root -g root fstab "${ROOT?}/etc/fstab"
|
|
|
|
|
|
|
|
install -m 644 -o root -g root eth0 "${ROOT?}/etc/network/interfaces.d/eth0"
|
|
|
|
|
|
|
|
mkdir -p "${ROOT?}/etc/iptables"
|
|
|
|
install -m 644 -o root -g root rules.v4 "${ROOT?}/etc/iptables/rules.v4"
|
|
|
|
install -m 644 -o root -g root rules.v6 "${ROOT?}/etc/iptables/rules.v6"
|
|
|
|
|
2019-07-19 01:18:59 +01:00
|
|
|
install -m 755 -o root -g root rpi-resizerootfs "${ROOT?}/usr/sbin/rpi3-resizerootfs"
|
|
|
|
install -m 644 -o root -g root rpi-resizerootfs.service "${ROOT?}/etc/systemd/system"
|
2017-10-08 21:18:48 +01:00
|
|
|
mkdir -p "${ROOT?}/etc/systemd/system/systemd-remount-fs.service.requires/"
|
2019-07-19 01:18:59 +01:00
|
|
|
ln -s /etc/systemd/system/rpi-resizerootfs.service "${ROOT?}/etc/systemd/system/systemd-remount-fs.service.requires/rpi3-resizerootfs.service"
|
2017-10-08 21:18:48 +01:00
|
|
|
|
2019-07-19 01:18:59 +01:00
|
|
|
install -m 644 -o root -g root rpi-generate-ssh-host-keys.service "${ROOT?}/etc/systemd/system"
|
2017-10-08 21:18:48 +01:00
|
|
|
mkdir -p "${ROOT?}/etc/systemd/system/multi-user.target.requires/"
|
2019-07-19 01:18:59 +01:00
|
|
|
ln -s /etc/systemd/system/rpi-generate-ssh-host-keys.service "${ROOT?}/etc/systemd/system/multi-user.target.requires/rpi3-generate-ssh-host-keys.service"
|
2017-10-08 21:18:48 +01:00
|
|
|
rm -f ${ROOT?}/etc/ssh/ssh_host_*_key*
|
|
|
|
|
|
|
|
cat >> "${ROOT?}/etc/motd" <<'EOT'
|
|
|
|
|
|
|
|
Please change the root password by running passwd
|
|
|
|
EOT
|
2019-01-13 13:38:36 +00:00
|
|
|
root-fs: /
|
2017-10-08 21:18:48 +01:00
|
|
|
|
|
|
|
# Clean up archive cache (likely not useful) and lists (likely outdated) to
|
|
|
|
# reduce image size by several hundred megabytes.
|
2019-01-13 13:38:36 +00:00
|
|
|
- chroot: /
|
2017-10-08 21:18:48 +01:00
|
|
|
shell: |
|
|
|
|
apt-get clean
|
|
|
|
rm -rf /var/lib/apt/lists
|
|
|
|
|
2018-08-16 01:13:27 +01:00
|
|
|
# Modify the kernel commandline we take from the firmware to boot from
|
|
|
|
# the partition labeled raspiroot instead of forcing it to mmcblk0p2
|
2019-01-13 13:38:36 +00:00
|
|
|
- chroot: /
|
2018-08-16 01:13:27 +01:00
|
|
|
shell: |
|
2019-01-02 08:40:34 +00:00
|
|
|
ls -aR /boot
|
2018-12-05 00:39:03 +00:00
|
|
|
sed -i 's/.dev.mmcblk0p2/LABEL=RASPIROOT/' /boot/firmware/cmdline.txt
|
2018-08-16 01:13:27 +01:00
|
|
|
|
2017-10-08 21:18:48 +01:00
|
|
|
# TODO(https://github.com/larswirzenius/vmdb2/issues/24): remove once vmdb
|
|
|
|
# clears /etc/resolv.conf on its own.
|
|
|
|
- shell: |
|
|
|
|
rm "${ROOT?}/etc/resolv.conf"
|
2019-01-13 13:38:36 +00:00
|
|
|
root-fs: /
|