index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2018-05-25 09:07:39 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-05-25 09:07:39 +0200 |
commit | 0be03e8056755deaaf1492fa1df38907eade690e (patch) | |
tree | ef9a485711a1b098c249c1494ffc3029cc8da728 | |
parent | ad863c02e7b0e7030a920a318fcb9a9963333eb3 (diff) |
-rwxr-xr-x | bin/bootstrap-mysql | 6 | ||||
-rwxr-xr-x | bin/build-master-status | 2 | ||||
-rwxr-xr-x | bin/build-packages | 2 | ||||
-rwxr-xr-x | bin/copy-to-build-support | 4 | ||||
-rwxr-xr-x | bin/db-update | 4 | ||||
-rwxr-xr-x | bin/delete-packages | 6 | ||||
-rwxr-xr-x | bin/find-obsolete-packages | 4 | ||||
-rwxr-xr-x | bin/get-assignment | 4 | ||||
-rwxr-xr-x | bin/get-package-updates | 4 | ||||
-rwxr-xr-x | bin/modify-package-state | 4 | ||||
-rwxr-xr-x | bin/prioritize-build-list | 4 | ||||
-rwxr-xr-x | bin/return-assignment | 6 | ||||
-rwxr-xr-x | bin/sanity-check | 2 | ||||
-rwxr-xr-x | bin/seed-build-list | 4 | ||||
-rwxr-xr-x | bin/show-dependencies | 4 | ||||
-rwxr-xr-x | lib/common-functions | 15 |
diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql index 6e4afc2..c3d7080 100755 --- a/bin/bootstrap-mysql +++ b/bin/bootstrap-mysql @@ -6,17 +6,17 @@ . "${0%/*}/../conf/default.conf" exec 9> "${build_list_lock_file}" -if ! flock -n 9; then +if ! verbose_flock -n 9; then >&2 echo 'Cannot get build-list lock.' exit 1 fi exec 8> "${sanity_check_lock_file}" -if ! flock -s -n 9; then +if ! verbose_flock -s -n 9; then >&2 echo 'Cannot get sanity-check lock.' exit 1 fi exec 7> "${package_database_lock_file}" -if ! flock -s -n 7; then +if ! verbose_flock -s -n 7; then >&2 echo 'Cannot get package-database lock.' exit 1 fi diff --git a/bin/build-master-status b/bin/build-master-status index c0d9cb1..d1382c7 100755 --- a/bin/build-master-status +++ b/bin/build-master-status @@ -12,7 +12,7 @@ trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT # do not block if locked exec 9> "${sanity_check_lock_file}" -if ! flock -n 9; then +if ! verbose_flock -n 9; then >&2 echo 'Mysql-Sanity check skipped, cannot acquire lock.' exit fi diff --git a/bin/build-packages b/bin/build-packages index c6f912c..3d5d2d1 100755 --- a/bin/build-packages +++ b/bin/build-packages @@ -282,7 +282,7 @@ while [ "${count}" -ne 0 ] && \ # we get a lock on "${work_dir}/ping-build-master.lock", # if we release that lock, ping-to-master should stop _immediately_ exec 9> "${work_dir}/ping-build-master.lock" - if ! flock -n 9; then + if ! verbose_flock -n 9; then >&2 echo 'ERROR: Cannot lock ping-to-master - this should not happen.' exit 2 fi diff --git a/bin/copy-to-build-support b/bin/copy-to-build-support index 2de852a..fc79055 100755 --- a/bin/copy-to-build-support +++ b/bin/copy-to-build-support @@ -60,10 +60,10 @@ if [ "$#" -ne 1 ]; then fi exec 9> "${sanity_check_lock_file}" -flock -s ${wait_for_lock} 9 +verbose_flock -s ${wait_for_lock} 9 exec 8> "${package_database_lock_file}" -flock ${wait_for_lock} 8 +verbose_flock ${wait_for_lock} 8 tmp_dir=$(mktemp -d "${work_dir}/tmp.copy-to-build-support.0.XXXXXXXXXX") trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT diff --git a/bin/db-update b/bin/db-update index b6fd116..2351c77 100755 --- a/bin/db-update +++ b/bin/db-update @@ -115,13 +115,13 @@ fi # Create tmp_dir, lock and trap. exec 9> "${package_database_lock_file}" -if ! flock ${block_flag} 9; then +if ! verbose_flock ${block_flag} 9; then >&2 echo 'come back (shortly) later - I cannot lock package database.' exit 0 fi exec 8> "${sanity_check_lock_file}" -if ! flock -s ${block_flag} 8; then +if ! verbose_flock -s ${block_flag} 8; then >&2 echo 'come back (shortly) later - sanity-check currently running.' exit 0 fi diff --git a/bin/delete-packages b/bin/delete-packages index 520b664..0065752 100755 --- a/bin/delete-packages +++ b/bin/delete-packages @@ -77,19 +77,19 @@ fi if ! ${no_action}; then # exec 9> "${build_list_lock_file}" -# if ! flock ${block_flag} 9; then +# if ! verbose_flock ${block_flag} 9; then # >&2 echo 'come back (shortly) later - I cannot lock build list.' # exit 0 # fi exec 8> "${package_database_lock_file}" - if ! flock ${block_flag} 8; then + if ! verbose_flock ${block_flag} 8; then >&2 echo 'come back (shortly) later - I cannot lock package database.' exit 0 fi exec 7> "${sanity_check_lock_file}" - if ! flock -s ${block_flag} 7; then + if ! verbose_flock -s ${block_flag} 7; then >&2 echo 'come back (shortly) later - sanity-check running.' exit 0 fi diff --git a/bin/find-obsolete-packages b/bin/find-obsolete-packages index 751a6c3..c965447 100755 --- a/bin/find-obsolete-packages +++ b/bin/find-obsolete-packages @@ -79,13 +79,13 @@ fi if ! ${no_action}; then exec 9> "${sanity_check_lock_file}" - if ! flock -s ${wait_for_lock} 9; then + if ! verbose_flock -s ${wait_for_lock} 9; then >&2 echo 'Cannot get sanity-check lock.' exit 1 fi exec 8> "${build_list_lock_file}" - if ! flock ${wait_for_lock} 8; then + if ! verbose_flock ${wait_for_lock} 8; then >&2 echo 'Cannot get build-list lock.' exit 1 fi diff --git a/bin/get-assignment b/bin/get-assignment index 6289da0..1c67279 100755 --- a/bin/get-assignment +++ b/bin/get-assignment @@ -70,13 +70,13 @@ fi # Create a lock file and a trap. exec 9> "${build_list_lock_file}" -if ! flock -n 9; then +if ! verbose_flock -n 9; then >&2 echo 'come back (shortly) later - I cannot lock build list.' exit 1 fi exec 8> "${sanity_check_lock_file}" -if ! flock -s -n 8; then +if ! verbose_flock -s -n 8; then >&2 echo 'come back (shortly) later - sanity-check running.' exit 1 fi diff --git a/bin/get-package-updates b/bin/get-package-updates index aa53e4b..59ec019 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -200,13 +200,13 @@ fi # Create a lock file for build list. exec 9> "${build_list_lock_file}" -if ! flock ${block_flag} 9; then +if ! verbose_flock ${block_flag} 9; then >&2 echo 'come back (shortly) later - I cannot lock build list.' exit fi exec 8> "${sanity_check_lock_file}" -if ! flock -s ${block_flag} 8; then +if ! verbose_flock -s ${block_flag} 8; then >&2 echo 'come back (shortly) later - sanity-check running.' exit fi diff --git a/bin/modify-package-state b/bin/modify-package-state index 754611a..2ca2178 100755 --- a/bin/modify-package-state +++ b/bin/modify-package-state @@ -129,13 +129,13 @@ if ! [ -r "${input_file}" ]; then fi exec 9> "${sanity_check_lock_file}" -if ! flock -s ${wait_for_lock} 9; then +if ! verbose_flock -s ${wait_for_lock} 9; then >&2 echo 'Cannot get sanity-check lock.' exit fi exec 8> "${package_database_lock_file}" -if ! flock ${wait_for_lock} 8; then +if ! verbose_flock ${wait_for_lock} 8; then >&2 echo 'Cannot get package-database lock.' exit fi diff --git a/bin/prioritize-build-list b/bin/prioritize-build-list index 4138534..f5687e6 100755 --- a/bin/prioritize-build-list +++ b/bin/prioritize-build-list @@ -14,13 +14,13 @@ fi # Create a lock file for build list. exec 9> "${build_list_lock_file}" -if ! flock -n 9; then +if ! verbose_flock -n 9; then >&2 echo 'come back (shortly) later - I cannot lock build list.' exit 1 fi exec 8> "${sanity_check_lock_file}" -if ! flock -s -n 8; then +if ! verbose_flock -s -n 8; then >&2 echo 'come back (shortly) later - sanity-check running.' exit 1 fi diff --git a/bin/return-assignment b/bin/return-assignment index 553247c..dd13925 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -29,13 +29,13 @@ fi # Create a lock file and a trap. exec 9> "${build_list_lock_file}" -if ! flock -n 9; then +if ! verbose_flock -n 9; then >&2 echo 'come back (shortly) later - I cannot lock build list.' exit 1 fi exec 8> "${sanity_check_lock_file}" -if ! flock -s -n 8; then +if ! verbose_flock -s -n 8; then >&2 echo 'come back (shortly) later - sanity-check running.' exit 1 fi @@ -226,7 +226,7 @@ fi # so we also need a lock on the package database exec 7> "${package_database_lock_file}" -if ! flock -n 7; then +if ! verbose_flock -n 7; then >&2 echo 'come back (shortly) later - I cannot lock package database.' exit 1 fi diff --git a/bin/sanity-check b/bin/sanity-check index 7ae0303..d5b86db 100755 --- a/bin/sanity-check +++ b/bin/sanity-check @@ -75,7 +75,7 @@ do done exec 9> "${sanity_check_lock_file}" -if ! flock ${block_flag} 9; then +if ! verbose_flock ${block_flag} 9; then >&2 echo 'Sanity check skipped, cannot acquire lock.' exit fi diff --git a/bin/seed-build-list b/bin/seed-build-list index 923e65a..7540f14 100755 --- a/bin/seed-build-list +++ b/bin/seed-build-list @@ -115,13 +115,13 @@ fi # get locks if ${update}; then exec 9> "${sanity_check_lock_file}" - if ! flock -s ${wait_for_lock} 9; then + if ! verbose_flock -s ${wait_for_lock} 9; then >&2 echo 'Cannot get sanity-check lock.' exit 1 fi exec 8> "${build_list_lock_file}" - if ! flock ${wait_for_lock} 8; then + if ! verbose_flock ${wait_for_lock} 8; then >&2 echo 'Cannot get build-list lock.' exit 1 fi diff --git a/bin/show-dependencies b/bin/show-dependencies index ede0f78..111a41b 100755 --- a/bin/show-dependencies +++ b/bin/show-dependencies @@ -41,13 +41,13 @@ if pgrep -f '^\S+ '"$0"'.' | \ fi exec 9> "${work_dir}/${0##*/}.lock" -if ! flock -n 9; then +if ! verbose_flock -n 9; then >&2 echo 'Cannot get show-dependencies lock.' exit fi exec 8> "${sanity_check_lock_file}" -if ! flock -s -n 8; then +if ! verbose_flock -s -n 8; then >&2 echo 'Cannot get sanity-check lock.' exit fi diff --git a/lib/common-functions b/lib/common-functions index 4224831..b152f53 100755 --- a/lib/common-functions +++ b/lib/common-functions @@ -719,3 +719,18 @@ calculate_script_checksum() { sha512sum | \ awk '{print $1}' } + +# verbose_flock +# flock wrapper with some informational output on error +verbose_flock() { + local err=0 + flock "$@" || { + err=$? + lsof "/proc/$$/fd/$( + printf '%s\n' "$@" | \ + grep -vm1 '^-' + )" || true + printf 'FYI: I am %s.\n' "$$" + return ${err} + } +} |