From a24344e0a705369301942a9d9ac5d3c4a24a8326 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 18 Oct 2017 13:29:43 +0200 Subject: bin/return-assignment, bin/cleanup: sort build logs by success/error. --- bin/cleanup | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'bin/cleanup') diff --git a/bin/cleanup b/bin/cleanup index c8de490..2350702 100755 --- a/bin/cleanup +++ b/bin/cleanup @@ -40,7 +40,7 @@ fi # remove logs where package is not broken/locked anymore ( - find "${build_log_directory}" -maxdepth 1 -printf '%f\n' | \ + find "${build_log_directory}/error" -maxdepth 1 -type f -printf '%f\n' | \ sed 's|\.[^.]\+\.build-log\.gz$||' | \ sort -u find "${work_dir}/package-states" -maxdepth 1 \( -name '*.broken' -o -name '*.locked' \) -printf '%f\n' | \ @@ -53,30 +53,34 @@ fi uniq -u | \ cut -d' ' -f1 | \ while read -r s; do - rm -f "${build_log_directory}/${s}."* + rm -f "${build_log_directory}/error/${s}."* done # only keep 10 newest logs per package -find "${build_log_directory}" -maxdepth 1 -printf '%f\n' | \ - sed 's|^\(.*\)\(\.\([^.]\+\)\.build-log\.gz\)$|\1\2 \3 \1|' | \ - sort -k3,3 -k2r,2 | \ - uniq -f2 --group=prepend | \ - cut -d' ' -f1 | \ - ( - count=0 - while read -r a; do - if [ -z "${a}" ]; then - count=0 - continue - fi - if [ ${count} -ge 10 ]; then - echo "${build_log_directory}/${a}" - fi - count=$((count+1)) - done - ) | \ - xargs -rn1 rm +for sub_dir in 'error' 'success'; do + + find "${build_log_directory}/${sub_dir}" -maxdepth 1 -type f -printf '%f\n' | \ + sed 's|^\(.*\)\(\.\([^.]\+\)\.build-log\.gz\)$|\1\2 \3 \1|' | \ + sort -k3,3 -k2r,2 | \ + uniq -f2 --group=prepend | \ + cut -d' ' -f1 | \ + ( + count=0 + while read -r a; do + if [ -z "${a}" ]; then + count=0 + continue + fi + if [ ${count} -ge 10 ]; then + echo "${build_log_directory}/${sub_dir}/${a}" + fi + count=$((count+1)) + done + ) | \ + xargs -rn1 rm + +done # remove old package meta data delete_old_metadata -- cgit v1.2.3