From 89841624b9eff687dec43c43efba1b5fd54c789e Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 22 Mar 2018 14:36:52 +0100 Subject: bin/cleanup: take info about "recent" logfiles from database --- bin/cleanup | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) (limited to 'bin/cleanup') diff --git a/bin/cleanup b/bin/cleanup index 02ac98b..a0bf790 100755 --- a/bin/cleanup +++ b/bin/cleanup @@ -42,31 +42,21 @@ fi # 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 -- cgit v1.2.3-70-g09d2