mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
bin/package: exit with nonzero status on build failure
Build scripts and the like ought to be able to check the results of the build using the exit status of the build command. bin/package, src/cmd/INIT/package.sh: - Add global error_status variable to keep track of the highest exit status of all commands using capture(). Exit with that. - capture(): * When capturing build output using 'tee', change the regular pipe construct (which doesn't preserve the exit status of pipe elements except the last one) to a couple of background jobs connected with a FIFO (named pipe). This allows getting the build's exit status using the "wait" command. * Update error_status on every invocation of capture(). (cherry picked from commit 22c3a6e1b32f3ab7eeca45adb76863982dc3e334)
This commit is contained in:
parent
22d6b4527d
commit
d18469d608
2 changed files with 28 additions and 2 deletions
15
bin/package
15
bin/package
|
@ -3966,13 +3966,18 @@ capture() # file command ...
|
|||
0) if executable ! $TEE
|
||||
then TEE=tee
|
||||
fi
|
||||
rm -f $o.fifo
|
||||
mkfifo -m 600 $o.fifo || exit
|
||||
$TEE -a $o < $o.fifo &
|
||||
{
|
||||
case $s in
|
||||
?*) echo "$s" ;;
|
||||
esac
|
||||
showenv $action
|
||||
"$@"
|
||||
} < /dev/null 2>&1 | $TEE -a $o
|
||||
} > $o.fifo 2>&1 &
|
||||
rm $o.fifo # unlink early
|
||||
wait "$!" # get build's exit status
|
||||
;;
|
||||
*) {
|
||||
case $s in
|
||||
|
@ -3987,6 +3992,10 @@ capture() # file command ...
|
|||
*) $make "$@"
|
||||
;;
|
||||
esac
|
||||
exit_status=$?
|
||||
if test "$exit_status" -gt "$error_status"
|
||||
then error_status=$exit_status
|
||||
fi
|
||||
}
|
||||
|
||||
package_install() # dest sum
|
||||
|
@ -4358,6 +4367,8 @@ isascii()
|
|||
return $__isascii__
|
||||
}
|
||||
|
||||
error_status=0
|
||||
|
||||
case $action in
|
||||
|
||||
admin) while test ! -f $admin_db
|
||||
|
@ -7358,3 +7369,5 @@ TEST) set '' $target $package
|
|||
;;
|
||||
|
||||
esac
|
||||
|
||||
exit "$error_status"
|
||||
|
|
|
@ -3965,13 +3965,18 @@ capture() # file command ...
|
|||
0) if executable ! $TEE
|
||||
then TEE=tee
|
||||
fi
|
||||
rm -f $o.fifo
|
||||
mkfifo -m 600 $o.fifo || exit
|
||||
$TEE -a $o < $o.fifo &
|
||||
{
|
||||
case $s in
|
||||
?*) echo "$s" ;;
|
||||
esac
|
||||
showenv $action
|
||||
"$@"
|
||||
} < /dev/null 2>&1 | $TEE -a $o
|
||||
} > $o.fifo 2>&1 &
|
||||
rm $o.fifo # unlink early
|
||||
wait "$!" # get build's exit status
|
||||
;;
|
||||
*) {
|
||||
case $s in
|
||||
|
@ -3986,6 +3991,10 @@ capture() # file command ...
|
|||
*) $make "$@"
|
||||
;;
|
||||
esac
|
||||
exit_status=$?
|
||||
if test "$exit_status" -gt "$error_status"
|
||||
then error_status=$exit_status
|
||||
fi
|
||||
}
|
||||
|
||||
package_install() # dest sum
|
||||
|
@ -4357,6 +4366,8 @@ isascii()
|
|||
return $__isascii__
|
||||
}
|
||||
|
||||
error_status=0
|
||||
|
||||
case $action in
|
||||
|
||||
admin) while test ! -f $admin_db
|
||||
|
@ -7357,3 +7368,5 @@ TEST) set '' $target $package
|
|||
;;
|
||||
|
||||
esac
|
||||
|
||||
exit "$error_status"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue