Reorganize the source checkout layout
Separate tracked source from generated artifacts so the repo root stops accumulating helper scripts, manifests, and local runtime outputs. Move manual shell entrypoints under scripts/, manifests under config/, and the Firecracker API reference under docs/reference/. Make build and runtimebundle now target build/bin, build/runtime, and build/dist as the canonical source-checkout paths. Update runtime discovery, helper scripts, tests, and docs to follow the new layout while keeping legacy source-checkout runtime fallbacks for existing local bundles during migration. Validated with bash -n on the moved scripts, make build, and GOCACHE=/tmp/banger-gocache go test ./....
This commit is contained in:
parent
2362d0ae39
commit
01c7cb5e65
23 changed files with 296 additions and 186 deletions
95
scripts/register-void-image.sh
Executable file
95
scripts/register-void-image.sh
Executable file
|
|
@ -0,0 +1,95 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
log() {
|
||||
printf '[register-void-image] %s\n' "$*" >&2
|
||||
}
|
||||
|
||||
find_latest_matching() {
|
||||
local dir="$1"
|
||||
local pattern="$2"
|
||||
if [[ ! -d "$dir" ]]; then
|
||||
return 1
|
||||
fi
|
||||
find "$dir" -maxdepth 1 -type f -name "$pattern" | sort | tail -n 1
|
||||
}
|
||||
|
||||
find_latest_module_dir() {
|
||||
local root="$1"
|
||||
if [[ ! -d "$root" ]]; then
|
||||
return 1
|
||||
fi
|
||||
find "$root" -mindepth 1 -maxdepth 1 -type d | sort | tail -n 1
|
||||
}
|
||||
|
||||
resolve_banger_bin() {
|
||||
if [[ -n "${BANGER_BIN:-}" ]]; then
|
||||
printf '%s\n' "$BANGER_BIN"
|
||||
return
|
||||
fi
|
||||
if [[ -x "$REPO_ROOT/build/bin/banger" ]]; then
|
||||
printf '%s\n' "$REPO_ROOT/build/bin/banger"
|
||||
return
|
||||
fi
|
||||
if [[ -x "$REPO_ROOT/banger" ]]; then
|
||||
printf '%s\n' "$REPO_ROOT/banger"
|
||||
return
|
||||
fi
|
||||
if command -v banger >/dev/null 2>&1; then
|
||||
command -v banger
|
||||
return
|
||||
fi
|
||||
log "banger binary not found; build it first with 'make build' or set BANGER_BIN"
|
||||
exit 1
|
||||
}
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
DEFAULT_RUNTIME_DIR="$REPO_ROOT/build/runtime"
|
||||
if [[ ! -d "$DEFAULT_RUNTIME_DIR" && -d "$REPO_ROOT/runtime" ]]; then
|
||||
DEFAULT_RUNTIME_DIR="$REPO_ROOT/runtime"
|
||||
fi
|
||||
|
||||
RUNTIME_DIR="${BANGER_RUNTIME_DIR:-$DEFAULT_RUNTIME_DIR}"
|
||||
IMAGE_NAME="${VOID_IMAGE_NAME:-void-exp}"
|
||||
BANGER_BIN="$(resolve_banger_bin)"
|
||||
ROOTFS="$RUNTIME_DIR/rootfs-void.ext4"
|
||||
WORK_SEED="$RUNTIME_DIR/rootfs-void.work-seed.ext4"
|
||||
PACKAGES="$REPO_ROOT/config/packages.void"
|
||||
|
||||
if [[ ! -f "$ROOTFS" ]]; then
|
||||
log "missing Void rootfs: $ROOTFS"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f "$WORK_SEED" ]]; then
|
||||
log "missing Void work-seed: $WORK_SEED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
args=(
|
||||
image register
|
||||
--name "$IMAGE_NAME"
|
||||
--rootfs "$ROOTFS"
|
||||
--work-seed "$WORK_SEED"
|
||||
--packages "$PACKAGES"
|
||||
)
|
||||
|
||||
if [[ ! -d "$RUNTIME_DIR/void-kernel" ]]; then
|
||||
log "missing staged Void kernel artifacts: $RUNTIME_DIR/void-kernel"
|
||||
log "run 'make void-kernel' before registering $IMAGE_NAME"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
kernel="$(find_latest_matching "$RUNTIME_DIR/void-kernel/boot" 'vmlinux-*' || true)"
|
||||
initrd="$(find_latest_matching "$RUNTIME_DIR/void-kernel/boot" 'initramfs-*' || true)"
|
||||
modules="$(find_latest_module_dir "$RUNTIME_DIR/void-kernel/lib/modules" || true)"
|
||||
|
||||
if [[ -z "$kernel" || -z "$initrd" || -z "$modules" ]]; then
|
||||
log "staged Void kernel is incomplete; expected vmlinux, initramfs, and modules under $RUNTIME_DIR/void-kernel"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "using staged Void kernel artifacts from $RUNTIME_DIR/void-kernel"
|
||||
args+=(--kernel "$kernel" --initrd "$initrd" --modules "$modules")
|
||||
|
||||
"$BANGER_BIN" "${args[@]}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue