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>
This commit is contained in:
parent
b807c51102
commit
0c62649b64
|
@ -77,6 +77,9 @@ done
|
||||||
# Canonicalize chrootdir, getting rid of trailing /
|
# Canonicalize chrootdir, getting rid of trailing /
|
||||||
chrootdir=$(readlink -e "$passeddir")
|
chrootdir=$(readlink -e "$passeddir")
|
||||||
|
|
||||||
|
# Detect chrootdir filesystem type
|
||||||
|
chroottype=$(stat -f -c %T "$chrootdir")
|
||||||
|
|
||||||
if [[ ${copy:0:1} = / ]]; then
|
if [[ ${copy:0:1} = / ]]; then
|
||||||
copydir=$copy
|
copydir=$copy
|
||||||
else
|
else
|
||||||
|
@ -134,16 +137,14 @@ if [[ ! -d $copydir ]] || $clean_first; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
stat_busy "Creating clean working copy [$copy]"
|
stat_busy "Creating clean working copy [$copy]"
|
||||||
use_rsync=false
|
if [[ "$chroottype" == btrfs ]]; then
|
||||||
if type -P btrfs >/dev/null; then
|
if [[ -d $copydir ]]; then
|
||||||
[[ -d $copydir ]] && btrfs subvolume delete "$copydir" &>/dev/null
|
btrfs subvolume delete "$copydir" >/dev/null ||
|
||||||
btrfs subvolume snapshot "$chrootdir/root" "$copydir" &>/dev/null ||
|
die "Unable to delete subvolume $copydir"
|
||||||
use_rsync=true
|
fi
|
||||||
|
btrfs subvolume snapshot "$chrootdir/root" "$copydir" >/dev/null ||
|
||||||
|
die "Unable to create subvolume $copydir"
|
||||||
else
|
else
|
||||||
use_rsync=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $use_rsync; then
|
|
||||||
mkdir -p "$copydir"
|
mkdir -p "$copydir"
|
||||||
rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir"
|
rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue