index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
-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 |