2026-01-31 22:56:39 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
# Test Archipelago ISO in QEMU
|
2026-03-27 21:35:12 +00:00
|
|
|
#
|
|
|
|
|
# Usage:
|
|
|
|
|
# ./test-iso-qemu.sh [path-to-iso] [--bios] [--nographic]
|
|
|
|
|
#
|
|
|
|
|
# Options:
|
|
|
|
|
# --bios Force legacy BIOS mode (default: UEFI)
|
|
|
|
|
# --nographic No GUI window, serial console only (great for logging)
|
|
|
|
|
#
|
|
|
|
|
# Serial log is always written to /tmp/archipelago-qemu-serial.log
|
2026-01-31 22:56:39 +00:00
|
|
|
|
2026-02-01 02:22:02 +00:00
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
2026-03-27 21:35:12 +00:00
|
|
|
SERIAL_LOG="/tmp/archipelago-qemu-serial.log"
|
|
|
|
|
FORCE_BIOS=false
|
|
|
|
|
NOGRAPHIC=false
|
|
|
|
|
ISO=""
|
2026-01-31 22:56:39 +00:00
|
|
|
|
2026-03-27 21:35:12 +00:00
|
|
|
for arg in "$@"; do
|
|
|
|
|
case "$arg" in
|
|
|
|
|
--bios) FORCE_BIOS=true ;;
|
|
|
|
|
--nographic) NOGRAPHIC=true ;;
|
|
|
|
|
*) ISO="$arg" ;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Auto-detect ISO
|
|
|
|
|
if [ -z "$ISO" ]; then
|
|
|
|
|
ISO=$(ls -t "$SCRIPT_DIR"/results/archipelago-installer-unbundled-*.iso 2>/dev/null | head -1)
|
|
|
|
|
fi
|
|
|
|
|
if [ -z "$ISO" ] || [ ! -f "$ISO" ]; then
|
|
|
|
|
ISO=$(ls -t "$SCRIPT_DIR"/results/archipelago-*.iso 2>/dev/null | head -1)
|
|
|
|
|
fi
|
|
|
|
|
if [ -z "$ISO" ] || [ ! -f "$ISO" ]; then
|
|
|
|
|
echo "ISO not found."
|
2026-02-01 02:22:02 +00:00
|
|
|
echo ""
|
2026-03-27 21:35:12 +00:00
|
|
|
echo "Usage: $0 [path-to-iso] [--bios] [--nographic]"
|
2026-02-01 02:22:02 +00:00
|
|
|
echo ""
|
2026-03-27 21:35:12 +00:00
|
|
|
echo "Or place an ISO in: $SCRIPT_DIR/results/"
|
2026-01-31 22:56:39 +00:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2026-03-27 21:35:12 +00:00
|
|
|
echo "Testing Archipelago ISO in QEMU"
|
|
|
|
|
echo " ISO: $ISO"
|
|
|
|
|
echo " Size: $(du -h "$ISO" | cut -f1)"
|
|
|
|
|
echo " RAM: 4GB"
|
|
|
|
|
echo " CPU: 2 cores"
|
|
|
|
|
echo " Serial: $SERIAL_LOG"
|
2026-01-31 22:56:39 +00:00
|
|
|
echo ""
|
2026-02-01 02:22:02 +00:00
|
|
|
|
|
|
|
|
# Create test disk if it doesn't exist
|
|
|
|
|
DISK="/tmp/archipelago-test-disk.qcow2"
|
|
|
|
|
if [ ! -f "$DISK" ]; then
|
2026-03-27 21:35:12 +00:00
|
|
|
echo "Creating 20GB test disk..."
|
2026-02-01 02:22:02 +00:00
|
|
|
qemu-img create -f qcow2 "$DISK" 20G
|
|
|
|
|
fi
|
|
|
|
|
|
2026-03-27 21:35:12 +00:00
|
|
|
# Common QEMU args
|
|
|
|
|
QEMU_ARGS=(
|
|
|
|
|
-m 4G
|
|
|
|
|
-smp 2
|
|
|
|
|
-boot d
|
|
|
|
|
-cdrom "$ISO"
|
|
|
|
|
-drive if=virtio,format=qcow2,file="$DISK"
|
|
|
|
|
-net nic,model=virtio -net user,hostfwd=tcp::2222-:22,hostfwd=tcp::8100-:80
|
|
|
|
|
-serial file:"$SERIAL_LOG"
|
|
|
|
|
)
|
2026-01-31 22:56:39 +00:00
|
|
|
|
2026-03-27 21:35:12 +00:00
|
|
|
# Display mode
|
|
|
|
|
if [ "$NOGRAPHIC" = true ]; then
|
|
|
|
|
QEMU_ARGS+=(-nographic -append "console=ttyS0")
|
2026-02-01 02:22:02 +00:00
|
|
|
else
|
2026-03-27 21:35:12 +00:00
|
|
|
QEMU_ARGS+=(-vga virtio -display default)
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "Starting VM..."
|
|
|
|
|
echo "(Serial console logging to $SERIAL_LOG)"
|
|
|
|
|
echo "(Press Ctrl+Alt+G to release mouse, Ctrl+C to stop VM)"
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
# Detect UEFI firmware
|
|
|
|
|
OVMF=""
|
|
|
|
|
if [ "$FORCE_BIOS" = false ]; then
|
|
|
|
|
if [ -f "/opt/homebrew/share/qemu/edk2-x86_64-code.fd" ]; then
|
|
|
|
|
OVMF="/opt/homebrew/share/qemu/edk2-x86_64-code.fd"
|
|
|
|
|
elif [ -f "/usr/share/OVMF/OVMF_CODE.fd" ]; then
|
|
|
|
|
OVMF="/usr/share/OVMF/OVMF_CODE.fd"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -n "$OVMF" ]; then
|
|
|
|
|
echo " Boot: UEFI ($OVMF)"
|
|
|
|
|
qemu-system-x86_64 \
|
|
|
|
|
-machine q35 \
|
|
|
|
|
-drive if=pflash,format=raw,readonly=on,file="$OVMF" \
|
|
|
|
|
"${QEMU_ARGS[@]}"
|
|
|
|
|
else
|
|
|
|
|
echo " Boot: Legacy BIOS"
|
2026-02-01 02:22:02 +00:00
|
|
|
qemu-system-x86_64 \
|
|
|
|
|
-machine pc \
|
2026-03-27 21:35:12 +00:00
|
|
|
"${QEMU_ARGS[@]}"
|
2026-02-01 02:22:02 +00:00
|
|
|
fi
|
|
|
|
|
|
2026-03-27 21:35:12 +00:00
|
|
|
echo ""
|
|
|
|
|
echo "VM stopped. Serial log: $SERIAL_LOG"
|
|
|
|
|
echo "Last 20 lines:"
|
|
|
|
|
tail -20 "$SERIAL_LOG" 2>/dev/null
|