Blame 0007-fix-kernel-install-do-not-generate-an-initrd-when-on.patch

ff27f8
From ee0c17d24940f08a41179edce58f688f807d1d75 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:58:58 +0100
ff27f8
Subject: [PATCH 07/10] fix(kernel-install): do not generate an initrd when one
ff27f8
 was specified
ff27f8
ff27f8
According to the synopsis, kernel-install can be called with an
ff27f8
already-prepared initrd. In that case, no initrd should be generated by dracut.
ff27f8
ff27f8
(Cherry-picked commit 0b72cf5c4eca0e0db76e3e210cfdc48e6b49bb74 from PR#1825)
ff27f8
---
ff27f8
 install.d/50-dracut.install | 4 ++++
ff27f8
 1 file changed, 4 insertions(+)
ff27f8
ff27f8
diff --git a/install.d/50-dracut.install b/install.d/50-dracut.install
ff27f8
index efb184cd..3907e303 100755
ff27f8
--- a/install.d/50-dracut.install
ff27f8
+++ b/install.d/50-dracut.install
ff27f8
@@ -4,6 +4,7 @@ COMMAND="$1"
ff27f8
 KERNEL_VERSION="$2"
ff27f8
 BOOT_DIR_ABS="$3"
ff27f8
 KERNEL_IMAGE="$4"
ff27f8
+INITRD_OPTIONS_SHIFT=4
ff27f8
 
ff27f8
 # If KERNEL_INSTALL_MACHINE_ID is defined but empty, BOOT_DIR_ABS is a fake directory.
ff27f8
 # In this case, do not create the initrd.
ff27f8
@@ -34,6 +35,9 @@ ret=0
ff27f8
 
ff27f8
 case "$COMMAND" in
ff27f8
     add)
ff27f8
+        # If the initrd was provided on the kernel command line, we shouldn't generate our own.
ff27f8
+        [ "$#" -gt "$INITRD_OPTIONS_SHIFT" ] && exit 0
ff27f8
+
ff27f8
         if [[ $IMAGE == "uki.efi" ]]; then
ff27f8
             IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/uki.efi
ff27f8
         else
ff27f8
-- 
ff27f8
2.42.0
ff27f8