ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
8d419f
From 7e5ff353f8b35352f6c36233841754154b4f453b Mon Sep 17 00:00:00 2001
8d419f
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
8d419f
Date: Wed, 19 Jan 2022 12:15:16 +0100
8d419f
Subject: [PATCH] kernel-install: prefix errors with "Error:", exit immediately
8d419f
MIME-Version: 1.0
8d419f
Content-Type: text/plain; charset=UTF-8
8d419f
Content-Transfer-Encoding: 8bit
8d419f
8d419f
kernel-install would continue after errors… We don't want this, as it
8d419f
makes the results totally unpredicatable. If we didn't install the kernel
8d419f
or didn't do some important part of the setup, let's just return an error
8d419f
and let the user deal with it.
8d419f
8d419f
When looking at output, the error was often hard to distinguish, esp.
8d419f
with -v. Add "Error:" everywhere to make the output easier to parse.
8d419f
8d419f
(cherry picked from commit 680cec6b4ddb356d7dd087b197718712cb5c1662)
8d419f
8d419f
Related: #2065061
8d419f
---
8d419f
 src/kernel-install/90-loaderentry.install | 10 +++++-----
8d419f
 src/kernel-install/kernel-install         | 12 ++++++------
8d419f
 2 files changed, 11 insertions(+), 11 deletions(-)
8d419f
8d419f
diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install
8d419f
index 7b768457c1..6a396910cb 100644
8d419f
--- a/src/kernel-install/90-loaderentry.install
8d419f
+++ b/src/kernel-install/90-loaderentry.install
8d419f
@@ -83,27 +83,27 @@ if ! [ -d "$ENTRY_DIR_ABS" ]; then
8d419f
 fi
8d419f
 
8d419f
 install -g root -o root -m 0644 "$KERNEL_IMAGE" "$ENTRY_DIR_ABS/linux" || {
8d419f
-    echo "Could not copy '$KERNEL_IMAGE' to '$ENTRY_DIR_ABS/linux'." >&2
8d419f
+    echo "Error: could not copy '$KERNEL_IMAGE' to '$ENTRY_DIR_ABS/linux'." >&2
8d419f
     exit 1
8d419f
 }
8d419f
 
8d419f
 shift "$INITRD_OPTIONS_SHIFT"
8d419f
 for initrd; do
8d419f
     [ -f "$initrd" ] || {
8d419f
-        echo "Initrd '$initrd' not a file." >&2
8d419f
+        echo "Error: initrd '$initrd' not a file." >&2
8d419f
         exit 1
8d419f
     }
8d419f
 
8d419f
     initrd_basename="${initrd##*/}"
8d419f
     [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Installing $ENTRY_DIR_ABS/$initrd_basename"
8d419f
     install -g root -o root -m 0644 "$initrd" "$ENTRY_DIR_ABS/$initrd_basename" || {
8d419f
-        echo "Could not copy '$initrd' to '$ENTRY_DIR_ABS/$initrd_basename'." >&2
8d419f
+        echo "Error: could not copy '$initrd' to '$ENTRY_DIR_ABS/$initrd_basename'." >&2
8d419f
         exit 1
8d419f
     }
8d419f
 done
8d419f
 
8d419f
 mkdir -p "${LOADER_ENTRY%/*}" || {
8d419f
-    echo "Could not create loader entry directory '${LOADER_ENTRY%/*}'." >&2
8d419f
+    echo "Error: could not create loader entry directory '${LOADER_ENTRY%/*}'." >&2
8d419f
     exit 1
8d419f
 }
8d419f
 
8d419f
@@ -121,7 +121,7 @@ mkdir -p "${LOADER_ENTRY%/*}" || {
8d419f
     [ $# -eq 0 ] && [ -f "$ENTRY_DIR_ABS/initrd" ] && echo "initrd     $ENTRY_DIR/initrd"
8d419f
     :
8d419f
 } >"$LOADER_ENTRY" || {
8d419f
-    echo "Could not create loader entry '$LOADER_ENTRY'." >&2
8d419f
+    echo "Error: could not create loader entry '$LOADER_ENTRY'." >&2
8d419f
     exit 1
8d419f
 }
8d419f
 exit 0
8d419f
diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install
8d419f
index fe457c1070..a73a205d79 100755
8d419f
--- a/src/kernel-install/kernel-install
8d419f
+++ b/src/kernel-install/kernel-install
8d419f
@@ -73,7 +73,7 @@ else
8d419f
 fi
8d419f
 
8d419f
 if [ $# -lt 1 ]; then
8d419f
-    echo "Not enough arguments" >&2
8d419f
+    echo "Error: not enough arguments" >&2
8d419f
     exit 1
8d419f
 fi
8d419f
 
8d419f
@@ -150,12 +150,12 @@ IFS="
8d419f
 case "$COMMAND" in
8d419f
     add)
8d419f
         if [ $# -lt 1 ]; then
8d419f
-            echo "Command 'add' requires a kernel image" >&2
8d419f
+            echo "Error: command 'add' requires a kernel image" >&2
8d419f
             exit 1
8d419f
         fi
8d419f
 
8d419f
         if ! [ -f "$1" ]; then
8d419f
-            echo "Kernel image argument $1 not a file" >&2
8d419f
+            echo "Error: kernel image argument $1 not a file" >&2
8d419f
             exit 1
8d419f
         fi
8d419f
 
8d419f
@@ -165,9 +165,9 @@ case "$COMMAND" in
8d419f
             # to serve as the indication to use or to not use the BLS
8d419f
             if [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ]; then
8d419f
                 echo "+mkdir -v -p $ENTRY_DIR_ABS"
8d419f
-                mkdir -v -p "$ENTRY_DIR_ABS"
8d419f
+                mkdir -v -p "$ENTRY_DIR_ABS" || exit 1
8d419f
             else
8d419f
-                mkdir -p "$ENTRY_DIR_ABS"
8d419f
+                mkdir -p "$ENTRY_DIR_ABS" || exit 1
8d419f
             fi
8d419f
         fi
8d419f
 
8d419f
@@ -196,7 +196,7 @@ case "$COMMAND" in
8d419f
         ;;
8d419f
 
8d419f
     *)
8d419f
-        echo "Unknown command '$COMMAND'" >&2
8d419f
+        echo "Error: unknown command '$COMMAND'" >&2
8d419f
         exit 1
8d419f
         ;;
8d419f
 esac