Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-04-17 13:47:54 +0200
committerErich Eckner <git@eckner.net>2019-04-17 13:47:54 +0200
commit2d3827b12d0eda00f28147905ea579d3d07df02c (patch)
tree56ab7dcf09d180f4b1fc08d88d9abd4167e7edb4
parent254a31c2e10b3b806a3b00137d32acf24af77a44 (diff)
lib/common-functions: recursively_umount_and_rm(): copy stuff from archlinux/devtool's lib/archroot.sh: is_subvolume(), is_same_fs() and subvolume_delete_recursive() - now it should do the correct thing on btrfs, too
-rwxr-xr-xlib/common-functions19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/common-functions b/lib/common-functions
index e87e6ef..17309fb 100755
--- a/lib/common-functions
+++ b/lib/common-functions
@@ -390,10 +390,25 @@ recursively_umount_and_rm() {
exit 42
fi
+ # the sh -c '...' construct branch below is borrowed from
+ # archlinux/devtools lib/archroot.sh: is_subvolume(), is_same_fs() and
+ # subvolume_delete_recursive()
+ # shellcheck disable=SC1004,SC2016
find "${dir}" \
- -xdev -depth -type d \
+ -depth \
+ -xdev \
+ -type d \
-exec 'mountpoint' '-q' '{}' ';' \
- -exec 'sudo' 'umount' '-l' '{}' ';'
+ -exec 'sudo' 'umount' '-l' '{}' ';' \
+ -prune \
+ , \
+ -inum 256 \
+ -exec sh -c '
+ [ "$(stat -f -c %T "$1")" = btrfs ] && \
+ [ "$(stat -c %d "$1")" = "$2" ]
+ ' {} "$(stat -c %d "${dir}")" \; \
+ -exec btrfs subvolume delete {} \; \
+ -prune
rm -rf --one-file-system "${dir}"
}