1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-09 13:57:42 +03:00

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-01-19 12:15:16 +01:00
parent a520d5dddb
commit 680cec6b4d
2 changed files with 11 additions and 11 deletions

View 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

View File

@ -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