summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-11-26 20:36:17 +0100
committerErich Eckner <git@eckner.net>2017-11-26 20:36:17 +0100
commit9de220fb31da37c3f7de160e466a44c98dfa03c9 (patch)
treeb2b1cc1b029252d9376c369a9653d928671fb6f0 /bin
parent3d73461f75988701413e7f3d713117482c9d3bbb (diff)
downloadbuilder-9de220fb31da37c3f7de160e466a44c98dfa03c9.tar.xz
bin/cleanup: delete error logs more exactly
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cleanup35
1 files changed, 19 insertions, 16 deletions
diff --git a/bin/cleanup b/bin/cleanup
index e342873..ff4247c 100755
--- a/bin/cleanup
+++ b/bin/cleanup
@@ -39,29 +39,32 @@ fi
# remove logs where package is not broken/locked anymore
-# TODO: be a little more secure on deleting stuff (deleting "a.*" also deletes "a.b.*",
-# so removing logs of "a" will also remove logs of "a.b".
-
{
- find "${build_log_directory}/error" -maxdepth 1 -type f -printf '%f\n' | \
- sed 's|\.[^.]\+\.build-log\.gz$||' | \
- sort -u
+ 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 '%f\n' | \
- sed '
- s|\.[^.]\+$||
- p
- '
+ \) -printf '0 0 %f\n' | \
+ sed 's|\.[^.]\+$||'
} | \
- sort | \
- uniq -u | \
- cut -d' ' -f1 | \
- while read -r s; do
- rm -f "${build_log_directory}/error/${s}."*
+ 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}"
done
# only keep 10 newest logs per failed package