From 179f88d00b76993ad2d94b9630226d0a5490ac4f Mon Sep 17 00:00:00 2001 From: Roland Date: Wed, 11 Feb 2026 17:38:04 -0700 Subject: [PATCH] Updating pi-gen build to use bookworm-arm64 branch. --- pi-gen/build.sh | 40 +++++++++++++++---- pi-gen/config.txt | 4 +- pi-gen/stage2/04-wrolpi/00-run-chroot.sh | 15 +++++++ .../04-wrolpi/{01-packages => 01-packages-nr} | 0 4 files changed, 49 insertions(+), 10 deletions(-) create mode 100755 pi-gen/stage2/04-wrolpi/00-run-chroot.sh rename pi-gen/stage2/04-wrolpi/{01-packages => 01-packages-nr} (100%) diff --git a/pi-gen/build.sh b/pi-gen/build.sh index 18379e0c..2ff5de4d 100755 --- a/pi-gen/build.sh +++ b/pi-gen/build.sh @@ -2,7 +2,7 @@ # https://github.com/RPI-Distro/pi-gen SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -BUILD_DIR=/tmp/wrolpi-build-pi-gen +BUILD_DIR=/var/tmp/wrolpi-build-pi-gen VERSION=$(cat "${SCRIPT_DIR}/../wrolpi/version.txt") @@ -17,15 +17,38 @@ if [ ! -f "${SCRIPT_DIR}/stage2/04-wrolpi/files/map-db-gis.dump" ]; then exit 1 fi +CHROOTFS="${BUILD_DIR}/work/WROLPi/stage0/rootfs" + +cleanup() { + [ -f /var/tmp/bookworm-arm64.zip ] && rm /var/tmp/bookworm-arm64.zip + + # Only unmount if it is actually a mountpoint + for mp in \ + "${CHROOTFS}/dev/pts" \ + "${CHROOTFS}/sys" \ + "${CHROOTFS}/proc" \ + "${CHROOTFS}/run" \ + "${CHROOTFS}/tmp" \ + "${CHROOTFS}/dev"; do + + if mountpoint -q "${mp}" 2>/dev/null; then + umount "${mp}" 2>/dev/null || umount -l "${mp}" 2>/dev/null + fi + done + + # Final safety net – remove the whole build tree + rm -rf "${BUILD_DIR}" +} + +trap cleanup EXIT + set -e set -x -# Clear out old builds. -[ -d "${BUILD_DIR}" ] && rm -rf "${BUILD_DIR}" -mkdir "${BUILD_DIR}" - -# We need the arm64 branch for modern RPi. -git clone --branch arm64 https://github.com/RPI-Distro/pi-gen.git "${BUILD_DIR}" +# Get the latest pi-gen code. +wget https://github.com/RPi-Distro/pi-gen/archive/refs/heads/bookworm-arm64.zip -O /var/tmp/bookworm-arm64.zip +unzip /var/tmp/bookworm-arm64.zip -d /var/tmp +mv /var/tmp/pi-gen-bookworm-arm64 /var/tmp/wrolpi-build-pi-gen # Copy the configuration and build files into the pi-gen directory. cp "${SCRIPT_DIR}/config.txt" "${BUILD_DIR}/config.txt" @@ -40,7 +63,8 @@ echo 'IMG_SUFFIX="-desktop"' > "${BUILD_DIR}/stage5/EXPORT_IMAGE" (cd "${BUILD_DIR}" && time nice -n 18 "${BUILD_DIR}"/build.sh -c "${BUILD_DIR}"/config.txt | \ tee "${SCRIPT_DIR}"/build.log) -grep "02-run.sh completed" "${SCRIPT_DIR}/build.log" >/dev/null 2>&1 || (echo "script 2 failed!" && exit 1) +grep "00-run-chroot.sh completed" "${SCRIPT_DIR}/build.log" >/dev/null 2>&1 || (echo "script 0 failed!" && exit 1) +grep "03-run-chroot.sh completed" "${SCRIPT_DIR}/build.log" >/dev/null 2>&1 || (echo "script 3 failed!" && exit 1) grep "03-run-chroot.sh completed" "${SCRIPT_DIR}/build.log" >/dev/null 2>&1 || (echo "script 3 failed!" && exit 1) grep "04-run-chroot.sh completed" "${SCRIPT_DIR}/build.log" >/dev/null 2>&1 || (echo "script 4 failed!" && exit 1) diff --git a/pi-gen/config.txt b/pi-gen/config.txt index 47c98421..0af6b605 100644 --- a/pi-gen/config.txt +++ b/pi-gen/config.txt @@ -1,5 +1,5 @@ IMG_NAME=WROLPi -BASE_QCOW2_SIZE=12G +BASE_QCOW2_SIZE=48G RELEASE=bookworm LOCALE_DEFAULT=en_US.UTF-8 TARGET_HOSTNAME=wrolpi @@ -7,4 +7,4 @@ KEYBOARD_KEYMAP=en_US KEYBOARD_LAYOUT="English (US)" ENABLE_SSH=1 DEPLOY_COMPRESSION=xz -WPA_COUNTRY=US \ No newline at end of file +WPA_COUNTRY=US diff --git a/pi-gen/stage2/04-wrolpi/00-run-chroot.sh b/pi-gen/stage2/04-wrolpi/00-run-chroot.sh new file mode 100755 index 00000000..6ef25062 --- /dev/null +++ b/pi-gen/stage2/04-wrolpi/00-run-chroot.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e +set -x + +# Preseed debconf answers to avoid interactive prompts during package installation. +# iperf3 asks whether to start as a daemon at boot - answer yes since we enable it via systemctl. +echo "iperf3 iperf3/start_daemon boolean true" | debconf-set-selections + +set +x + +echo +echo "======================================================================" +echo "00-run-chroot.sh completed" +echo "======================================================================" +echo diff --git a/pi-gen/stage2/04-wrolpi/01-packages b/pi-gen/stage2/04-wrolpi/01-packages-nr similarity index 100% rename from pi-gen/stage2/04-wrolpi/01-packages rename to pi-gen/stage2/04-wrolpi/01-packages-nr