From 09f4182e6aadcd5fe209beae61f8eb6ec4858687 Mon Sep 17 00:00:00 2001 From: Drake Date: Thu, 24 Sep 2026 11:22:15 -0500 Subject: [PATCH] scripts: verify_recovery_tools uses a private temp initrd; fail on a missing image Parallel verify_all.sh runs shared /tmp/aienos-recovery-standalone-initrd.img and corrupted each other's copy (gzip: unexpected end of file), and the user-owned leftover later blocked the root recovery-media build (fs.protected_regular=2). Without an argument the script now builds into its own mktemp dir; with an argument it inspects exactly that image and fails if it's missing instead of silently building a substitute. Co-authored-by: Drake Co-Authored-By: Claude Opus 5.5 --- scripts/verify_recovery_tools.sh | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/scripts/verify_recovery_tools.sh b/scripts/verify_recovery_tools.sh index 56d08651..def6e4d4 100755 --- a/scripts/verify_recovery_tools.sh +++ b/scripts/verify_recovery_tools.sh @@ -11,18 +11,30 @@ set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "${REPO_ROOT}" -INITRD_IMG="${1:-/tmp/aienos-recovery-standalone-initrd.img}" +WORK_DIR=$(mktemp -d) +trap 'rm -rf "${WORK_DIR}"' EXIT -if [[ ! -f "${INITRD_IMG}" ]]; then +# With an argument: inspect exactly that image, and fail if it is missing +# (never substitute a freshly built one). Without: build a private copy in +# WORK_DIR, so parallel runs never share a fixed /tmp path and no stale +# user-owned file is left where a root build would later collide with it. +if [[ $# -ge 1 ]]; then + INITRD_IMG="$1" + if [[ ! -f "${INITRD_IMG}" ]]; then + echo "FAIL initrd image not found: ${INITRD_IMG}" >&2 + exit 1 + fi +else + INITRD_IMG="${WORK_DIR}/aienos-recovery-standalone-initrd.img" echo "Building standalone recovery initrd..." bash "${REPO_ROOT}/scripts/build_standalone_recovery_initrd.sh" "${INITRD_IMG}" fi -WORK_DIR=$(mktemp -d) -trap 'rm -rf "${WORK_DIR}"' EXIT +ROOT_DIR="${WORK_DIR}/root" +mkdir -p "${ROOT_DIR}" echo "Extracting ${INITRD_IMG}..." -gzip -dc "${INITRD_IMG}" | (cd "${WORK_DIR}" && cpio -idm --quiet) +gzip -dc "${INITRD_IMG}" | (cd "${ROOT_DIR}" && cpio -idm --quiet) FAILED=0 check() { @@ -34,9 +46,9 @@ check() { fi } -have_file() { [[ -f "${WORK_DIR}/$1" || -x "${WORK_DIR}/$1" || -L "${WORK_DIR}/$1" ]] && echo 1 || echo 0; } -init_has() { grep -q -- "$1" "${WORK_DIR}/init" 2>/dev/null && echo 1 || echo 0; } -module_packaged() { grep -qxF "$1.ko" "${WORK_DIR}/etc/aienos-modules.order" 2>/dev/null && echo 1 || echo 0; } +have_file() { [[ -f "${ROOT_DIR}/$1" || -x "${ROOT_DIR}/$1" || -L "${ROOT_DIR}/$1" ]] && echo 1 || echo 0; } +init_has() { grep -q -- "$1" "${ROOT_DIR}/init" 2>/dev/null && echo 1 || echo 0; } +module_packaged() { grep -qxF "$1.ko" "${ROOT_DIR}/etc/aienos-modules.order" 2>/dev/null && echo 1 || echo 0; } echo "" echo "-- required tools for NVMe root mount --" @@ -62,7 +74,7 @@ check "chroot present" "$(have_file bin/chroot)" echo "" echo "-- init hooks --" -check "init is executable" "$([[ -x "${WORK_DIR}/init" ]] && echo 1 || echo 0)" +check "init is executable" "$([[ -x "${ROOT_DIR}/init" ]] && echo 1 || echo 0)" check "init keeps zero-disk test mode (aienos.test=1)" "$(init_has 'aienos.test=1')" check "init reports EFI boot entries (efibootmgr)" "$(init_has 'efibootmgr')" check "init drops into an interactive maintenance shell" "$(init_has 'exec /bin/sh')"