diff options
Diffstat (limited to 'bin/nit-picker')
-rwxr-xr-x | bin/nit-picker | 122 |
1 files changed, 70 insertions, 52 deletions
diff --git a/bin/nit-picker b/bin/nit-picker index d356011..ed5b7da 100755 --- a/bin/nit-picker +++ b/bin/nit-picker @@ -10,34 +10,65 @@ # resilient against transient states of the buildmaster): # - check sanity of git # - check expiration of package and master keys +# - complain about packages residing too long in [staging]/[testing] +# - check if our packages are still available upstream # TODO: # - check for differences of dependencies between mysql and git # - check for differences of dependencies between mysql and packages # - check for installability of packages -# - check if our packages are still available upstream -# - complain about packages residing too long in [staging]/[testing] -if [ $# -ge 1 ] && [ "x$1" = 'x-n' ]; then - >&2 echo 'not joining irc' - irc=false - repair_dependencies=false - shift -elif [ $# -ge 1 ] && [ "x$1" = 'x-r' ]; then - >&2 echo 'repair all wrong dependencies (remove superfluid, add missing)' - irc=false - repair_dependencies=true +# shellcheck disable=SC2016 +print_usage() { + >&2 echo 'usage: nit-picker [-n|-r|-x] [$single_test]' + >&2 echo ' -n: Do not join irc.' + >&2 echo ' -r: Remove superfluid dependencies in the database.' + >&2 echo ' To avoid catastrophic breakage, this option requires' + >&2 echo ' $single_test being set.' + >&2 echo ' -x: Exit upon first found inconsistency.' + >&2 echo ' $single_test: Only execute the given test.' +} + +exit_fast=false +irc=true +repair_dependencies=false + +while [ $# -ge 1 ]; do + case "$1" in + '-n') + >&2 echo 'not joining irc' + irc=false + ;; + '-r') + >&2 echo 'repair all wrong dependencies (remove superfluid, add missing)' + repair_dependencies=true + ;; + '-x') + >&2 echo 'exit, when the first inconsistency is being found' + exit_fast=true + ;; + '-*') + >&2 printf 'unknown option "%s"\n' "$1" + print_usage + exit 1 + ;; + *) + break + ;; + esac shift +done + +if [ $# -eq 0 ]; then + single_run=false else - irc=true - repair_dependencies=false - # shellcheck disable=SC2016 - if [ $# -ne 0 ]; then - >&2 echo 'usage: nit-picker [-n|-r [$single_test]]' - >&2 echo ' -n: do not join irc' - >&2 echo ' -r: remove superfluid dependencies in the database' - >&2 echo ' $single_test: only execute the given test' - exit 1 - fi + single_run=true +fi + +if ${repair_dependencies} \ +&& ! ${single_run}; then + >&2 echo 'Option "-r" needs a test.' + print_usage + exit 1 fi clean_up() { @@ -55,7 +86,7 @@ if ${irc}; then rm -rf --one-file-system "${irc_dir}" - ii -s irc.freenode.net -n nit-picker -f nit-picker >/dev/null 2>&1 & + ii -s irc.libera.chat -n nit-picker -f nit-picker >/dev/null 2>&1 & ii_pid=$! clean_up() { @@ -78,10 +109,10 @@ if ${irc}; then done # join channel - echo '/j #archlinux32' | \ + echo '/j #archlinux32-devops' | \ sponge "${irc_dir}/in" - while [ ! -f "${irc_dir}/#archlinux32/out" ]; do + while [ ! -f "${irc_dir}/#archlinux32-devops/out" ]; do sleep 1 done @@ -100,6 +131,12 @@ local_irc_say() { else sed 's/^/irc: /' fi + if ${exit_fast}; then + exit 1 + fi + if ! ${single_run}; then + sleep 60 + fi } mysql_load_min_and_max_versions @@ -114,7 +151,9 @@ while pgrep -x ii >/dev/null \ else do_once_a_day_checks=false fi - if [ $# -eq 0 ]; then + if ${single_run}; then + printf '%s\n' "$*" + else # shellcheck disable=SC2016 { if ! "${repair_dependencies}"; then @@ -233,19 +272,18 @@ while pgrep -x ii >/dev/null \ mysql_run_query | \ tr '\t' ' ' | \ shuf - else - printf '%s\n' "$*" fi | \ while read -r action parameters; do if ${irc} && ! pgrep -x ii >/dev/null; then + >&2 echo 'ii is no longer running' break fi case "${action}" in 'commit') # check whether a given commit is present in the git repo git_repo="${parameters%% *}" - git_rev="${parameters#${git_repo} }" + git_rev="${parameters#"${git_repo}" }" git_head="${git_rev%% *}" - git_rev="${git_rev#${git_head} }" + git_rev="${git_rev#"${git_head}" }" # shellcheck disable=SC2016 eval "$( printf 'git_dir="${repo_paths__%s}"\n' \ @@ -373,9 +411,6 @@ while pgrep -x ii >/dev/null \ if ! ${irc}; then diff -u --color "${tmp_dir}/db-deps" "${tmp_dir}/pkg-deps" || true fi - if [ $# -eq 0 ]; then - sleep 60 - fi fi fi rm \ @@ -449,9 +484,6 @@ while pgrep -x ii >/dev/null \ if [ -n "${error_message}" ]; then printf '%s\n' "${error_message}" \ | local_irc_say - if [ $# -eq 0 ]; then - sleep 60 - fi fi rm \ "${tmp_dir}/${parameters}" \ @@ -507,9 +539,6 @@ while pgrep -x ii >/dev/null \ )" \ | awk '{print $1 ": your slave " $2 " builds " $3 "/" $4 " for more than a day, now (" ($5-1) " day(s) " $6 ")"}' \ | local_irc_say - if [ $# -eq 0 ]; then - sleep 60 - fi ;; 'keyring') if ! ${master_mirror_rsync_command} \ @@ -545,9 +574,6 @@ while pgrep -x ii >/dev/null \ "$(date -I -d@"${expiration}")" \ "${expiration_days}" \ | local_irc_say - if [ $# -eq 0 ]; then - sleep 60 - fi fi done done @@ -603,9 +629,6 @@ while pgrep -x ii >/dev/null \ s/^\S\+ /parts of \0are in different repositories: / ' \ | local_irc_say - if [ $# -eq 0 ]; then - sleep 60 - fi fi ;; 'upstream-availability') @@ -670,9 +693,6 @@ while pgrep -x ii >/dev/null \ printf 'Package %s is still in our repositories or on the build-list, but is not available upstream.\n' \ "${parameters}" \ | local_irc_say - if [ $# -eq 0 ]; then - sleep 60 - fi ;; 'repository-duration') case "${parameters#* }" in @@ -742,9 +762,6 @@ while pgrep -x ii >/dev/null \ fi } \ | local_irc_say - if [ $# -eq 0 ]; then - sleep 60 - fi ;; *) >&2 printf 'action "%s" is not yet implemented.\n' "${action}" @@ -756,7 +773,8 @@ while pgrep -x ii >/dev/null \ ;; esac done - if [ $# -ge 1 ] || "${repair_dependencies}"; then + if ${single_run}; then + >&2 echo 'only one run was requested' break fi sleep 120 @@ -863,6 +881,6 @@ done printf ';\n' fi } \ -| ifne ssh buildmaster 'mysql buildmaster +| ifne ssh -o PasswordAuthentication=No buildmaster 'mysql buildmaster rm -f "/tmp/add-those-dependencies" ' |