This replaces a workaround with a better one. Instead of tricking 50-dracut.install with an empty inird file we instruct kernel-install to simply skip this plugin.

This way we don't end up with a bunch of confusing empty initrd files in /boot. End result is the same.

I've got an upstream PR open to fix the underlying issue (i.e make 50-dracut.install work properly with uefi=yes and layout=uki): https://github.com/dracutdevs/dracut/pull/2405


From c2d6ecb074d25c70677fa9c371801a0002c9a216 Mon Sep 17 00:00:00 2001
From: Andrew Ammerlaan <andrewammerl...@gentoo.org>
Date: Fri, 16 Jun 2023 22:51:00 +0200
Subject: [PATCH] dist-kernel-utils.eclass: skip initrd installation when using
 uki

Gets rid of a hack that prevents 50-dracut.install from regenerating the initrd when calling kernel-install. Instead instruct kernel-install to simply not run
this plugin.

Signed-off-by: Andrew Ammerlaan <andrewammerl...@gentoo.org>
---
 eclass/dist-kernel-utils.eclass | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass
index c6892c2f01278..e371e035c8565 100644
--- a/eclass/dist-kernel-utils.eclass
+++ b/eclass/dist-kernel-utils.eclass
@@ -106,10 +106,21 @@ dist-kernel_install_kernel() {
                # install the combined executable in place of kernel
                image=${initrd}.efi
                mv "${initrd}" "${image}" || die
-               # put an empty file in place of initrd.  installing a duplicate
-               # file would waste disk space, and removing it entirely provokes
-               # kernel-install to regenerate it via dracut.
-               > "${initrd}"
+               # We moved the generated initrd, prevent dracut from running 
again
+               local plugins=()
+               for file in "${EROOT}"/usr/lib/kernel/install.d/*; do
+                       if [[ ${file} != */50-dracut.install && \
+                               ${file} != */51-dracut-rescue.install && \
+                               ${file} == *.install ]]; then
+                                       plugins+=( "${file}" )
+                       fi
+               done
+               for file in "${EROOT}"/etc/kernel/install.d/*; do
+                       if [[ ${file} == *.install ]]; then
+                                       plugins+=( "${file}" )
+                       fi
+               done
+               export KERNEL_INSTALL_PLUGINS="${KERNEL_INSTALL_PLUGINS} 
${plugins[@]}"
        fi

        ebegin "Installing the kernel via installkernel"


Reply via email to