Some packages end up creating subvolumes through systemd-tmpfiles, (e.g.
systemd-nspawn,) so we need to delete those as well, but there's no way
to reliably list subvolumes under a certain subvolume relative to the
filesystem, so we need a hard-coded list.

Signed-off-by: Johannes Löthberg <johan...@kyriasis.com>
---
 archbuild.in     | 7 ++++++-
 makechrootpkg.in | 5 +++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/archbuild.in b/archbuild.in
index 9c5d706..d78ad09 100644
--- a/archbuild.in
+++ b/archbuild.in
@@ -54,7 +54,12 @@ if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" 
]]; then
                lock 9 "$copy.lock" "Locking chroot copy '$copy'"
 
                if [[ "$(stat -f -c %T "${copy}")" == btrfs ]]; then
-                       { type -P btrfs && btrfs subvolume delete "${copy}"; } 
&>/dev/null
+                       if type -P btrfs &>/dev/null; then
+                               if [[ -d "$copy/var/lib/machines" ]]; then
+                                       btrfs subvolume delete 
"$copy/var/lib/machies" &>/dev/null
+                               fi
+
+                               btrfs subvolume delete "$copy" &>/dev/null
+                       fi
                fi
                rm -rf --one-file-system "${copy}"
        done
diff --git a/makechrootpkg.in b/makechrootpkg.in
index 284d444..9612e7d 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -91,6 +91,11 @@ create_chroot() {
                stat_busy "Creating clean working copy [$copy]"
                if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; 
then
                        if [[ -d $copydir ]]; then
+                               if [[ -d "$copydir/var/lib/machines" ]]; then
+                                       btrfs subvolume delete 
"$copydir/var/lib/machies" &>/dev/null ||
+                                               die "Unable to delete subvolume 
%s" "$copydir/var/lib/machines"
+                               fi
+
                                btrfs subvolume delete "$copydir" >/dev/null ||
                                        die "Unable to delete subvolume %s" 
"$copydir"
                        fi
-- 
2.11.0

Reply via email to