diff options
author | Holger Levsen <holger@layer-acht.org> | 2014-10-15 19:52:26 +0200 |
---|---|---|
committer | Holger Levsen <holger@layer-acht.org> | 2014-10-15 19:52:26 +0200 |
commit | 7b8f67a2692d2936e7f1a123a9370e6229deea89 (patch) | |
tree | a3a2d88a89da289460287036d4c3da12cdfbb418 /bin | |
parent | f18fe2d09ec420fb23b7e2241a9318473ec7ffd3 (diff) | |
download | jenkins.debian.net-7b8f67a2692d2936e7f1a123a9370e6229deea89.tar.xz |
reproducible: use trap to always remove lock file
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/reproducible_scheduler.sh | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/bin/reproducible_scheduler.sh b/bin/reproducible_scheduler.sh index 85358e27..33c543d7 100755 --- a/bin/reproducible_scheduler.sh +++ b/bin/reproducible_scheduler.sh @@ -19,8 +19,13 @@ update_apt() { sudo apt-get update || ( sleep $(( $RANDOM % 70 + 30 )) ; sudo apt-get update ) || ( sleep $(( $RANDOM % 70 + 30 )) ; sudo apt-get update || exit 1 ) } +cleanup_lock() { + rm -f ${PACKAGES_DB}.lock +} + # update sources table in db update_sources_table() { + trap cleanup_lock INT TERM EXIT touch ${PACKAGES_DB}.lock TMPFILE=$(mktemp) curl $MIRROR/dists/sid/main/source/Sources.xz > $TMPFILE @@ -49,7 +54,8 @@ update_sources_table() { done echo "$(date) Done removing duplicate versions from sources db..." echo "=============================================================================" - rm ${PACKAGES_DB}.lock + cleanup_lock + trap - INT TERM EXIT # verify duplicate entries have been removed correctly from the db P_IN_SOURCES=$(sqlite3 ${PACKAGES_DB} 'SELECT count(name) FROM sources') if [ $P_IN_TMPFILE -ne $P_IN_SOURCES ] ; then |