From 5be25c5f55fd6f5857cc54e9c56c4bdbb682ce39 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com> Date: Fri, 23 Sep 2016 23:34:49 +0200 Subject: [PATCH] archbuild: Make clean scripts a bit more verbose --- roles/archbuild/files/clean-chroots | 19 +++++++++++++------ roles/archbuild/files/clean-dests | 22 ++++++++++++++++++++-- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/roles/archbuild/files/clean-chroots b/roles/archbuild/files/clean-chroots index 85ca394c8..675a911e9 100755 --- a/roles/archbuild/files/clean-chroots +++ b/roles/archbuild/files/clean-chroots @@ -1,13 +1,19 @@ #!/bin/zsh setopt extendedglob nomatch errreturn -integer ret=0 br=0 +integer ret=0 cd /var/lib/archbuild +chroots=( */^root(/Nmh+12) ) +(( ${#chroots} )) || exit 0 + +df -HT . +echo "<6>Deleting ${#chroots} chroots" + if btrfs filesystem df . &>/dev/null; then remove() { - btrfs sub del $1 + btrfs sub del $1 &>/dev/null } else remove() { @@ -15,7 +21,7 @@ else } fi -for chroot in */^root(/Nmh+12); do +for chroot in $chroots; do exec 9>>| $chroot.lock if ! flock -n 9; then @@ -23,9 +29,9 @@ for chroot in */^root(/Nmh+12); do continue fi - echo "<6>Deleting $chroot" - - if ! remove $chroot &>/dev/null; then + if remove $chroot; then + echo "<6>Deleted $chroot" + else echo "<3>Error deleting $chroot" ret=1 fi @@ -33,4 +39,5 @@ for chroot in */^root(/Nmh+12); do # We don't remove the lockfile. Less races that way done +df -HT . exit $ret diff --git a/roles/archbuild/files/clean-dests b/roles/archbuild/files/clean-dests index 2670a8601..5ab14a1b2 100755 --- a/roles/archbuild/files/clean-dests +++ b/roles/archbuild/files/clean-dests @@ -1,6 +1,24 @@ #!/bin/zsh setopt extendedglob nomatch errreturn -cd /var/lib/archbuilddest +integer ret=0 -rm -rf srcdest/*(Na+90) +cd /var/lib/archbuilddest/srcdest + +files=( *(Na+90) ) +(( ${#files} )) || exit 0 + +df -HT . +echo "<6>Deleting ${#files} files" + +for file in $files; do + if rm -rf $file; then + echo "<6>Deleted $file" + else + echo "<3>Error deleting $file" + ret=1 + fi +done + +df -HT . +exit $ret -- GitLab