From 3b76016f9b20e190c623fb38adf0ed2bc3c588ba Mon Sep 17 00:00:00 2001 From: Solene Rapenne Date: Sun, 4 Sep 2022 21:57:23 +0200 Subject: [PATCH] local_build: return an error if a host didn't succeed --- local_build.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/local_build.sh b/local_build.sh index d7ae931..45baf91 100755 --- a/local_build.sh +++ b/local_build.sh @@ -32,6 +32,7 @@ then NAME=* fi +SUCCESS=0 for i in $NAME do if test -d "$i" @@ -49,14 +50,21 @@ do test -d .git || git init >/dev/null 2>/dev/null git add . >/dev/null $SUDO nixos-rebuild "${COMMAND}" --flake .#bento-machine 2>${TMPLOG} >${TMPLOG} - if [ $? -eq 0 ]; then echo "success" ; else echo "failure" ; cat ${TMPLOG} ; fi + if [ $? -eq 0 ]; then echo "success" ; else echo "failure" ; SUCCESS=$(( SUCCESS + 1 )) ; cat ${TMPLOG} ; fi else cd "$TMP" || exit 5 $SUDO nixos-rebuild "${COMMAND}" --no-flake -I nixos-config="$TMP/configuration.nix" 2>${TMPLOG} >${TMPLOG} - if [ $? -eq 0 ]; then echo "success" ; else echo "failure" ; cat ${TMPLOG} ; fi + if [ $? -eq 0 ]; then echo "success" ; else echo "failure" ; SUCCESS=$(( SUCCESS + 1 )) ; cat ${TMPLOG} ; fi fi cd - >/dev/null || exit 5 rm -fr "$TMP" fi done + +# we don't want to allow this script to chain +# with another if it failed +if [ "$SUCCESS" -ne 0 ] +then + exit 1 +fi