index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
-rwxr-xr-x | bin/cleanup | 70 |
diff --git a/bin/cleanup b/bin/cleanup index 78daece..c9a8d2b 100755 --- a/bin/cleanup +++ b/bin/cleanup @@ -5,6 +5,8 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" +# TODO: clean database, too + # we only clean if run interactive or if no one is logged in if ! tty -s && \ [ -n "$(users)" ]; then @@ -17,54 +19,24 @@ if [ -s "${work_dir}/build-master-sanity" ]; then exit fi -# remove blocked/broken/locked markes of packages not on the buildlist anymore - -{ - find "${work_dir}/package-states" -maxdepth 1 \( -name '*.broken' -o -name '*.locked' -o -name '*.blocked' \) -printf '%f\n' | \ - sed ' - s|^\(.*\)\.\([^.]\+\)\.\([^.]\+\)\.\([^.]\+\)\.\([^.]\+\)$|state \0 \1 \2 \3 \4 \5| - ' - awk '{ - print "order " $1 "." $2 "." $3 "." $4 " " $1 " " $2 " " $3 " " $4 " broken" - print "order " $1 "." $2 "." $3 "." $4 " " $1 " " $2 " " $3 " " $4 " blocked" - print "order " $1 "." $2 "." $3 "." $4 " " $1 " " $2 " " $3 " " $4 " locked" - }' "${work_dir}/build-list" -} | \ - sort -k3 | \ - uniq -uf2 | \ - grep '^state ' | \ - awk '{print $2}' | \ - sed "s|^|${work_dir}/package-states/|" | \ - xargs -rn1 rm - # remove logs where package is not broken/locked anymore { - find "${build_log_directory}/error" -maxdepth 1 -type f -printf '1 %f %f\n' | \ - sed 's|\.[^. ]\+\.build-log\.gz$||' - find "${work_dir}/package-states" -maxdepth 1 \( \ - -name '*.broken' -o \ - -name '*.done' -o \ - -name '*.locked' -o \ - -name '*.testing' \ - \) -printf '0 0 %f\n' | \ - sed 's|\.[^.]\+$||' + find "${build_log_directory}/error" -maxdepth 1 -type f -printf 'file %f\n' + # shellcheck disable=SC2016 + printf 'SELECT "mysql",`failed_builds`.`log_file` FROM `failed_builds`;\n' | \ + mysql_run_query | \ + tr '\t' ' ' } | \ - sort -k3,3 -k1,2 | \ - uniq --group=prepend -f2 | \ - while read -r num file _; do - if [ "${num}" = '0' ]; then - while read -r line; do - if [ -z "${line}" ]; then - break - fi - done - continue - fi - if [ -z "${num}${file}" ]; then - continue - fi - rm -f "${build_log_directory}/error/${file}" + sort -k2,2 -k1,1 | \ + uniq -uf 1 | \ + sed -n ' + s/^file // + T + p + ' | \ + while read -r file; do + rm "${build_log_directory}/error/${file}" done # only keep 10 newest logs per failed package @@ -97,14 +69,4 @@ find "${build_log_directory}/success" -maxdepth 1 -type f -mtime +14 \ -not -exec zgrep -q '^+.*ELF file .* has text relocations' '{}' \; \ -delete -# remove old package meta data -delete_old_metadata - -# remove dependency graphs of packages on the deletion list -sed ' - s|^|'"${webserver_directory}"'/graphs/| - s|$|.png| -' "${work_dir}/deletion-list" | \ - xargs -rn1 rm -f - exit 0 |