diff --git a/build/stage2.sh b/build/stage2.sh index 6f95d20..b78e6a7 100755 --- a/build/stage2.sh +++ b/build/stage2.sh @@ -58,6 +58,15 @@ bind() { mount --bind "$1" "$2" && MOUNTED+=("$2"); } mkdir -p "$WORK" "$DNF_CACHE" +# $WORK persists between builds so the staged base can be reused — which means +# everything else in it persists too, including intermediates from a build that +# was cancelled or failed before its cleanup ran. That is not inert: mkfs.vfat +# -C refuses to overwrite an existing file, and `mv dir $WORK/boot` nests inside +# a surviving directory rather than replacing it. So state the invariant +# positively — only the staged base and its stamp survive a new run. +find "$WORK" -mindepth 1 -maxdepth 1 \ + ! -name base ! -name base.stamp -exec rm -rf {} + + # --------------------------------------------------------------------------- # Build tooling. Every dnf transaction in here runs emulated, so the prebuilt # base image (gongfoo's build-fedora-44-aarch64) carries these already and this @@ -129,6 +138,12 @@ else # config. Both 50-dracut.install and 51-dracut-rescue.install bail out when # KERNEL_INSTALL_INITRD_GENERATOR is anything other than "dracut". # + # Expected side effect: with no initramfs present, 95-set-boot-entry.install + # logs "Error: /boot/initramfs-.img not found" and exits 1 during the + # transaction. rpm reports the scriptlet failure and carries on. It does not + # matter here — stage2 writes its own BLS entry below — and it cannot happen + # on the device, where this file is gone and dracut runs normally. + # # This file must not survive into the image — see the removal after the # working copy is made. mkdir -p "$BASE/etc/kernel"