[arch-projects] [devtools] [PATCH] archbuild/makechrootpkg: Delete sub-subvolumes as well
Johannes Löthberg
johannes at kyriasis.com
Sat Jan 28 17:18:29 UTC 2017
Some packages end up creating subvolumes through systemd-tmpfiles, (e.g.
systemd-nspawn,) so we need to delete those as well.
Signed-off-by: Johannes Löthberg <johannes at kyriasis.com>
---
archbuild.in | 10 +++++++++-
makechrootpkg.in | 5 +++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/archbuild.in b/archbuild.in
index 9c5d706..159602b 100644
--- a/archbuild.in
+++ b/archbuild.in
@@ -54,7 +54,15 @@ 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
+ # Delete all subvolumes under the copy directory. This is needed
+ # because some things, like systemd-nspawn, end up creating a btrfs
+ # subvolume through systemd-tmpfiles.
+ if type -P btrfs &>/dev/null; then
+ btrfs subvolume list --sort=-path -o "$copy" | \
+ sed 's|[^/]*||' | \
+ xargs btrfs subvolume delete &>/dev/null
+
+ 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..b89f33e 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
+ btrfs subvolume list --sort=-path -o "$copydir" | \
+ sed 's|[^/]*||' | \
+ xargs btrfs subvolume delete >/dev/null ||
+ die "Unable to delete subvolumes under %s" "$copydir"
+
btrfs subvolume delete "$copydir" >/dev/null ||
die "Unable to delete subvolume %s" "$copydir"
fi
--
2.11.0
More information about the arch-projects
mailing list