summaryrefslogtreecommitdiff
path: root/makechrootpkg.in
diff options
context:
space:
mode:
authorSébastien Luttringer <seblu@seblu.net>2013-03-02 05:21:10 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-03-10 10:33:58 +0100
commit0c62649b64b5da227593d951ae252bfc2cd894a4 (patch)
tree3f9a2e365faf3e1e61eada2a99c57a1af66e4a9d /makechrootpkg.in
parentb807c51102685bc07f39216ecbff5570a250feff (diff)
downloaddevtools32-0c62649b64b5da227593d951ae252bfc2cd894a4.tar.xz
makechrootpkg: Properly detect filesystem type
Enable btrfs features only if the underlying filesystem is btrfs and not rely on the presence of the btrfs tools. Signed-off-by: Sébastien Luttringer <seblu@seblu.net> Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
Diffstat (limited to 'makechrootpkg.in')
-rw-r--r--makechrootpkg.in19
1 files changed, 10 insertions, 9 deletions
diff --git a/makechrootpkg.in b/makechrootpkg.in
index ed8ab88..c8b5f87 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -77,6 +77,9 @@ done
# Canonicalize chrootdir, getting rid of trailing /
chrootdir=$(readlink -e "$passeddir")
+# Detect chrootdir filesystem type
+chroottype=$(stat -f -c %T "$chrootdir")
+
if [[ ${copy:0:1} = / ]]; then
copydir=$copy
else
@@ -134,16 +137,14 @@ if [[ ! -d $copydir ]] || $clean_first; then
fi
stat_busy "Creating clean working copy [$copy]"
- use_rsync=false
- if type -P btrfs >/dev/null; then
- [[ -d $copydir ]] && btrfs subvolume delete "$copydir" &>/dev/null
- btrfs subvolume snapshot "$chrootdir/root" "$copydir" &>/dev/null ||
- use_rsync=true
+ if [[ "$chroottype" == btrfs ]]; then
+ if [[ -d $copydir ]]; then
+ btrfs subvolume delete "$copydir" >/dev/null ||
+ die "Unable to delete subvolume $copydir"
+ fi
+ btrfs subvolume snapshot "$chrootdir/root" "$copydir" >/dev/null ||
+ die "Unable to create subvolume $copydir"
else
- use_rsync=true
- fi
-
- if $use_rsync; then
mkdir -p "$copydir"
rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir"
fi