From ca0e9f7c72ddb8aa3418acb954d35d593f01e2df Mon Sep 17 00:00:00 2001 From: nmemmert <67961292+nmemmert@users.noreply.github.com> Date: Mon, 31 Aug 2026 11:34:08 -0400 Subject: [PATCH] Bundle archiso initcpio hook directly in repo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Current archiso package does not install initcpio hook files (confirmed: find /usr -path */initcpio/hooks/archiso returns nothing). Write the hook and its mkinitcpio install script directly into the profile airootfs so COPY carries them into the image without any package dependency. Hook finds ISO by archisosearchuuid= kernel param, waits up to 30s for the device to appear via blkid, mounts iso9660→squashfs→overlay onto /new_root. mkinitcpio detects /new_root is already mounted and succeeds. Co-Authored-By: Claude Sonnet 4.6 --- iso/docker/Dockerfile | 12 ---- .../airootfs/usr/lib/initcpio/hooks/archiso | 55 +++++++++++++++++++ .../airootfs/usr/lib/initcpio/install/archiso | 19 +++++++ 3 files changed, 74 insertions(+), 12 deletions(-) create mode 100644 iso/profile/airootfs/usr/lib/initcpio/hooks/archiso create mode 100644 iso/profile/airootfs/usr/lib/initcpio/install/archiso diff --git a/iso/docker/Dockerfile b/iso/docker/Dockerfile index a4a48b6..01650c0 100644 --- a/iso/docker/Dockerfile +++ b/iso/docker/Dockerfile @@ -38,18 +38,6 @@ COPY . /build/orionos # Bootstrap boot loader configs from the installed archiso releng profile. # Copy only the .c32 binary modules — our repo provides syslinux.cfg. # efiboot/ is needed for systemd-boot UEFI; fall back to a minimal loader.conf. -# Copy archiso initcpio hook files directly into airootfs so mkinitcpio -# finds them even if the package-based install path differs at build time. -# Use find to locate the files regardless of exact path in current archiso version. -RUN mkdir -p /build/orionos/iso/profile/airootfs/usr/lib/initcpio/hooks \ - /build/orionos/iso/profile/airootfs/usr/lib/initcpio/install && \ - HOOK="$(find /usr -path "*/initcpio/hooks/archiso" 2>/dev/null | head -1)" && \ - INST="$(find /usr -path "*/initcpio/install/archiso" 2>/dev/null | head -1)" && \ - echo "Hook: ${HOOK:-NOT FOUND}" && echo "Install: ${INST:-NOT FOUND}" && \ - [ -n "$HOOK" ] && cp "$HOOK" /build/orionos/iso/profile/airootfs/usr/lib/initcpio/hooks/archiso || \ - (echo "ERROR: archiso initcpio hook not found in any path" && exit 1) && \ - [ -n "$INST" ] && cp "$INST" /build/orionos/iso/profile/airootfs/usr/lib/initcpio/install/archiso || \ - (echo "ERROR: archiso initcpio install not found in any path" && exit 1) RUN mkdir -p /build/orionos/iso/profile/syslinux && \ cp /usr/share/archiso/configs/releng/syslinux/*.c32 \ diff --git a/iso/profile/airootfs/usr/lib/initcpio/hooks/archiso b/iso/profile/airootfs/usr/lib/initcpio/hooks/archiso new file mode 100644 index 0000000..10e77c0 --- /dev/null +++ b/iso/profile/airootfs/usr/lib/initcpio/hooks/archiso @@ -0,0 +1,55 @@ +#!/usr/bin/ash +# Live-boot hook: find ISO by UUID, mount squashfs, set up overlay on /new_root. + +run_latehook() { + local _uuid _basedir _dev _img + + _uuid="$(getarg archisosearchuuid=)" + _basedir="$(getarg archisobasedir=)" + : "${_basedir:=arch}" + + if [ -z "${_uuid}" ]; then + echo "archiso: archisosearchuuid not set in kernel cmdline" + return 1 + fi + + # Wait up to 30 s for a block device with the ISO UUID to appear + local _waited=0 + while [ "${_waited}" -lt 30 ]; do + _dev="$(blkid -l -o device -t UUID="${_uuid}" 2>/dev/null)" + [ -n "${_dev}" ] && break + sleep 1 + _waited=$(( _waited + 1 )) + done + + if [ -z "${_dev}" ]; then + echo "archiso: could not find boot medium with UUID=${_uuid}" + return 1 + fi + + echo "archiso: found boot medium ${_dev}" + + mkdir -p /run/archiso/bootmnt + mount -r "${_dev}" /run/archiso/bootmnt || { echo "archiso: mount bootmnt failed"; return 1; } + + _img="/run/archiso/bootmnt/${_basedir}/x86_64/airootfs.sfs" + if [ ! -e "${_img}" ]; then + echo "archiso: squashfs not found at ${_img}" + return 1 + fi + + mkdir -p /run/archiso/airootfs + mount -r -t squashfs "${_img}" /run/archiso/airootfs || { echo "archiso: squashfs mount failed"; return 1; } + + # RAM-backed writable overlay layer + mkdir -p /run/archiso/overlay + mount -t tmpfs tmpfs -o mode=0755 /run/archiso/overlay + mkdir -p /run/archiso/overlay/upper /run/archiso/overlay/work + + mkdir -p /new_root + mount -t overlay overlay \ + -o lowerdir=/run/archiso/airootfs,upperdir=/run/archiso/overlay/upper,workdir=/run/archiso/overlay/work \ + /new_root || { echo "archiso: overlay mount failed"; return 1; } + + echo "archiso: live root mounted on /new_root" +} diff --git a/iso/profile/airootfs/usr/lib/initcpio/install/archiso b/iso/profile/airootfs/usr/lib/initcpio/install/archiso new file mode 100644 index 0000000..b10285d --- /dev/null +++ b/iso/profile/airootfs/usr/lib/initcpio/install/archiso @@ -0,0 +1,19 @@ +#!/bin/bash +# mkinitcpio install script for the archiso live-boot hook. + +build() { + add_runscript + add_binary blkid + add_binary mount + add_binary sleep + add_module squashfs + add_module overlay + add_module isofs +} + +help() { + cat <