From 6828b5cff3f20875d51871ef91ffe0508fd5354e Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 3 Feb 2023 23:57:47 +0100 Subject: bin/cleanup: lock the database - this should not run in parallel to db-update --- bin/cleanup | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bin/cleanup b/bin/cleanup index 57c4e07..14d08ac 100755 --- a/bin/cleanup +++ b/bin/cleanup @@ -19,6 +19,14 @@ if [ -s "${work_dir}/build-master-sanity" ]; then exit fi +# Lock the database - we should not run in parallel with db-update. +exec 9> "${package_database_lock_file}" +# shellcheck disable=SC2086 +if ! verbose_flock -n 9; then + >&2 echo 'come back (shortly) later - I cannot lock package database.' + exit 0 +fi + # only keep newest logs per failed package and fail_reason # shellcheck disable=SC2016 @@ -68,6 +76,9 @@ fi rm "${build_log_directory}/error/${file}" done +# Release database lock. +flock -u 9 || true + # only keep namcap logs of last 2 weeks for succeeded packages find "${build_log_directory}/success" -maxdepth 1 -type f -mtime +14 \ -not -exec zgrep -q '^+.*ELF file .* has text relocations' '{}' \; \ -- cgit v1.2.3-70-g09d2