- Dockerfile.builder: Go 1.24.0 → 1.25.5 (go.mod requires it) - test-boot.sh: use direct kernel boot via ISO extraction instead of broken -cdrom + -append; fix boot marker to "KubeSolo is running" (Stage 90 blocks on wait, never emits "complete") - test-security-hardening.sh: same direct kernel boot and marker fixes - run-vm.sh, dev-vm.sh, dev-vm-arm64.sh: quote QEMU -net args to silence shellcheck SC2054 - fetch-components.sh, fetch-rpi-firmware.sh, dev-vm-arm64.sh: fix trap quoting (SC2064) Validated: full Docker build, 94 Go tests pass, QEMU boot (73s), security hardening test (6/6 pass, 1 AppArmor skip pending kernel rebuild). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
101 lines
3.0 KiB
Bash
Executable File
101 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# dev-vm-arm64.sh — Launch ARM64 QEMU VM for development
|
|
#
|
|
# Uses qemu-system-aarch64 with -machine virt to emulate an ARM64 system.
|
|
# This is useful for testing ARM64/RPi builds on x86_64 hosts.
|
|
#
|
|
# Usage:
|
|
# ./hack/dev-vm-arm64.sh # Use default kernel + initramfs
|
|
# ./hack/dev-vm-arm64.sh <kernel> <initramfs> # Specify custom paths
|
|
# ./hack/dev-vm-arm64.sh --debug # Enable debug logging
|
|
# ./hack/dev-vm-arm64.sh --shell # Drop to emergency shell
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
VMLINUZ=""
|
|
INITRD=""
|
|
EXTRA_APPEND=""
|
|
|
|
# Parse arguments
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--shell) EXTRA_APPEND="$EXTRA_APPEND kubesolo.shell" ;;
|
|
--debug) EXTRA_APPEND="$EXTRA_APPEND kubesolo.debug" ;;
|
|
*)
|
|
if [ -z "$VMLINUZ" ]; then
|
|
VMLINUZ="$arg"
|
|
elif [ -z "$INITRD" ]; then
|
|
INITRD="$arg"
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Defaults
|
|
VMLINUZ="${VMLINUZ:-$PROJECT_ROOT/build/cache/custom-kernel-arm64/Image}"
|
|
INITRD="${INITRD:-$PROJECT_ROOT/build/rootfs-work/kubesolo-os.gz}"
|
|
|
|
# Verify files exist
|
|
if [ ! -f "$VMLINUZ" ]; then
|
|
echo "ERROR: Kernel not found: $VMLINUZ"
|
|
echo " Run 'make kernel-arm64' to build the ARM64 kernel."
|
|
exit 1
|
|
fi
|
|
if [ ! -f "$INITRD" ]; then
|
|
echo "ERROR: Initrd not found: $INITRD"
|
|
echo " Run 'make initramfs' to build the initramfs."
|
|
exit 1
|
|
fi
|
|
|
|
# Find mkfs.ext4
|
|
MKFS_EXT4=""
|
|
if command -v mkfs.ext4 >/dev/null 2>&1; then
|
|
MKFS_EXT4="mkfs.ext4"
|
|
elif [ -x "/opt/homebrew/opt/e2fsprogs/sbin/mkfs.ext4" ]; then
|
|
MKFS_EXT4="/opt/homebrew/opt/e2fsprogs/sbin/mkfs.ext4"
|
|
elif [ -x "/usr/local/opt/e2fsprogs/sbin/mkfs.ext4" ]; then
|
|
MKFS_EXT4="/usr/local/opt/e2fsprogs/sbin/mkfs.ext4"
|
|
fi
|
|
|
|
if [ -z "$MKFS_EXT4" ]; then
|
|
echo "ERROR: mkfs.ext4 not found. Install e2fsprogs:"
|
|
if [ "$(uname)" = "Darwin" ]; then
|
|
echo " brew install e2fsprogs"
|
|
else
|
|
echo " apt install e2fsprogs # Debian/Ubuntu"
|
|
echo " dnf install e2fsprogs # Fedora/RHEL"
|
|
fi
|
|
exit 1
|
|
fi
|
|
|
|
# Create data disk
|
|
DATA_DISK="$(mktemp /tmp/kubesolo-arm64-data-XXXXXX).img"
|
|
dd if=/dev/zero of="$DATA_DISK" bs=1M count=1024 2>/dev/null
|
|
"$MKFS_EXT4" -q -L KSOLODATA "$DATA_DISK" 2>/dev/null
|
|
trap 'rm -f "$DATA_DISK"' EXIT
|
|
|
|
echo "==> Launching ARM64 QEMU VM..."
|
|
echo " Kernel: $VMLINUZ"
|
|
echo " Initrd: $INITRD"
|
|
echo " Data: $DATA_DISK"
|
|
echo ""
|
|
echo " K8s API: localhost:6443"
|
|
echo " SSH: localhost:2222"
|
|
echo " Press Ctrl+A X to exit QEMU"
|
|
echo ""
|
|
|
|
qemu-system-aarch64 \
|
|
-machine virt \
|
|
-cpu cortex-a72 \
|
|
-m 2048 \
|
|
-smp 2 \
|
|
-nographic \
|
|
-kernel "$VMLINUZ" \
|
|
-initrd "$INITRD" \
|
|
-append "console=ttyAMA0 kubesolo.data=/dev/vda kubesolo.debug $EXTRA_APPEND" \
|
|
-drive "file=$DATA_DISK,format=raw,if=virtio" \
|
|
-net "nic,model=virtio" \
|
|
-net "user,hostfwd=tcp::6443-:6443,hostfwd=tcp::2222-:22"
|