From ebda614a8dd43b44f8e0d9d844eac7a979a011bd Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 21 Apr 2026 20:12:55 -0500 Subject: fix: cleanup on empty findmnt + stale profiledef entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two pre-existing build.sh bugs surfaced while rebuilding the ISO for the first time since the April lib/ refactor. 1. safe_cleanup_work_dir runs findmnt | grep | sort in a command substitution. When no mounts match (the common case — this is a defensive sweep on top of the explicit known-mount loop), grep exits 1, pipefail propagates it, set -e exits the script. The trap then reports "Build interrupted or failed" and the build aborts before doing any work. Swallow the grep status with || true; no-match is not an error here. 2. The profiledef.sh file_permissions seds drifted out of sync with the lib/ refactor: - lib/zfs.sh was removed in 3321f0f but its sed block stayed, producing a warning every build ("Cannot change permissions of '.../lib/zfs.sh': no such file"). - lib/raid.sh was added in 19f4624 without a corresponding sed, so the file shipped with whatever permissions cp gave it. Drop the zfs.sh block and add the raid.sh block. --- build.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 6144932..06399ec 100755 --- a/build.sh +++ b/build.sh @@ -50,9 +50,11 @@ safe_cleanup_work_dir() { # Catch any other mounts under airootfs (bind mounts not in the # explicit list above). Deepest-first via reverse sort. + # grep exits 1 on no-match; with pipefail that would propagate and + # trip set -e, so swallow it — "no leftover mounts" is the common case. local leftover leftover=$(findmnt --list --noheadings -o TARGET 2>/dev/null \ - | grep "$airootfs" | sort -r) + | grep "$airootfs" | sort -r || true) if [[ -n "$leftover" ]]; then while IFS= read -r mp; do umount -l "$mp" 2>/dev/null || true @@ -422,10 +424,10 @@ if grep -q "file_permissions=" "$PROFILE_DIR/profiledef.sh"; then /)/ i\ ["/usr/local/bin/lib/disk.sh"]="0:0:755" }' "$PROFILE_DIR/profiledef.sh" sed -i '/^file_permissions=(/,/)/ { - /)/ i\ ["/usr/local/bin/lib/zfs.sh"]="0:0:755" + /)/ i\ ["/usr/local/bin/lib/btrfs.sh"]="0:0:755" }' "$PROFILE_DIR/profiledef.sh" sed -i '/^file_permissions=(/,/)/ { - /)/ i\ ["/usr/local/bin/lib/btrfs.sh"]="0:0:755" + /)/ i\ ["/usr/local/bin/lib/raid.sh"]="0:0:755" }' "$PROFILE_DIR/profiledef.sh" sed -i '/^file_permissions=(/,/)/ { /)/ i\ ["/etc/shadow"]="0:0:400" -- cgit v1.2.3