From 814dd9df251267c2e48d4a30bb3a192329e7f2ab Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 15 Sep 2019 08:10:36 -0400 Subject: consolidate error reporting within generation pipeline --- mkinitcpio | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/mkinitcpio b/mkinitcpio index db7a61a..ed808f0 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -192,8 +192,7 @@ compute_hookset() { } build_image() { - local out=$1 compress=$2 errmsg= - local -a pipesave cpio_opts + local out=$1 compress=$2 errmsg pipestatus case $compress in cat) @@ -216,25 +215,24 @@ build_image() { # Reproducibility: set all timestamps to 0 find . -mindepth 1 -execdir touch -hcd "@0" "{}" + - find . -mindepth 1 -printf '%P\0' | sort -z | + # If this pipeline changes, |pipeprogs| below needs to be updated as well. + find . -mindepth 1 -printf '%P\0' | + sort -z | LANG=C bsdtar --null -cnf - -T - | LANG=C bsdtar --uid 0 --gid 0 --null -cf - --format=newc @- | $compress "${COMPRESSION_OPTIONS[@]}" > "$out" - pipesave=("${PIPESTATUS[@]}") # save immediately + pipestatus=("${PIPESTATUS[@]}") + pipeprogs=('find' 'sort' 'bsdtar (step 1)' 'bsdtar (step 2)' "$compress") + popd >/dev/null - if (( pipesave[0] )); then - errmsg="find reported an error" - elif (( pipesave[1] )); then - errmsg="sort reported an error" - elif (( pipesave[2] )); then - errmsg="bsdtar (step 1) reported an error" - elif (( pipesave[3] )); then - errmsg="bsdtar (step 2) reported an error" - elif (( pipesave[4] )); then - errmsg="$compress reported an error" - fi + for (( i = 0; i < ${#pipestatus[*]}; ++i )); do + if (( pipestatus[i] )); then + errmsg="${pipeprogs[i]} reported an error" + break + fi + done if (( _builderrors )); then warning "errors were encountered during the build. The image may not be complete." -- cgit v1.2.3-24-g4f1b