]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install: prefix errors with "Error:", exit immediately
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 19 Jan 2022 11:15:16 +0000 (12:15 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 28 Jan 2022 15:17:47 +0000 (16:17 +0100)
kernel-install would continue after errors… We don't want this, as it
makes the results totally unpredicatable. If we didn't install the kernel
or didn't do some important part of the setup, let's just return an error
and let the user deal with it.

When looking at output, the error was often hard to distinguish, esp.
with -v. Add "Error:" everywhere to make the output easier to parse.

src/kernel-install/90-loaderentry.install
src/kernel-install/kernel-install

index 7b768457c1d1d074fbc1bfb025c9449eba136497..6a396910cbeb7140f9a4713b96c6a7f569bd6ebf 100644 (file)
@@ -83,27 +83,27 @@ if ! [ -d "$ENTRY_DIR_ABS" ]; then
 fi
 
 install -g root -o root -m 0644 "$KERNEL_IMAGE" "$ENTRY_DIR_ABS/linux" || {
-    echo "Could not copy '$KERNEL_IMAGE' to '$ENTRY_DIR_ABS/linux'." >&2
+    echo "Error: could not copy '$KERNEL_IMAGE' to '$ENTRY_DIR_ABS/linux'." >&2
     exit 1
 }
 
 shift "$INITRD_OPTIONS_SHIFT"
 for initrd; do
     [ -f "$initrd" ] || {
-        echo "Initrd '$initrd' not a file." >&2
+        echo "Error: initrd '$initrd' not a file." >&2
         exit 1
     }
 
     initrd_basename="${initrd##*/}"
     [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Installing $ENTRY_DIR_ABS/$initrd_basename"
     install -g root -o root -m 0644 "$initrd" "$ENTRY_DIR_ABS/$initrd_basename" || {
-        echo "Could not copy '$initrd' to '$ENTRY_DIR_ABS/$initrd_basename'." >&2
+        echo "Error: could not copy '$initrd' to '$ENTRY_DIR_ABS/$initrd_basename'." >&2
         exit 1
     }
 done
 
 mkdir -p "${LOADER_ENTRY%/*}" || {
-    echo "Could not create loader entry directory '${LOADER_ENTRY%/*}'." >&2
+    echo "Error: could not create loader entry directory '${LOADER_ENTRY%/*}'." >&2
     exit 1
 }
 
@@ -121,7 +121,7 @@ mkdir -p "${LOADER_ENTRY%/*}" || {
     [ $# -eq 0 ] && [ -f "$ENTRY_DIR_ABS/initrd" ] && echo "initrd     $ENTRY_DIR/initrd"
     :
 } >"$LOADER_ENTRY" || {
-    echo "Could not create loader entry '$LOADER_ENTRY'." >&2
+    echo "Error: could not create loader entry '$LOADER_ENTRY'." >&2
     exit 1
 }
 exit 0
index fe457c107072aee9e79ae6f2b00a00c246381049..a73a205d79783964b9aa243ebbc760e73bbe20c4 100755 (executable)
@@ -73,7 +73,7 @@ else
 fi
 
 if [ $# -lt 1 ]; then
-    echo "Not enough arguments" >&2
+    echo "Error: not enough arguments" >&2
     exit 1
 fi
 
@@ -150,12 +150,12 @@ IFS="
 case "$COMMAND" in
     add)
         if [ $# -lt 1 ]; then
-            echo "Command 'add' requires a kernel image" >&2
+            echo "Error: command 'add' requires a kernel image" >&2
             exit 1
         fi
 
         if ! [ -f "$1" ]; then
-            echo "Kernel image argument $1 not a file" >&2
+            echo "Error: kernel image argument $1 not a file" >&2
             exit 1
         fi
 
@@ -165,9 +165,9 @@ case "$COMMAND" in
             # to serve as the indication to use or to not use the BLS
             if [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ]; then
                 echo "+mkdir -v -p $ENTRY_DIR_ABS"
-                mkdir -v -p "$ENTRY_DIR_ABS"
+                mkdir -v -p "$ENTRY_DIR_ABS" || exit 1
             else
-                mkdir -p "$ENTRY_DIR_ABS"
+                mkdir -p "$ENTRY_DIR_ABS" || exit 1
             fi
         fi
 
@@ -196,7 +196,7 @@ case "$COMMAND" in
         ;;
 
     *)
-        echo "Unknown command '$COMMAND'" >&2
+        echo "Error: unknown command '$COMMAND'" >&2
         exit 1
         ;;
 esac