summaryrefslogtreecommitdiff
path: root/bin/cleanup
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-10-18 13:29:43 +0200
committerErich Eckner <git@eckner.net>2017-10-18 13:29:43 +0200
commita24344e0a705369301942a9d9ac5d3c4a24a8326 (patch)
treefb362b252f89d2d7954b818782b2c7ab7d9755d6 /bin/cleanup
parent43a932816ed014e193d91c04a6d355baa6deb41d (diff)
downloadbuilder-a24344e0a705369301942a9d9ac5d3c4a24a8326.tar.xz
bin/return-assignment, bin/cleanup: sort build logs by success/error.
Diffstat (limited to 'bin/cleanup')
-rwxr-xr-xbin/cleanup46
1 files changed, 25 insertions, 21 deletions
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