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"