ubuntu: Check that btrfs is actually available

Before calling btrfs and playing with subvolumes, let's make sure the btrfs command is available. Signed-off-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent b91f00d3
...@@ -63,7 +63,7 @@ try_mksubvolume() ...@@ -63,7 +63,7 @@ try_mksubvolume()
path=$1 path=$1
[ -d $path ] && return 0 [ -d $path ] && return 0
mkdir -p $(dirname $path) mkdir -p $(dirname $path)
if is_btrfs $(dirname $path); then if which btrfs >/dev/null 2>&1 && is_btrfs $(dirname $path); then
btrfs subvolume create $path btrfs subvolume create $path
else else
mkdir -p $path mkdir -p $path
...@@ -74,7 +74,7 @@ try_rmsubvolume() ...@@ -74,7 +74,7 @@ try_rmsubvolume()
{ {
path=$1 path=$1
[ -d $path ] || return 0 [ -d $path ] || return 0
if is_btrfs_subvolume $path; then if which btrfs >/dev/null 2>&1 && is_btrfs_subvolume $path; then
btrfs subvolume delete $path btrfs subvolume delete $path
else else
rm -rf $path rm -rf $path
...@@ -406,7 +406,7 @@ copy_ubuntu() ...@@ -406,7 +406,7 @@ copy_ubuntu()
# make a local copy of the miniubuntu # make a local copy of the miniubuntu
echo "Copying rootfs to $rootfs ..." echo "Copying rootfs to $rootfs ..."
try_mksubvolume $rootfs try_mksubvolume $rootfs
if is_btrfs_subvolume $cache/rootfs-$arch && is_btrfs_subvolume $rootfs; then if which btrfs >/dev/null 2>&1 && is_btrfs_subvolume $cache/rootfs-$arch && is_btrfs_subvolume $rootfs; then
realrootfs=$(dirname $config)/rootfs realrootfs=$(dirname $config)/rootfs
[ "$rootfs" = "$realrootfs" ] || umount $rootfs || return 1 [ "$rootfs" = "$realrootfs" ] || umount $rootfs || return 1
btrfs subvolume delete $realrootfs || return 1 btrfs subvolume delete $realrootfs || return 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment