summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/cleanup38
1 files changed, 14 insertions, 24 deletions
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