Replace the old `void-exp` repository defaults with `void` so the Make targets, registration helper, example config, verification messaging, and sample test fixtures all line up with the new managed image name. Keep the scope to repo-facing naming only: config overrides, helper output, and test fixtures now expect `void`, while runtime compatibility for existing local `void-exp` VMs remains an operational concern outside this commit. Validation: go test ./..., make build, and a local `banger vm create --image void` smoke boot with ssh and opencode ports up.
88 lines
2.3 KiB
Bash
Executable file
88 lines
2.3 KiB
Bash
Executable file
#!/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)"
|
|
RUNTIME_DIR="${BANGER_MANUAL_DIR:-$REPO_ROOT/build/manual}"
|
|
IMAGE_NAME="${VOID_IMAGE_NAME:-void}"
|
|
BANGER_BIN="$(resolve_banger_bin)"
|
|
ROOTFS="$RUNTIME_DIR/rootfs-void.ext4"
|
|
WORK_SEED="$RUNTIME_DIR/rootfs-void.work-seed.ext4"
|
|
|
|
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"
|
|
)
|
|
|
|
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[@]}"
|