From: Zbigniew Jędrzejewski-Szmek Date: Wed, 19 Jan 2022 11:15:16 +0000 (+0100) Subject: kernel-install: prefix errors with "Error:", exit immediately X-Git-Tag: v251-rc1~399^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=680cec6b4ddb356d7dd087b197718712cb5c1662;p=thirdparty%2Fsystemd.git kernel-install: prefix errors with "Error:", exit immediately 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. --- diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install index 7b768457c1d..6a396910cbe 100644 --- a/src/kernel-install/90-loaderentry.install +++ b/src/kernel-install/90-loaderentry.install @@ -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 diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install index fe457c10707..a73a205d797 100755 --- a/src/kernel-install/kernel-install +++ b/src/kernel-install/kernel-install @@ -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