ensure failing if manifest or gencode break

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-02-17 16:26:48 +01:00
parent f392543d43
commit ff41ce0318
5 changed files with 25 additions and 16 deletions

View file

@ -21,8 +21,10 @@ I usually do it like this:
eof eof
# Tell the user what we do, so this script makes sense during execution # Tell the user what we do, so this script makes sense during execution
# And abort on any error set -x
set -ex
# Abort on any error
set -e
# prepare use (only from top level directory) # prepare use (only from top level directory)
export PATH="$PATH:$(pwd -P)/bin" export PATH="$PATH:$(pwd -P)/bin"

View file

@ -23,10 +23,8 @@
# #
. cdist-config . cdist-config
[ $# -eq 2 ] || __cdist_usage "<target host> <outdir>"
if [ $# -ne 2 ]; then set -e
__cdist_usage "<target host> <outdir>"
fi
export __cdist_target_host="$1"; shift export __cdist_target_host="$1"; shift
export __cdist_output_dir="$1"; shift export __cdist_output_dir="$1"; shift

View file

@ -23,19 +23,15 @@
# #
. cdist-config . cdist-config
[ $# -eq 3 ] || __cdist_usage "<target host> <manifest> <outdir>"
if [ $# -ne 3 ]; then set -u
__cdist_usage "<target host> <manifest> <outdir>"
fi
set -aeu
export __cdist_target_host="$1"; shift export __cdist_target_host="$1"; shift
export __cdist_manifest="$1"; shift export __cdist_manifest="$1"; shift
export __cdist_output_dir="$1"; shift export __cdist_output_dir="$1"; shift
# Ensure binaries exist and are up-to-date # Ensure binaries exist and are up-to-date
cdist-build-bin cdist-build-bin || __cdist_exit_err "Failed to build support binaries"
# prepend our path, so all cdist tools come before other tools # prepend our path, so all cdist tools come before other tools
PATH="${__cdist_cache_bin}:$PATH" PATH="${__cdist_cache_bin}:$PATH"
@ -50,7 +46,12 @@ mkdir -p "${__cdist_output_dir}"
# Catch errors ourselves now # Catch errors ourselves now
set +e set +e
"${__cdist_manifest}"; ret=$? # Ensure manifest fails if any error exists - FIXME: redundant, cdist-object-codegen
(
set -e
. "${__cdist_manifest}"
); ret=$?
if [ "$ret" -ne 0 ]; then if [ "$ret" -ne 0 ]; then
__cdist_exit_err "Error: ${__cdist_manifest} exited non-zero." __cdist_exit_err "Error: ${__cdist_manifest} exited non-zero."
fi fi

View file

@ -56,7 +56,12 @@ eof
# Catch errors ourself now # Catch errors ourself now
set +e set +e
"$gencode"; ret=$? (
# Ensure manifest fails if something within manifest fails
# And not all manifests need to include set -e themselves
set -e
. "$gencode"
); ret=$?
else else
ret=0 ret=0

View file

@ -25,12 +25,15 @@
. cdist-config . cdist-config
set -e set -e
pwd -P >&2
ls >&2
type="$(cat type)" type="$(cat type)"
mode="$(cat mode)" mode="$(cat mode)"
path="$(cat path)" path="$(cat path)"
case "$type" in
case "$type" in
directory) directory)
echo mkdir \"$path\" echo mkdir \"$path\"
;; ;;