summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archbuild.in2
-rw-r--r--lib/archroot.sh8
-rw-r--r--makechrootpkg.in7
-rw-r--r--mkarchroot.in2
4 files changed, 12 insertions, 7 deletions
diff --git a/archbuild.in b/archbuild.in
index 4fb33c3..b192788 100644
--- a/archbuild.in
+++ b/archbuild.in
@@ -52,7 +52,7 @@ if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then
lock 9 "$copy.lock" "Locking chroot copy '$copy'"
- if [[ "$(stat -f -c %T "${copy}")" == btrfs ]]; then
+ if is_btrfs "${copy}"; then
{ type -P btrfs && btrfs subvolume delete "${copy}"; } &>/dev/null
fi
rm -rf --one-file-system "${copy}"
diff --git a/lib/archroot.sh b/lib/archroot.sh
index 7d7ab67..14417aa 100644
--- a/lib/archroot.sh
+++ b/lib/archroot.sh
@@ -12,3 +12,11 @@ check_root() {
exec su root -c "$(printf ' %q' "${orig_argv[@]}")"
fi
}
+
+##
+# usage : is_btrfs( $path )
+# return : whether $path is on a btrfs
+##
+is_btrfs() {
+ [[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs ]]
+}
diff --git a/makechrootpkg.in b/makechrootpkg.in
index 695b898..9e84996 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -96,7 +96,7 @@ create_chroot() {
slock 8 "$chrootdir/root.lock" "Locking clean chroot"
stat_busy "Creating clean working copy [$copy]"
- if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then
+ if is_btrfs "$chrootdir" && ! mountpoint -q "$copydir"; then
if [[ -d $copydir ]]; then
btrfs subvolume delete "$copydir" >/dev/null ||
die "Unable to delete subvolume %s" "$copydir"
@@ -119,7 +119,7 @@ create_chroot() {
clean_temporary() {
stat_busy "Removing temporary copy [$copy]"
- if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then
+ if is_btrfs "$chrootdir" && ! mountpoint -q "$copydir"; then
btrfs subvolume delete "$copydir" >/dev/null ||
die "Unable to delete subvolume %s" "$copydir"
else
@@ -285,9 +285,6 @@ chrootdir=$(readlink -e "$passeddir")
[[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir"
[[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir"
-# Detect chrootdir filesystem type
-chroottype=$(stat -f -c %T "$chrootdir")
-
if [[ ${copy:0:1} = / ]]; then
copydir=$copy
else
diff --git a/mkarchroot.in b/mkarchroot.in
index 010de3c..3d7e396 100644
--- a/mkarchroot.in
+++ b/mkarchroot.in
@@ -57,7 +57,7 @@ mkdir -p "$working_dir"
lock 9 "${working_dir}.lock" "Locking chroot"
-if [[ $(stat -f -c %T "$working_dir") == btrfs ]]; then
+if is_btrfs "$working_dir"; then
rmdir "$working_dir"
if ! btrfs subvolume create "$working_dir"; then
die "Couldn't create subvolume for '%s'" "$working_dir"