From 1b2c042ed3e70fdf5ca4886c408a54d82c9d5c4e Mon Sep 17 00:00:00 2001 From: m2 <69128853+m2Giles@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:15:04 -0400 Subject: [PATCH] feat: build initramfs for surface, asus and nvidia (#258) * feat: build initramfs for surface, asus and nvidia * fix: add cliwrap for initramfs gereration * fix: missing && and don't cliwrap twice --------- Co-authored-by: Mark Mihalik --- Containerfile | 4 ++++ build-initramfs.sh | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100755 build-initramfs.sh diff --git a/Containerfile b/Containerfile index cc133884..6cb6a1e5 100644 --- a/Containerfile +++ b/Containerfile @@ -18,6 +18,9 @@ COPY ${KERNEL_FLAVOR}/ /tmp/ RUN mkdir -p /var/lib/alternatives && \ IMAGE_FLAVOR=main /tmp/image-info.sh && \ /tmp/install.sh && \ + if [ "${KERNEL_FLAVOR}" != "main" ]; then \ + /tmp/build-initramfs.sh \ + ; fi && \ mv /var/lib/alternatives /staged-alternatives && \ rm -rf /tmp/* /var/* && \ ostree container commit && \ @@ -41,6 +44,7 @@ COPY *.sh /tmp/ RUN mkdir -p /var/lib/alternatives && \ IMAGE_FLAVOR=nvidia /tmp/image-info.sh && \ /tmp/nvidia-install.sh && \ + /tmp/build-initramfs.sh && \ mv /var/lib/alternatives /staged-alternatives && \ rm -rf /tmp/* /var/* && \ ostree container commit && \ diff --git a/build-initramfs.sh b/build-initramfs.sh new file mode 100755 index 00000000..ec2c4d36 --- /dev/null +++ b/build-initramfs.sh @@ -0,0 +1,20 @@ +#!/usr/bin/bash + +set -oue pipefail + + +if [[ "${KERNEL_FLAVOR}" == "surface" ]]; then + KERNEL_SUFFIX="surface" +else + KERNEL_SUFFIX="" +fi + +if [ ! -f /usr/libexec/rpm-ostree/wrapped/dracut ]; then + rpm-ostree cliwrap install-to-root / +fi + +QUALIFIED_KERNEL="$(rpm -qa | grep -P 'kernel-(|'"$KERNEL_SUFFIX"'-)(\d+\.\d+\.\d+)' | sed -E 's/kernel-(|'"$KERNEL_SUFFIX"'-)//')" + +/usr/libexec/rpm-ostree/wrapped/dracut --no-hostonly --kver "$QUALIFIED_KERNEL" --reproducible -v --add ostree -f "/lib/modules/$QUALIFIED_KERNEL/initramfs.img" + +chmod 0600 "/lib/modules/$QUALIFIED_KERNEL/initramfs.img"