Persist firmware if --storage is defined, fix video, and remove --headless (#11)

* Persist firmware if --storage is defined

* Fix video device to be correct to work with hyprland

* Remove headless
This commit is contained in:
Ryan Hughes authored and GitHub committed 2025-08-20 15:52:10 +02:00
1 parent 0e1b226e75
commit 72d9eaa417
1 file changed
+16 -22
+16 -22
View File
@@ -56,7 +56,6 @@ check_requirements() {
print_success "OVMF firmware is installed" print_success "OVMF firmware is installed"
fi fi
# Install missing packages # Install missing packages
if [ ${#packages_to_install[@]} -gt 0 ]; then if [ ${#packages_to_install[@]} -gt 0 ]; then
print_info "Installing missing packages: ${packages_to_install[*]}" print_info "Installing missing packages: ${packages_to_install[*]}"
@@ -162,6 +161,8 @@ build_qemu_command() {
# UEFI firmware (unless BIOS mode requested) # UEFI firmware (unless BIOS mode requested)
if [ -n "$OVMF_CODE" ] && [ "$BOOT_MODE" != "bios" ]; then if [ -n "$OVMF_CODE" ] && [ "$BOOT_MODE" != "bios" ]; then
# Persist firmaware as well if $STORAGE_DIR is specified
if [ -z "$STORAGE_DIR" ]; then
# Create writable VARS file from the correct template # Create writable VARS file from the correct template
OVMF_VARS_COPY="/tmp/OVMF_VARS_$$.fd" OVMF_VARS_COPY="/tmp/OVMF_VARS_$$.fd"
if [ -f "$OVMF_VARS" ]; then if [ -f "$OVMF_VARS" ]; then
@@ -170,6 +171,19 @@ build_qemu_command() {
# Fallback: create empty VARS file if template not found # Fallback: create empty VARS file if template not found
dd if=/dev/zero of="$OVMF_VARS_COPY" bs=1M count=4 2>/dev/null dd if=/dev/zero of="$OVMF_VARS_COPY" bs=1M count=4 2>/dev/null
fi fi
else
OVMF_VARS_COPY="$STORAGE_DIR/OVMF_VARS.fd"
# Only create firmaware file if it doesn't exist to allow persistence
if [ ! -f "$OVMF_VARS_COPY" ]; then
if [ -f "$OVMF_VARS" ]; then
cp "$OVMF_VARS" "$OVMF_VARS_COPY"
else
# Fallback: create empty VARS file if template not found
dd if=/dev/zero of="$OVMF_VARS_COPY" bs=1M count=4 2>/dev/null
fi
fi
fi
qemu_args+=("-drive" "if=pflash,format=raw,readonly=on,file=$OVMF_CODE") qemu_args+=("-drive" "if=pflash,format=raw,readonly=on,file=$OVMF_CODE")
qemu_args+=("-drive" "if=pflash,format=raw,file=$OVMF_VARS_COPY") qemu_args+=("-drive" "if=pflash,format=raw,file=$OVMF_VARS_COPY")
@@ -190,16 +204,8 @@ build_qemu_command() {
qemu_args+=("-drive" "file=$iso_file,media=cdrom,if=none,format=raw,id=cdrom0") qemu_args+=("-drive" "file=$iso_file,media=cdrom,if=none,format=raw,id=cdrom0")
qemu_args+=("-device" "ide-cd,drive=cdrom0,bootindex=2") qemu_args+=("-device" "ide-cd,drive=cdrom0,bootindex=2")
# Display configuration qemu_args+=("-device" "virtio-vga-gl")
if [ "$HEADLESS" = true ]; then
qemu_args+=("-nographic")
qemu_args+=("-vnc" ":1")
else
# Use virtio-vga for both UEFI and BIOS modes
qemu_args+=("-device" "virtio-vga")
# Enable OpenGL acceleration in GTK display
qemu_args+=("-display" "gtk,gl=on") qemu_args+=("-display" "gtk,gl=on")
fi
# Input devices # Input devices
qemu_args+=("-usb" "-device" "usb-tablet") qemu_args+=("-usb" "-device" "usb-tablet")
@@ -208,11 +214,9 @@ build_qemu_command() {
qemu_args+=("-netdev" "user,id=net0") qemu_args+=("-netdev" "user,id=net0")
qemu_args+=("-device" "virtio-net-pci,netdev=net0") qemu_args+=("-device" "virtio-net-pci,netdev=net0")
echo "${qemu_args[@]}" echo "${qemu_args[@]}"
} }
# Function to show usage # Function to show usage
show_usage() { show_usage() {
echo "Omarchy ISO Boot Tool - Arch Linux" echo "Omarchy ISO Boot Tool - Arch Linux"
@@ -224,7 +228,6 @@ show_usage() {
echo " --storage DIR Directory for VM storage (default: /tmp)" echo " --storage DIR Directory for VM storage (default: /tmp)"
echo " --memory MB Memory allocation in MB (default: 8192)" echo " --memory MB Memory allocation in MB (default: 8192)"
echo " --no-kvm Disable KVM acceleration" echo " --no-kvm Disable KVM acceleration"
echo " --headless Run without display (VNC on :1)"
echo " --help Show this help message" echo " --help Show this help message"
echo "" echo ""
echo "Examples:" echo "Examples:"
@@ -275,10 +278,6 @@ main() {
KVM_AVAILABLE=false KVM_AVAILABLE=false
print_info "KVM acceleration disabled by user" print_info "KVM acceleration disabled by user"
;; ;;
--headless)
HEADLESS=true
print_info "Headless mode enabled"
;;
*) *)
print_warning "Unknown option: $1" print_warning "Unknown option: $1"
;; ;;
@@ -297,11 +296,6 @@ main() {
print_info "Setting up storage..." print_info "Setting up storage..."
setup_storage setup_storage
# Show display information
if [ "$HEADLESS" = true ]; then
print_info "Headless mode. VNC server on :1 (port 5901)"
fi
print_info "Boot order: Disk (if bootable) -> ISO (fallback)" print_info "Boot order: Disk (if bootable) -> ISO (fallback)"
print_info "After installation, system will automatically boot from disk" print_info "After installation, system will automatically boot from disk"