fix installer

This commit is contained in:
Jonas Leder 2026-08-06 22:07:33 +02:00
commit b8fd538073

View file

@ -184,21 +184,39 @@ MUSL_LOADER="$TOOLS_LIB/ld-musl-x86_64.so.1"
GRUB_MKIMAGE="$STAGE/tools/grub-mkimage"
GRUB_BIOS_SETUP="$STAGE/tools/grub-bios-setup"
GRUB_EDITENV="$STAGE/tools/grub-editenv"
GRUB_MODDIR="$STAGE/tools/grub/i386-pc"
GRUB_MODDIR_SRC="$STAGE/tools/grub/i386-pc"
GRUB_EMBED_CFG="$STAGE/tools/embed.cfg"
GRUB_MODULES_FILE="$STAGE/tools/grub-modules.txt"
for f in "$MUSL_LOADER" "$GRUB_MKIMAGE" "$GRUB_BIOS_SETUP" "$GRUB_EDITENV" "$GRUB_EMBED_CFG" "$GRUB_MODULES_FILE"; do
[ -f "$f" ] || die "bundled installer tool $f missing from release tarball (rebuild with a current build-image.sh)"
done
[ -d "$GRUB_MODDIR" ] || die "bundled GRUB i386-pc module dir missing from release tarball"
[ -d "$GRUB_MODDIR_SRC" ] || die "bundled GRUB i386-pc module dir missing from release tarball"
chmod +x "$MUSL_LOADER" "$GRUB_MKIMAGE" "$GRUB_BIOS_SETUP" "$GRUB_EDITENV"
run_tool() {
"$MUSL_LOADER" --library-path "$TOOLS_LIB" "$@"
}
# grub-bios-setup insists on resolving --directory (and --core-image,
# which it always joins onto --directory itself, even when given as an
# absolute path -- see the core.img naming below) down to a real
# underlying block device, to work out how to embed core.img -- staging
# them under $STAGE (tmpfs, /tmp) fails with "failed to get canonical
# path of `tmpfs'" since tmpfs has no backing block device. Installing
# the module dir onto the just-formatted, really-mounted ALPINEDATA
# partition first (the same location grub.cfg's own $prefix points at,
# so this also happens to match a normal grub-install layout) sidesteps
# that entirely.
GRUB_MODDIR="$DATA_MNT/boot/grub/i386-pc"
mkdir -p "$GRUB_MODDIR"
cp -a "$GRUB_MODDIR_SRC/." "$GRUB_MODDIR/"
log "building GRUB BIOS core image (prefix on the data partition's /boot/grub)"
CORE_IMG="$STAGE/core.img"
# core.img has to actually live inside $GRUB_MODDIR, not just be
# referenced by absolute path -- grub-bios-setup joins --directory and
# --core-image itself regardless.
CORE_IMG_NAME="core.img"
CORE_IMG="$GRUB_MODDIR/$CORE_IMG_NAME"
GRUB_MODULES=$(cat "$GRUB_MODULES_FILE")
# shellcheck disable=SC2086
run_tool "$GRUB_MKIMAGE" \
@ -212,7 +230,7 @@ run_tool "$GRUB_MKIMAGE" \
log "installing GRUB to the MBR + post-MBR gap (BIOS boot)"
run_tool "$GRUB_BIOS_SETUP" \
--directory="$GRUB_MODDIR" \
--core-image="$CORE_IMG" \
--core-image="$CORE_IMG_NAME" \
--skip-fs-probe \
"$DEVICE"