summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-03-22 14:36:52 +0100
committerErich Eckner <git@eckner.net>2018-03-22 14:36:52 +0100
commit89841624b9eff687dec43c43efba1b5fd54c789e (patch)
tree24f3c5027fcc95b59497f95f652651f6c7911be4 /bin
parent4f5f0fafc4be959a9a05adac8bf5162a7c5bab46 (diff)
downloadbuilder-89841624b9eff687dec43c43efba1b5fd54c789e.tar.xz
bin/cleanup: take info about "recent" logfiles from database
Diffstat (limited to 'bin')
-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