summaryrefslogtreecommitdiff
path: root/bin/cleanup
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-08-23 21:35:06 +0200
committerErich Eckner <git@eckner.net>2017-08-23 21:35:06 +0200
commit395c60b1ce1c8bc84746ecfefba21d3234b288fa (patch)
tree7b5ef1ec650e6948714c358ba8338fcc75a4567f /bin/cleanup
parentd44c45606f6289889cb0f5c12ab5bed61d65330d (diff)
downloadbuilder-395c60b1ce1c8bc84746ecfefba21d3234b288fa.tar.xz
silence a lot shellcheck warnings
Diffstat (limited to 'bin/cleanup')
-rwxr-xr-xbin/cleanup19
1 files changed, 10 insertions, 9 deletions
diff --git a/bin/cleanup b/bin/cleanup
index 93af0bc..c8de490 100755
--- a/bin/cleanup
+++ b/bin/cleanup
@@ -2,6 +2,7 @@
# clean up unnecessary data
+# shellcheck source=conf/default.conf
. "${0%/*}/../conf/default.conf"
# we only clean if run interactive or if no one is logged in
@@ -19,8 +20,7 @@ fi
# remove blocked/broken/locked markes of packages not on the buildlist anymore
(
- ls "${work_dir}/package-states" | \
- grep '\.broken$\|\.b\?locked$' | \
+ find "${work_dir}/package-states" -maxdepth 1 \( -name '*.broken' -o -name '*.locked' -o -name '*.blocked' \) -printf '%f\n' | \
sed '
s|^\(.*\)\.\([^.]\+\)\.\([^.]\+\)\.\([^.]\+\)\.\([^.]\+\)$|state \0 \1 \2 \3 \4 \5|
'
@@ -40,11 +40,10 @@ fi
# remove logs where package is not broken/locked anymore
(
- ls "${build_log_directory}" | \
+ find "${build_log_directory}" -maxdepth 1 -printf '%f\n' | \
sed 's|\.[^.]\+\.build-log\.gz$||' | \
sort -u
- ls "${work_dir}/package-states" | \
- grep '\.broken$\|\.locked$' | \
+ find "${work_dir}/package-states" -maxdepth 1 \( -name '*.broken' -o -name '*.locked' \) -printf '%f\n' | \
sed '
s|\.[^.]\+$||
p
@@ -52,19 +51,21 @@ fi
) | \
sort | \
uniq -u | \
- while read -r s t; do
+ cut -d' ' -f1 | \
+ while read -r s; do
rm -f "${build_log_directory}/${s}."*
done
# only keep 10 newest logs per package
-ls "${build_log_directory}" | \
+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 b c; do
+ while read -r a; do
if [ -z "${a}" ]; then
count=0
continue
@@ -72,7 +73,7 @@ ls "${build_log_directory}" | \
if [ ${count} -ge 10 ]; then
echo "${build_log_directory}/${a}"
fi
- count=$((${count}+1))
+ count=$((count+1))
done
) | \
xargs -rn1 rm