From ec3ccd4eec718512c9d31b36eedf270d479a724e Mon Sep 17 00:00:00 2001 From: Pavel Valena Date: Feb 20 2023 22:39:19 +0000 Subject: Skip creating initrd when initrd already provided, or different generator is configured. https://github.com/dracutdevs/dracut/pull/1825/ --- diff --git a/1825-Skip-creating-initrd-when-initrd-is-provided.patch b/1825-Skip-creating-initrd-when-initrd-is-provided.patch new file mode 100644 index 0000000..085ae7b --- /dev/null +++ b/1825-Skip-creating-initrd-when-initrd-is-provided.patch @@ -0,0 +1,93 @@ +From f47bcdd7342ca0d46b889e712a1c7446e18434bc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 18 Jan 2022 18:08:42 +0100 +Subject: [PATCH 1/2] feat(kernel-install): do nothing when + $KERNEL_INSTALL_INITRD_GENERATOR says so + +dracut may be installed without being actually used. This is very common in +binary distros where a package may be pulled in through dependencies, even +though the user does not need it in a particular setup. KERNEL_INSTALL_INITRD_GENERATOR +is being added in systemd's kernel-install to select which of the possibly many +initrd generation mechanisms will be used. + +For backwards compat, if it not set, continue as before. But if set to +something else, skip our kernel-install plugins. +--- + install.d/50-dracut.install | 8 +++++++- + install.d/51-dracut-rescue.install | 5 +++++ + 2 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/install.d/50-dracut.install b/install.d/50-dracut.install +index 70632ec7f..552fd0338 100755 +--- a/install.d/50-dracut.install ++++ b/install.d/50-dracut.install +@@ -6,11 +6,17 @@ BOOT_DIR_ABS="$3" + KERNEL_IMAGE="$4" + + # If KERNEL_INSTALL_MACHINE_ID is defined but empty, BOOT_DIR_ABS is a fake directory. +-# So, let's skip to create initrd. ++# In this case, do not create the initrd. + if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then + exit 0 + fi + ++# Skip this plugin if we're using a different generator. If nothing is specified, ++# assume we're wanted since we're installed. ++if [ "${KERNEL_INSTALL_INITRD_GENERATOR:-dracut}" != "dracut" ]; then ++ exit 0 ++fi ++ + if [[ -d "$BOOT_DIR_ABS" ]]; then + INITRD="initrd" + else +diff --git a/install.d/51-dracut-rescue.install b/install.d/51-dracut-rescue.install +index 8bf9a6d95..93483931a 100755 +--- a/install.d/51-dracut-rescue.install ++++ b/install.d/51-dracut-rescue.install +@@ -7,6 +7,11 @@ KERNEL_VERSION="$2" + BOOT_DIR_ABS="${3%/*}/0-rescue" + KERNEL_IMAGE="$4" + ++# Skip this plugin if we're using a different generator. If nothing is specified, ++# assume we're wanted since we're installed. ++if [ "${KERNEL_INSTALL_INITRD_GENERATOR:-dracut}" != "dracut" ]; then ++ exit 0 ++fi + + dropindirs_sort() + { + +From 0b72cf5c4eca0e0db76e3e210cfdc48e6b49bb74 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 18 Jan 2022 18:58:58 +0100 +Subject: [PATCH 2/2] fix(kernel-install): do not generate an initrd when one + was specified + +According to the synopsis, kernel-install can be called with an +already-prepared initrd. In that case, no initrd should be generated by dracut. +--- + install.d/50-dracut.install | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/install.d/50-dracut.install b/install.d/50-dracut.install +index 552fd0338..836251e92 100755 +--- a/install.d/50-dracut.install ++++ b/install.d/50-dracut.install +@@ -4,6 +4,7 @@ COMMAND="$1" + KERNEL_VERSION="$2" + BOOT_DIR_ABS="$3" + KERNEL_IMAGE="$4" ++INITRD_OPTIONS_SHIFT=4 + + # If KERNEL_INSTALL_MACHINE_ID is defined but empty, BOOT_DIR_ABS is a fake directory. + # In this case, do not create the initrd. +@@ -27,6 +28,9 @@ fi + ret=0 + case "$COMMAND" in + add) ++ # If the initrd was provided on the kernel command line, we shouldn't generate our own. ++ [ "$#" -gt "$INITRD_OPTIONS_SHIFT" ] && exit 0 ++ + INITRD_IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/initrd + if [[ -f ${INITRD_IMAGE_PREGENERATED} ]]; then + # we found an initrd at the same place as the kernel diff --git a/dracut.spec b/dracut.spec index 735fca8..79d7836 100644 --- a/dracut.spec +++ b/dracut.spec @@ -31,6 +31,11 @@ Source1: https://www.gnu.org/licenses/lgpl-2.1.txt # https://github.com/dracutdevs/dracut/pull/1521 Patch1: 1521-Never-enable-the-bluetooth-module-by-default.patch +# Skip creating initrd when initrd already provided, +# or different generator is configured +# https://github.com/dracutdevs/dracut/pull/1825/ +Patch2: 1825-Skip-creating-initrd-when-initrd-is-provided.patch + BuildRequires: bash BuildRequires: git-core BuildRequires: pkgconfig(libkmod) >= 23 @@ -439,6 +444,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/ %changelog * Mon Feb 13 2023 Pavel Valena - 059-1 - Update to 059 +- feat(dracut.sh): option to skip creating initrd * Thu Jan 19 2023 Fedora Release Engineering - 057-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild