594167
From bc1c914ebdec526151964c1aa3c2aeea0d4e2680 Mon Sep 17 00:00:00 2001
aa0848
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczleweli@nabijaczleweli.xyz>
aa0848
Date: Fri, 17 Dec 2021 19:51:12 +0100
aa0848
Subject: [PATCH] kernel-install: 90-loaderentry: error out on nonexistent
aa0848
 initrds instead of swallowing them quietly
aa0848
aa0848
(cherry picked from commit 742561efbe938c45936f2e4f5d81b3ff6b352882)
aa0848
aa0848
Related: #2065061
aa0848
---
aa0848
 src/kernel-install/90-loaderentry.install | 12 +++++++-----
aa0848
 1 file changed, 7 insertions(+), 5 deletions(-)
aa0848
aa0848
diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install
aa0848
index 35324e69a9..e588e72bf9 100644
aa0848
--- a/src/kernel-install/90-loaderentry.install
aa0848
+++ b/src/kernel-install/90-loaderentry.install
aa0848
@@ -93,7 +93,10 @@ install -g root -o root -m 0644 "$KERNEL_IMAGE" "$ENTRY_DIR_ABS/linux" || {
aa0848
 
aa0848
 shift "$INITRD_OPTIONS_SHIFT"
aa0848
 for initrd; do
aa0848
-    [ -f "$initrd" ] || continue
aa0848
+    [ -f "$initrd" ] || {
aa0848
+        echo "Initrd '$initrd' not a file." >&2
aa0848
+        exit 1
aa0848
+    }
aa0848
 
aa0848
     initrd_basename="${initrd##*/}"
aa0848
     [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Installing $ENTRY_DIR_ABS/$initrd_basename"
aa0848
@@ -108,9 +111,6 @@ mkdir -p "${LOADER_ENTRY%/*}" || {
aa0848
     exit 1
aa0848
 }
aa0848
 
aa0848
-# Try "initrd", generated by dracut in its kernel-install hook, if no initrds were supplied
aa0848
-[ $# -eq 0 ] && set -- "initrd"
aa0848
-
aa0848
 [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Creating $LOADER_ENTRY"
aa0848
 {
aa0848
     echo "title      $PRETTY_NAME"
aa0848
@@ -119,8 +119,10 @@ mkdir -p "${LOADER_ENTRY%/*}" || {
aa0848
     echo "options    $BOOT_OPTIONS"
aa0848
     echo "linux      $ENTRY_DIR/linux"
aa0848
     for initrd; do
aa0848
-        [ -f "$ENTRY_DIR_ABS/${initrd##*/}" ] && echo "initrd     $ENTRY_DIR/${initrd##*/}"
aa0848
+        echo "initrd     $ENTRY_DIR/${initrd##*/}"
aa0848
     done
aa0848
+    # Try "initrd", generated by dracut in its kernel-install hook, if no initrds were supplied
aa0848
+    [ $# -eq 0 ] && [ -f "$ENTRY_DIR_ABS/initrd" ] && echo "initrd     $ENTRY_DIR/initrd"
aa0848
     :
aa0848
 } >"$LOADER_ENTRY" || {
aa0848
     echo "Could not create loader entry '$LOADER_ENTRY'." >&2