Blame 0001-feat-kernel-install-do-nothing-when-KERNEL_INSTALL_I.patch

ff27f8
From f86d5ff72868e9df7d255e3c5e938a9e339f09fa Mon Sep 17 00:00:00 2001
ff27f8
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
ff27f8
Date: Tue, 18 Jan 2022 18:08:42 +0100
ff27f8
Subject: [PATCH 01/10] feat(kernel-install): do nothing when
ff27f8
 $KERNEL_INSTALL_INITRD_GENERATOR says so
ff27f8
ff27f8
dracut may be installed without being actually used. This is very common in
ff27f8
binary distros where a package may be pulled in through dependencies, even
ff27f8
though the user does not need it in a particular setup. KERNEL_INSTALL_INITRD_GENERATOR
ff27f8
is being added in systemd's kernel-install to select which of the possibly many
ff27f8
initrd generation mechanisms will be used.
ff27f8
ff27f8
For backwards compat, if it not set, continue as before. But if set to
ff27f8
something else, skip our kernel-install plugins.
ff27f8
ff27f8
(Cherry-picked commit f47bcdd7342ca0d46b889e712a1c7446e18434bc from PR#1825)
ff27f8
---
ff27f8
 install.d/50-dracut.install        | 31 ++++++------------------------
ff27f8
 install.d/51-dracut-rescue.install | 12 +++++++++---
ff27f8
 2 files changed, 15 insertions(+), 28 deletions(-)
ff27f8
ff27f8
diff --git a/install.d/50-dracut.install b/install.d/50-dracut.install
ff27f8
index 441414ac..efb184cd 100755
ff27f8
--- a/install.d/50-dracut.install
ff27f8
+++ b/install.d/50-dracut.install
ff27f8
@@ -6,38 +6,19 @@ BOOT_DIR_ABS="$3"
ff27f8
 KERNEL_IMAGE="$4"
ff27f8
 
ff27f8
 # If KERNEL_INSTALL_MACHINE_ID is defined but empty, BOOT_DIR_ABS is a fake directory.
ff27f8
-# So, let's skip to create initrd.
ff27f8
+# In this case, do not create the initrd.
ff27f8
 if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
ff27f8
     exit 0
ff27f8
 fi
ff27f8
 
ff27f8
-# Do not attempt to create initramfs if the supplied image is already a UKI
ff27f8
-if [[ "$KERNEL_INSTALL_IMAGE_TYPE" = "uki" ]]; then
ff27f8
+# Skip this plugin if we're using a different generator. If nothing is specified,
ff27f8
+# assume we're wanted since we're installed.
ff27f8
+if [ "${KERNEL_INSTALL_INITRD_GENERATOR:-dracut}" != "dracut" ]; then
ff27f8
     exit 0
ff27f8
 fi
ff27f8
 
ff27f8
-# Mismatching the install layout and the --uefi/--no-uefi opts just creates a mess.
ff27f8
-if [[ $KERNEL_INSTALL_LAYOUT == "uki" && -n $KERNEL_INSTALL_STAGING_AREA ]]; then
ff27f8
-    BOOT_DIR_ABS="$KERNEL_INSTALL_STAGING_AREA"
ff27f8
-    if [[ -z $KERNEL_INSTALL_UKI_GENERATOR || $KERNEL_INSTALL_UKI_GENERATOR == "dracut" ]]; then
ff27f8
-        # No uki generator preference set or we have been chosen
ff27f8
-        IMAGE="uki.efi"
ff27f8
-        UEFI_OPTS="--uefi"
ff27f8
-    elif [[ -z $KERNEL_INSTALL_INITRD_GENERATOR || $KERNEL_INSTALL_INITRD_GENERATOR == "dracut" ]]; then
ff27f8
-        # We aren't the uki generator, but we have been requested to make the initrd
ff27f8
-        IMAGE="initrd"
ff27f8
-        UEFI_OPTS="--no-uefi"
ff27f8
-    else
ff27f8
-        exit 0
ff27f8
-    fi
ff27f8
-elif [[ $KERNEL_INSTALL_LAYOUT == "bls" && -n $KERNEL_INSTALL_STAGING_AREA ]]; then
ff27f8
-    BOOT_DIR_ABS="$KERNEL_INSTALL_STAGING_AREA"
ff27f8
-    if [[ -z $KERNEL_INSTALL_INITRD_GENERATOR || $KERNEL_INSTALL_INITRD_GENERATOR == "dracut" ]]; then
ff27f8
-        IMAGE="initrd"
ff27f8
-        UEFI_OPTS="--no-uefi"
ff27f8
-    else
ff27f8
-        exit 0
ff27f8
-    fi
ff27f8
+if [[ -d "$BOOT_DIR_ABS" ]]; then
ff27f8
+    INITRD="initrd"
ff27f8
 else
ff27f8
     # No layout information, use users --uefi/--no-uefi preference
ff27f8
     UEFI_OPTS=""
ff27f8
diff --git a/install.d/51-dracut-rescue.install b/install.d/51-dracut-rescue.install
ff27f8
index aa0ccdc5..be4172b5 100755
ff27f8
--- a/install.d/51-dracut-rescue.install
ff27f8
+++ b/install.d/51-dracut-rescue.install
ff27f8
@@ -7,9 +7,15 @@ KERNEL_VERSION="$2"
ff27f8
 BOOT_DIR_ABS="${3%/*}/0-rescue"
ff27f8
 KERNEL_IMAGE="$4"
ff27f8
 
ff27f8
-dropindirs_sort() {
ff27f8
-    suffix=$1
ff27f8
-    shift
ff27f8
+# Skip this plugin if we're using a different generator. If nothing is specified,
ff27f8
+# assume we're wanted since we're installed.
ff27f8
+if [ "${KERNEL_INSTALL_INITRD_GENERATOR:-dracut}" != "dracut" ]; then
ff27f8
+    exit 0
ff27f8
+fi
ff27f8
+
ff27f8
+dropindirs_sort()
ff27f8
+{
ff27f8
+    suffix=$1; shift
ff27f8
     args=("$@")
ff27f8
     files=$(
ff27f8
         while (($# > 0)); do
ff27f8
-- 
ff27f8
2.42.0
ff27f8