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] 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..."