index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2017-11-26 20:36:17 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2017-11-26 20:36:17 +0100 |
commit | 9de220fb31da37c3f7de160e466a44c98dfa03c9 (patch) | |
tree | b2b1cc1b029252d9376c369a9653d928671fb6f0 | |
parent | 3d73461f75988701413e7f3d713117482c9d3bbb (diff) |
-rwxr-xr-x | bin/cleanup | 35 |
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 |