Skip to content

Commit 1c70dda

Browse files
installkernel: recognize the special exit code 77 for hooks
in systemd's kernel-install this exit code causes the remaining hooks to be skipped without causing a fatal failure. may be useful to use as a sanity check in the initrd generator hooks to check e.g. if root is zfs and skip installation if the zfs module is missing Signed-off-by: Nowa Ammerlaan <[email protected]>
1 parent 05e2ba0 commit 1c70dda

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

installkernel

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ fi
218218
# into kernel package installation. Also make sure the PATH includes
219219
# /usr/sbin and /sbin, just as dpkg would.
220220
if [ ${#} -le 3 ] || [ "${4}" = "/boot" ]; then
221+
err=0
221222
(
222223
#shellcheck disable=SC2030
223224
export LC_ALL=C PATH="${PATH}:/usr/sbin:/sbin"
@@ -234,12 +235,14 @@ if [ ${#} -le 3 ] || [ "${4}" = "/boot" ]; then
234235
echo ""
235236
echo "Running ${plugin} ${ver} ${kernel}..."
236237
echo ""
237-
"${plugin}" "${ver}" "${kernel}"
238+
"${plugin}" "${ver}" "${kernel}" || exit ${?}
238239
echo ""
239240
echo "Hook ${plugin} finished successfully"
240241
echo ""
241242
done
242-
)
243+
) || err=${?}
244+
[ ${err} -eq 77 ] && exit 0
245+
[ ${err} -ne 0 ] && exit ${err}
243246
else
244247
echo "WARNING: A custom installation directory is specified as fourth argument."
245248
echo "WARNING: In this configuration running installation hooks is not supported."
@@ -296,6 +299,7 @@ fi
296299
# into kernel package installation. Also make sure the PATH includes
297300
# /usr/sbin and /sbin, just as dpkg would.
298301
if [ ${#} -le 3 ] || [ "${4}" = "/boot" ]; then
302+
err=0
299303
(
300304
#shellcheck disable=SC2031
301305
export LC_ALL=C PATH="${PATH}:/usr/sbin:/sbin"
@@ -312,12 +316,14 @@ if [ ${#} -le 3 ] || [ "${4}" = "/boot" ]; then
312316
echo ""
313317
echo "Running ${plugin} ${ver} ${dir}/${img_dest}-${ver}${suffix}..."
314318
echo ""
315-
"${plugin}" "${ver}" "${dir}/${img_dest}-${ver}${suffix}"
319+
"${plugin}" "${ver}" "${dir}/${img_dest}-${ver}${suffix}" || exit ${?}
316320
echo ""
317321
echo "Hook ${plugin} finished successfully"
318322
echo ""
319323
done
320-
)
324+
) || err=${?}
325+
[ ${err} -eq 77 ] && exit 0
326+
[ ${err} -ne 0 ] && exit ${err}
321327
else
322328
echo "WARNING: A custom installation directory is specified as fourth argument."
323329
echo "WARNING: In this configuration running installation hooks is not supported."

0 commit comments

Comments
 (0)