Caputre failed build and exit in elegant
This commit is contained in:
parent
0d3d1f7e33
commit
9997bb5979
|
@ -32,6 +32,7 @@ trap 'term_handle' TERM SIGINT INT
|
||||||
function build_repo {
|
function build_repo {
|
||||||
trap 'term_delay' TERM SIGINT INT
|
trap 'term_delay' TERM SIGINT INT
|
||||||
|
|
||||||
|
local return_code=0
|
||||||
for deb in "${INCOME_DIR}/"*
|
for deb in "${INCOME_DIR}/"*
|
||||||
do
|
do
|
||||||
if [[ "$deb" = *"/*" ]]
|
if [[ "$deb" = *"/*" ]]
|
||||||
|
@ -44,7 +45,15 @@ function build_repo {
|
||||||
for codename in "${CODENAME[@]}"
|
for codename in "${CODENAME[@]}"
|
||||||
do
|
do
|
||||||
msg "adding $deb into $codename"
|
msg "adding $deb into $codename"
|
||||||
reprepro includedeb "$codename" "$deb"
|
reprepro includedeb "$codename" "$deb" && return_code=$? || return_code=$?
|
||||||
|
|
||||||
|
if [[ "$return_code" -ne 0 ]]
|
||||||
|
then
|
||||||
|
msg "failed to add $deb into $codename"
|
||||||
|
msg "copy $deb to $FAILED_DIR/$codename"
|
||||||
|
mkdir -p "$FAILED_DIR/$codename"
|
||||||
|
cp "$deb" "$FAILED_DIR/$codename/"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
msg "finished adding $deb"
|
msg "finished adding $deb"
|
||||||
|
|
||||||
|
@ -67,9 +76,12 @@ do
|
||||||
inotifywait --quiet -e move -e modify -e create "$INCOME_DIR" &
|
inotifywait --quiet -e move -e modify -e create "$INCOME_DIR" &
|
||||||
inotify_pid="$!"
|
inotify_pid="$!"
|
||||||
|
|
||||||
# when inotifywait was killed, its return code is no-zero,
|
# When inotifywait was killed, its return code is no-zero,
|
||||||
# so when wait return inotifywait's return code, script will exit due to errexit
|
# so when wait return inotifywait's return code, script will exit due to errexit.
|
||||||
wait || true
|
# Use '||' to fix the above problem
|
||||||
|
#
|
||||||
|
# Break the loop when failed to watching (or killed)
|
||||||
|
wait $inotify_pid || GO_ON=0
|
||||||
done
|
done
|
||||||
|
|
||||||
msg "$PROGRAM_NAME shutdown"
|
msg "$PROGRAM_NAME shutdown"
|
||||||
|
|
Loading…
Reference in a new issue