From bb2b9737a8343a1a3bb87a15ffb605ce8ff2af70 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 11 Jun 2011 21:13:17 -0400 Subject: mkinitcpio: catch errors in parse_hook It would be better to catch errors in build as well, but this isn't entirely feasible due to the expectation of some builtins to return non-zero during normal operations (e.g., read returns 1 on EOF). Addresses FS#20661 Signed-off-by: Dave Reisner --- functions | 2 +- mkinitcpio | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/functions b/functions index 5ed543f..580e636 100644 --- a/functions +++ b/functions @@ -202,7 +202,7 @@ add_module() { add_file "$path" || return else error "module '$module' not found" - return + return 1 fi # explicit module depends diff --git a/mkinitcpio b/mkinitcpio index 3b7346b..0cc6f50 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -273,6 +273,11 @@ else msg "Starting build: %s" "$KERNELVERSION" fi +# set errtrace and a trap to catch errors in parse_hook +declare -i builderrors=0 +set -E +trap '[[ $FUNCNAME = parse_hook ]] && (( ++builderrors ))' ERR + #parse 'global' hook, as defined in ${CONFIG} parse_hook @@ -306,6 +311,10 @@ for hook in ${HOOKS}; do fi done +# unset errtrace and trap +set +E +trap ERR + if (( ${#ADDED_MODULES[*]} )); then msg "Generating module dependencies" /sbin/depmod -b "${TMPDIR}/root" "${KERNELVERSION}" @@ -331,6 +340,11 @@ if [[ "${GENIMG}" ]]; then errmsg="$COMPRESSION reported an error" fi + if (( builderrors )); then + warning "errors were encountered during the build. The image may not be complete." + status=1 + fi + if [[ $errmsg ]]; then error "Image generation FAILED: %s\n" "$errmsg" status=1 -- cgit v1.2.3-24-g4f1b