From ecce82c3caac9d89bebd9a8c935973e86a352288 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Fri, 31 Dec 2021 08:12:55 +0000 Subject: [PATCH] package: report 'failed' if build failed bin/package, src/cmd/INIT/package.sh: - Make the EXIT (0) trap report failure based on $error_status (see d18469d6), replacing 'done' with 'failed' if it is nonzero. - Remove extra space before 'at' in that report line. - If we get a signal, we have to set error_status to nonzero manually so that the correct exit message is printed. --- bin/package | 14 ++++++++------ src/cmd/INIT/package.sh | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/bin/package b/bin/package index 7e5a428fe..1559ef771 100755 --- a/bin/package +++ b/bin/package @@ -109,7 +109,7 @@ command=${0##*/} case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in 0123) USAGE=$' [-? -@(#)$Id: '$command$' (ksh 93u+m) 2021-12-22 $ +@(#)$Id: '$command$' (ksh 93u+m) 2021-12-31 $ ] [-author?Glenn Fowler ] [-author?Contributors to https://github.com/ksh93/ksh] @@ -529,7 +529,7 @@ SEE ALSO mamake(1), pax(1), pkgadd(1), pkgmk(1), rpm(1), sh(1), tar(1), optget(3) IMPLEMENTATION - version package (ksh 93u+m) 2021-12-22 + version package (ksh 93u+m) 2021-12-31 author Glenn Fowler author Contributors to https://github.com/ksh93/ksh copyright (c) 1994-2012 AT&T Intellectual Property @@ -2683,13 +2683,15 @@ capture() # file command ... : > $o note "$action output captured in $o" s="$command: $action start at $(date) in $INSTALLROOT" + cmd='case $error_status in 0) r=done;; *) r=failed;; esac;' + cmd=$cmd' echo "$command: $action $r at $(date) in $INSTALLROOT"' case $quiet in - 0) cmd="echo \"$command: $action done at \$(date)\" in $INSTALLROOT 2>&1 | \$TEE -a $o" ;; - *) cmd="echo \"$command: $action done at \$(date)\" in $INSTALLROOT >> $o" ;; + 0) cmd="$cmd 2>&1 | \$TEE -a $o" ;; + *) cmd="$cmd >> $o" ;; esac trap "$cmd" 0 - trap "$cmd; trap 1 0; kill -1 $$" 1 - trap "$cmd; trap 2 0; kill -2 $$" 2 + trap "error_status=1; $cmd; trap 1 0; kill -1 $$" 1 + trap "error_status=1; $cmd; trap 2 0; kill -2 $$" 2 ;; esac case $quiet in diff --git a/src/cmd/INIT/package.sh b/src/cmd/INIT/package.sh index 7e5a428fe..1559ef771 100644 --- a/src/cmd/INIT/package.sh +++ b/src/cmd/INIT/package.sh @@ -109,7 +109,7 @@ command=${0##*/} case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in 0123) USAGE=$' [-? -@(#)$Id: '$command$' (ksh 93u+m) 2021-12-22 $ +@(#)$Id: '$command$' (ksh 93u+m) 2021-12-31 $ ] [-author?Glenn Fowler ] [-author?Contributors to https://github.com/ksh93/ksh] @@ -529,7 +529,7 @@ SEE ALSO mamake(1), pax(1), pkgadd(1), pkgmk(1), rpm(1), sh(1), tar(1), optget(3) IMPLEMENTATION - version package (ksh 93u+m) 2021-12-22 + version package (ksh 93u+m) 2021-12-31 author Glenn Fowler author Contributors to https://github.com/ksh93/ksh copyright (c) 1994-2012 AT&T Intellectual Property @@ -2683,13 +2683,15 @@ capture() # file command ... : > $o note "$action output captured in $o" s="$command: $action start at $(date) in $INSTALLROOT" + cmd='case $error_status in 0) r=done;; *) r=failed;; esac;' + cmd=$cmd' echo "$command: $action $r at $(date) in $INSTALLROOT"' case $quiet in - 0) cmd="echo \"$command: $action done at \$(date)\" in $INSTALLROOT 2>&1 | \$TEE -a $o" ;; - *) cmd="echo \"$command: $action done at \$(date)\" in $INSTALLROOT >> $o" ;; + 0) cmd="$cmd 2>&1 | \$TEE -a $o" ;; + *) cmd="$cmd >> $o" ;; esac trap "$cmd" 0 - trap "$cmd; trap 1 0; kill -1 $$" 1 - trap "$cmd; trap 2 0; kill -2 $$" 2 + trap "error_status=1; $cmd; trap 1 0; kill -1 $$" 1 + trap "error_status=1; $cmd; trap 2 0; kill -2 $$" 2 ;; esac case $quiet in