From e87d10dd82be94a751538c7ddd3bd8bbad2d70b2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Dec 2025 18:27:51 +0000 Subject: [PATCH 1/4] Initial plan From 24626b541a7684316c502e27a36c6059381ab428 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Dec 2025 18:30:55 +0000 Subject: [PATCH 2/4] Fix GRUB boot issue by embedding bootstrap configuration Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com> --- scripts/docker-image-create-uefi.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/docker-image-create-uefi.sh b/scripts/docker-image-create-uefi.sh index b5b8c83..3e33526 100755 --- a/scripts/docker-image-create-uefi.sh +++ b/scripts/docker-image-create-uefi.sh @@ -13,13 +13,28 @@ echo "Preparing ESP contents..." mkdir -p /staging/esp/EFI/BOOT mkdir -p /staging/esp/boot/grub -# Create GRUB EFI binary using grub-mkstandalone +# Create minimal embedded GRUB configuration that searches for external config +cat > /tmp/embedded_grub.cfg << 'EOF' +# Embedded bootstrap configuration for GRUB +# This config tells GRUB where to find the real configuration file + +search --no-floppy --set=root --label SPARKOSEFI +if [ -e /boot/grub/grub.cfg ]; then + configfile /boot/grub/grub.cfg +else + echo "Error: Could not find /boot/grub/grub.cfg" + echo "Press any key to enter GRUB command line..." + read +fi +EOF + +# Create GRUB EFI binary using grub-mkstandalone with embedded bootstrap config grub-mkstandalone \ --format=x86_64-efi \ --output=/staging/esp/EFI/BOOT/BOOTX64.EFI \ --locales="" \ --fonts="" \ - "boot/grub/grub.cfg=/dev/null" + "boot/grub/grub.cfg=/tmp/embedded_grub.cfg" # Find the kernel KERNEL_PATH=$(find /kernel/boot -name "vmlinuz-*" | head -1) From 20115fb3700b75eb396acb3f335ddcd5613f89e5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Dec 2025 18:37:33 +0000 Subject: [PATCH 3/4] Extract GRUB embedded config to separate file and address code review feedback Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com> --- config/grub-embedded.cfg.in | 11 +++++++++++ scripts/docker-image-create-uefi.sh | 22 +++++++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 config/grub-embedded.cfg.in diff --git a/config/grub-embedded.cfg.in b/config/grub-embedded.cfg.in new file mode 100644 index 0000000..217de37 --- /dev/null +++ b/config/grub-embedded.cfg.in @@ -0,0 +1,11 @@ +# Embedded bootstrap configuration for GRUB +# This config tells GRUB where to find the real configuration file + +search --no-floppy --set=root --label @ESP_LABEL@ +if [ -e /boot/grub/grub.cfg ]; then + configfile /boot/grub/grub.cfg +else + echo "Error: Could not find /boot/grub/grub.cfg" + echo "Press any key to enter GRUB command line..." + sleep --verbose --interruptible 99999 +fi diff --git a/scripts/docker-image-create-uefi.sh b/scripts/docker-image-create-uefi.sh index 3e33526..7afcabc 100755 --- a/scripts/docker-image-create-uefi.sh +++ b/scripts/docker-image-create-uefi.sh @@ -4,6 +4,10 @@ set -e +# Configuration +ESP_LABEL="SPARKOSEFI" +ROOT_LABEL="SparkOS" + mkdir -p /output /staging/esp /staging/root echo "=== Creating UEFI-bootable SparkOS image with GRUB ===" @@ -13,20 +17,8 @@ echo "Preparing ESP contents..." mkdir -p /staging/esp/EFI/BOOT mkdir -p /staging/esp/boot/grub -# Create minimal embedded GRUB configuration that searches for external config -cat > /tmp/embedded_grub.cfg << 'EOF' -# Embedded bootstrap configuration for GRUB -# This config tells GRUB where to find the real configuration file - -search --no-floppy --set=root --label SPARKOSEFI -if [ -e /boot/grub/grub.cfg ]; then - configfile /boot/grub/grub.cfg -else - echo "Error: Could not find /boot/grub/grub.cfg" - echo "Press any key to enter GRUB command line..." - read -fi -EOF +# Create minimal embedded GRUB configuration from template +sed "s/@ESP_LABEL@/$ESP_LABEL/g" /build/config/grub-embedded.cfg.in > /tmp/embedded_grub.cfg # Create GRUB EFI binary using grub-mkstandalone with embedded bootstrap config grub-mkstandalone \ @@ -110,7 +102,7 @@ dd if=/output/sparkos.img of=/tmp/root.img bs=512 skip=$ROOT_START count=$ROOT_S # Format ESP partition (FAT32) echo "Formatting EFI System Partition (FAT32)..." -mkfs.vfat -F 32 -n "SPARKOSEFI" /tmp/esp.img >/dev/null +mkfs.vfat -F 32 -n "$ESP_LABEL" /tmp/esp.img >/dev/null # Populate ESP using mtools (no mount needed!) echo "Populating ESP with bootloader and kernel..." From 451b23b8e05cf7b6efc36c87c4046878faaededb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Dec 2025 18:41:11 +0000 Subject: [PATCH 4/4] Use ROOT_LABEL variable consistently and add documentation Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com> --- config/grub-embedded.cfg.in | 2 ++ scripts/docker-image-create-uefi.sh | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/config/grub-embedded.cfg.in b/config/grub-embedded.cfg.in index 217de37..902e6d9 100644 --- a/config/grub-embedded.cfg.in +++ b/config/grub-embedded.cfg.in @@ -7,5 +7,7 @@ if [ -e /boot/grub/grub.cfg ]; then else echo "Error: Could not find /boot/grub/grub.cfg" echo "Press any key to enter GRUB command line..." + # Sleep for a very long time (interruptible by any key press) + # This provides an effective "wait for keypress" in GRUB sleep --verbose --interruptible 99999 fi diff --git a/scripts/docker-image-create-uefi.sh b/scripts/docker-image-create-uefi.sh index 7afcabc..a75e0a3 100755 --- a/scripts/docker-image-create-uefi.sh +++ b/scripts/docker-image-create-uefi.sh @@ -43,8 +43,8 @@ printf '%s\n' \ 'set timeout=3' \ 'set default=0' \ '' \ - 'menuentry "SparkOS (Immutable Base + Overlay)" {' \ - ' linux /boot/vmlinuz root=LABEL=SparkOS ro init=/sbin/init console=tty1 quiet' \ + "menuentry \"SparkOS (Immutable Base + Overlay)\" {" \ + " linux /boot/vmlinuz root=LABEL=$ROOT_LABEL ro init=/sbin/init console=tty1 quiet" \ '}' \ > /staging/esp/boot/grub/grub.cfg @@ -120,7 +120,7 @@ mcopy -i /tmp/esp.img /staging/esp/boot/grub/grub.cfg ::/boot/grub/ # Format root partition (ext4) with directory contents (no mount needed!) echo "Formatting root partition (ext4) and populating..." -mke2fs -t ext4 -L "SparkOS" -d /staging/root /tmp/root.img >/dev/null 2>&1 +mke2fs -t ext4 -L "$ROOT_LABEL" -d /staging/root /tmp/root.img >/dev/null 2>&1 # Write partitions back to image echo "Writing partitions to image..."