1
1
mirror of https://gitlab.archlinux.org/archlinux/infrastructure.git synced 2025-01-18 08:06:16 +01:00
infrastructure/roles/archbuild/files/clean-chroots
Frederik Schwan e62da2db02
remove distinction between btrfs and non-btrfs FS in clean-chroots
rmdir of subvolumes is supported since 4.18
2020-10-07 16:56:53 +02:00

36 lines
551 B
Bash
Executable File

#!/bin/zsh
setopt extendedglob nomatch errreturn
integer ret=0
cd /var/lib/archbuild
chroots=( */^root(/Nmh+2) )
(( ${#chroots} )) || exit 0
df -HT .
echo "<6>Deleting ${#chroots} chroots"
for chroot in $chroots; do
exec 9>>| $chroot.lock
if ! flock -n 9; then
echo "<5>Not deleting $chroot; in use"
continue
fi
if rm -rf -- $chroot; then
echo "<6>Deleted $chroot"
else
echo "<3>Error deleting $chroot"
ret=1
fi
# We don't remove the lockfile. Less races that way
done
df -HT .
exit $ret
# vim:set sw=2 et: