Skip to content

Commit a0dc48a

Browse files
committed
fix(builder): custom build copied the ISO store-dir, not the ISO file
The install-iso store path is named ...-nixos-*.iso but is a DIRECTORY (iso/<file> inside), so 'find -name *.iso | head' matched the dir → cp failed ('omitting directory'). Validation run got all the way through squashfs+ISO, then died here. Match files only with -type f -print -quit (also removes the pipefail/SIGPIPE risk of | head); same fix for the netboot kernel/initrd/ipxe finds.
1 parent 5833081 commit a0dc48a

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

scripts/build-custom-image.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ if [[ "$TARGET" == "iso" ]]; then
137137
nix build --no-link --print-out-paths \
138138
"$WORK/build#packages.${ARCH}-linux.image" --print-build-logs > "$WORK/outpath" || die "nix build failed"
139139
RESULT="$(cat "$WORK/outpath")"
140-
ISO="$(find -L "$RESULT" -name '*.iso' | head -1)"
140+
# NB: the store path itself ends in `.iso` but is a DIRECTORY (iso/ inside);
141+
# match files only, first hit, no pipe (avoids matching the dir + SIGPIPE).
142+
ISO="$(find -L "$RESULT" -type f -name '*.iso' -print -quit)"
141143
[[ -n "$ISO" ]] || die "no ISO produced"
142144
NAME="sourceos-${EDITION}-${ARCH}-custom.iso"
143145
cp "$ISO" "$OUT/$NAME"
@@ -146,13 +148,15 @@ if [[ "$TARGET" == "iso" ]]; then
146148
elif [[ "$TARGET" == "netboot" ]]; then
147149
log "nix build netboot kernel + initramfs (long step)..."
148150
base="$WORK/build#nixosConfigurations.netboot.config.system.build"
149-
KERNEL="$(nix build --no-link --print-out-paths "$base.kernel" --print-build-logs)/bzImage" || die "kernel build failed"
150-
[[ -f "$KERNEL" ]] || KERNEL="$(find -L "$(nix build --no-link --print-out-paths "$base.kernel")" -name 'bzImage' -o -name 'Image' | head -1)"
151+
KDIR="$(nix build --no-link --print-out-paths "$base.kernel" --print-build-logs)" || die "kernel build failed"
152+
KERNEL="$(find -L "$KDIR" -type f \( -name 'bzImage' -o -name 'Image' \) -print -quit)"
153+
[[ -n "$KERNEL" ]] || die "no kernel found in $KDIR"
151154
RAMDISK_DIR="$(nix build --no-link --print-out-paths "$base.netbootRamdisk")" || die "ramdisk build failed"
152-
INITRD="$(find -L "$RAMDISK_DIR" -name 'initrd*' | head -1)"
155+
INITRD="$(find -L "$RAMDISK_DIR" -type f -name 'initrd*' -print -quit)"
156+
[[ -n "$INITRD" ]] || die "no initrd found in $RAMDISK_DIR"
153157
IPXE="$(nix build --no-link --print-out-paths "$base.netbootIpxeScript")" || die "ipxe build failed"
154158
# kargs = everything after the kernel path on the ipxe `kernel` line.
155-
KARGS="$(grep -E '^kernel ' "$(find -L "$IPXE" -type f | head -1)" | sed -E 's#^kernel +\S+ +##')"
159+
KARGS="$(grep -E '^kernel ' "$(find -L "$IPXE" -type f -print -quit)" | sed -E 's#^kernel +\S+ +##')"
156160
cp "$KERNEL" "$OUT/kernel"; cp "$INITRD" "$OUT/initrd"
157161
( cd "$OUT" && sha256sum kernel initrd > netboot.sha256 )
158162
KSUM="$(awk '/kernel$/{print $1}' "$OUT/netboot.sha256")"

0 commit comments

Comments
 (0)