Files
bfe-core1106-sdk/qemu/mkinitramfs.sh
T
BFE EngineeringandClaude Opus 5.5 820af4baaa
ci / test (push) Successful in 7s
ci / bench (push) Successful in 9s
ci / mcdc (push) Successful in 22s
ci / patches-apply (push) Successful in 50s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / qemu-tools (push) Failing after 27s
ci / quality (push) Successful in 1m17s
ci / badges (push) Skipped
ci / kernel-symbols (push) Successful in 7m7s
ci / test (pull_request) Successful in 9s
ci / bench (pull_request) Successful in 11s
ci / mcdc (pull_request) Successful in 13s
ci / patches-apply (pull_request) Successful in 54s
ci / qemu-tools (pull_request) Failing after 11s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / quality (pull_request) Successful in 1m27s
ci / badges (pull_request) Skipped
ci / kernel-symbols (pull_request) Successful in 4m10s
qemu: let a job without the cross compiler use a prebuilt panel BusyBox (flare-edge#2210)
The flare-edge flow jobs get the rig BusyBox from the image build job's
artifact and have no cross compiler, so RIG_BUSYBOX=panel, which always ran
build-busybox.sh, could not be used there.

- qemu/lib.sh: qemu_busybox_panel_inputs, one sha256 over the source pin
  and every committed input under qemu/busybox/ (no compiler). With
  RIG_BUSYBOX=panel and BUSYBOX set, qemu_get_busybox takes that binary only
  when BUSYBOX.inputs equals the value for this tree; otherwise it fails
  closed. The source pin moved here from build-busybox.sh.
- qemu/build-busybox.sh writes <binary>.inputs next to the binary (also on
  the up-to-date path) and removes a stale one before a rebuild.
- busybox-panel-test.sh: missing, foreign and matching .inputs, a missing
  binary, and a config or patch edit changing the inputs.
- CI qemu-tools: a panel initramfs from the prebuilt binary.

Refs flare-edge#2210

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
2026-10-29 08:34:45 -06:00

40 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build the QEMU device-sim initramfs: the pinned static busybox + qemu/rootfs/.
# The busybox binary is the ONLY external input (sha256-pinned, fail-closed:
# see qemu/lib.sh).
#
# Env:
# BUSYBOX path to a local busybox binary (skips the download; still verified;
# with RIG_BUSYBOX=panel a prebuilt panel binary, checked by its .inputs)
# RIG_BUSYBOX multiarch (default) or panel: the image's own BusyBox, built by
# qemu/build-busybox.sh (see qemu/busybox/README.md)
# OUT output dir (default: qemu/out); initramfs at $OUT/initramfs.cpio.gz
# EXTRA_DIR a directory merged into the initramfs root (a test's scripts and
# static binaries; init runs one on warden.run=<path>)
set -euo pipefail
QEMU_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=qemu/lib.sh disable=SC1091
. "$QEMU_DIR/lib.sh"
OUT="${OUT:-$QEMU_DIR/out}"
qemu_get_busybox
# Assemble in a scratch dir, removed on exit (scratch-dir leaks were a past
# review finding in this repo).
SCRATCH="$(mktemp -d "${TMPDIR:-/tmp}/warden-qemu-initramfs.XXXXXX")"
trap 'rm -rf "$SCRATCH"' EXIT
qemu_stage_rootfs "$SCRATCH/root"
# The kernel symbol list, so init can check it against /proc/config.gz.
install -D -m 0644 "$QEMU_DIR/../build/required-symbols.txt" "$SCRATCH/root/etc/required-symbols.txt"
if [ -n "${EXTRA_DIR:-}" ]; then
[ -d "$EXTRA_DIR" ] || { echo "FATAL: EXTRA_DIR is not a directory: $EXTRA_DIR" >&2; exit 1; }
cp -a "$EXTRA_DIR/." "$SCRATCH/root/"
fi
# Pack (newc cpio, gzip). No device nodes required: /init mounts devtmpfs and
# reopens the console itself, so the archive builds unprivileged.
( cd "$SCRATCH/root" && find . -print0 | cpio -0 -o -H newc -R +0:+0 2>/dev/null ) \
| gzip -9 > "$OUT/initramfs.cpio.gz"
qemu_log "initramfs: $OUT/initramfs.cpio.gz ($(du -h "$OUT/initramfs.cpio.gz" | cut -f1))"