richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
Blob Blame History Raw
From 6b47726b54a3bf71e0f7ba35bbfe915c7a64a7d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczleweli@nabijaczleweli.xyz>
Date: Fri, 17 Dec 2021 19:51:12 +0100
Subject: [PATCH] kernel-install: 90-loaderentry: error out on nonexistent
 initrds instead of swallowing them quietly

(cherry picked from commit 742561efbe938c45936f2e4f5d81b3ff6b352882)

Related: #2065061
---
 src/kernel-install/90-loaderentry.install | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install
index 35324e69a9..e588e72bf9 100644
--- a/src/kernel-install/90-loaderentry.install
+++ b/src/kernel-install/90-loaderentry.install
@@ -93,7 +93,10 @@ install -g root -o root -m 0644 "$KERNEL_IMAGE" "$ENTRY_DIR_ABS/linux" || {
 
 shift "$INITRD_OPTIONS_SHIFT"
 for initrd; do
-    [ -f "$initrd" ] || continue
+    [ -f "$initrd" ] || {
+        echo "Initrd '$initrd' not a file." >&2
+        exit 1
+    }
 
     initrd_basename="${initrd##*/}"
     [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Installing $ENTRY_DIR_ABS/$initrd_basename"
@@ -108,9 +111,6 @@ mkdir -p "${LOADER_ENTRY%/*}" || {
     exit 1
 }
 
-# Try "initrd", generated by dracut in its kernel-install hook, if no initrds were supplied
-[ $# -eq 0 ] && set -- "initrd"
-
 [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Creating $LOADER_ENTRY"
 {
     echo "title      $PRETTY_NAME"
@@ -119,8 +119,10 @@ mkdir -p "${LOADER_ENTRY%/*}" || {
     echo "options    $BOOT_OPTIONS"
     echo "linux      $ENTRY_DIR/linux"
     for initrd; do
-        [ -f "$ENTRY_DIR_ABS/${initrd##*/}" ] && echo "initrd     $ENTRY_DIR/${initrd##*/}"
+        echo "initrd     $ENTRY_DIR/${initrd##*/}"
     done
+    # Try "initrd", generated by dracut in its kernel-install hook, if no initrds were supplied
+    [ $# -eq 0 ] && [ -f "$ENTRY_DIR_ABS/initrd" ] && echo "initrd     $ENTRY_DIR/initrd"
     :
 } >"$LOADER_ENTRY" || {
     echo "Could not create loader entry '$LOADER_ENTRY'." >&2