From 80f113cc4c24bd05ad6df20a4e4d2f42ca885ace Mon Sep 17 00:00:00 2001 From: m-sz Date: Mon, 30 Dec 2024 15:55:58 +0100 Subject: [PATCH 1/2] Improve cross-compatibility of used dependencies Some of the tools used during the image creation process were executed based on their absolute path (eg. /sbin), which might not be the case. Changed them to just use the executable's name. Changed scripts shebang to use the more generic `#!/usr/bin/env bash` to accomodate different OSes. --- Makefile | 1 + create-live-image.sh | 14 +++++++------- get-merged-rootfs.sh | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index e56bef0..eb297e0 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +.PHONY: all clean LOCAL_DIR ?= $(shell readlink -m $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) WORK_DIR ?= $(LOCAL_DIR)/work diff --git a/create-live-image.sh b/create-live-image.sh index 5609692..72d91ba 100755 --- a/create-live-image.sh +++ b/create-live-image.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eux -o pipefail @@ -33,7 +33,7 @@ trap "cleanup ${MNTDIR}" 0 1 2 3 6 15 truncate -s 16G "${IMG}" # have static UUIDs to make partition table reproducible -/usr/sbin/sfdisk "$IMG" < Date: Mon, 3 Feb 2025 10:17:52 +0100 Subject: [PATCH 2/2] Fix the ordering of grub-install Puts grub-install of the create-live-image.sh script before the system partitions are unmounted. Previously, the installation step happened when the work/mnt directory had the config partition mounted, instead of the root filesystem. Adds --root-directory flag to grub-install, making GRUB scan only the loopback device's partition. Previously, with this option missing, host system was scanned and the LiveUSB would not work if built on one system and booted on a different one. Both of those changes make it possible to actually boot the image, tested using QEMU. --- create-live-image.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/create-live-image.sh b/create-live-image.sh index 72d91ba..d270b4f 100755 --- a/create-live-image.sh +++ b/create-live-image.sh @@ -94,6 +94,13 @@ cp "${WORKDIR}/rootfs/usr/lib/shim/shimx64.efi.signed.latest" \ mkdir -p "${MNTDIR}/.disk" echo "Golem Live USB" > "${MNTDIR}/.disk/info" +# Generate BIOS bootable GRUB image +grub-install \ + --target=i386-pc \ + --root-directory="${MNTDIR}" \ + --modules="part_gpt part_msdos fat iso9660" \ + "${IMG_LOOP}" + # Umount root filesystem umount "${MNTDIR}/boot/efi" umount "${MNTDIR}" @@ -106,8 +113,3 @@ cat > "${MNTDIR}/golemwz-example.toml" << EOF #glm_per_hour = "0.25" EOF -# Generate BIOS bootable GRUB image -grub-install \ - --target=i386-pc \ - --modules="part_gpt part_msdos fat iso9660" \ - "${IMG_LOOP}"