Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-06-26 10:01:23 +0200
committerErich Eckner <git@eckner.net>2017-06-26 10:01:23 +0200
commitd225f3c81759e3cd7f31ca66634aae5581ed2e94 (patch)
tree654a207c4c97bc1eb408c1074df7f75e7e7c4ad5 /bin
parent31fb98113f42030828f800a0867948e92975d327 (diff)
bin/cleanup: remove all but the 10 newest build logs per package
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cleanup27
1 files changed, 25 insertions, 2 deletions
diff --git a/bin/cleanup b/bin/cleanup
index e58fe9d..4d827ee 100755
--- a/bin/cleanup
+++ b/bin/cleanup
@@ -9,8 +9,10 @@ if ! "${base_dir}/bin/sanity-check" -r; then
exit 1
fi
+# remove logs where package is not broken/locked anymore
+
(
- ls '/srv/http/build-logs' | \
+ ls "${build_log_directory}" | \
sed 's|\.[^.]\+\.build-log\.gz$||' | \
sort -u
ls "${work_dir}/package-states" | \
@@ -23,5 +25,26 @@ fi
sort | \
uniq -u | \
while read -r s t; do
- rm -f "/srv/http/build-logs/${s}."*
+ rm -f "${build_log_directory}/${s}."*
done
+
+# only keep 10 newest logs per package
+
+ls "${build_log_directory}" | \
+ sed 's|^\(.*\)\(\.\([^.]\+\)\.build-log\.gz\)$|\1\2 \3 \1|' | \
+ sort -k3,3 -k2r,2 | \
+ uniq -f2 --group=prepend | \
+ (
+ count=0
+ while read -r a b c; 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