summaryrefslogtreecommitdiff
path: root/Meta/build-image-qemu.sh
diff options
context:
space:
mode:
authorEric Butler <eric@level.com>2021-05-09 08:39:21 -0400
committerAndreas Kling <kling@serenityos.org>2021-05-09 15:34:12 +0200
commit1a48609c6bcf7b041ef3811585e1c1ab58652394 (patch)
treeb31eba06c8920ab0d694f132f4bdf708f44e6a3c /Meta/build-image-qemu.sh
parente0fe38ea25eeb02b915a28e599bb7000584e264f (diff)
downloadserenity-1a48609c6bcf7b041ef3811585e1c1ab58652394.zip
Meta: Always try genext2fs as fallback to build disk image
If mounting disk image fails (e.g. fuse is not available on macos), always try using genext2fs before giving up.
Diffstat (limited to 'Meta/build-image-qemu.sh')
-rwxr-xr-xMeta/build-image-qemu.sh30
1 files changed, 14 insertions, 16 deletions
diff --git a/Meta/build-image-qemu.sh b/Meta/build-image-qemu.sh
index bd783f10dd..9e0ae43143 100755
--- a/Meta/build-image-qemu.sh
+++ b/Meta/build-image-qemu.sh
@@ -87,25 +87,23 @@ printf "mounting filesystem... "
mkdir -p mnt
use_genext2fs=0
if [ "$(uname -s)" = "Darwin" ]; then
- fuse-ext2 _disk_image mnt -o rw+,allow_other,uid=501,gid=20 || die "could not mount filesystem"
- echo "done"
+ mount_cmd="fuse-ext2 _disk_image mnt -o rw+,allow_other,uid=501,gid=20"
elif [ "$(uname -s)" = "OpenBSD" ]; then
- mount -t ext2fs "/dev/${VND}i" mnt/ || die "could not mount filesystem"
- echo "done"
+ mount_cmd="mount -t ext2fs "/dev/${VND}i" mnt/"
elif [ "$(uname -s)" = "FreeBSD" ]; then
- fuse-ext2 -o rw+,direct_io "/dev/${MD}" mnt/ || die "could not mount filesystem"
- echo "done"
+ mount_cmd="fuse-ext2 -o rw+,direct_io "/dev/${MD}" mnt/"
else
- if ! mount _disk_image mnt/ ; then
- if command -v genext2fs 1>/dev/null ; then
- echo "mount failed but genext2fs exists, use it instead"
- use_genext2fs=1
- else
- die "could not mount filesystem and genext2fs is missing"
- fi
- else
- echo "done"
- fi
+ mount_cmd="mount _disk_image mnt/"
+fi
+if ! eval "$mount_cmd"; then
+ if command -v genext2fs 1>/dev/null ; then
+ echo "mount failed but genext2fs exists, use it instead"
+ use_genext2fs=1
+ else
+ die "could not mount filesystem and genext2fs is missing"
+ fi
+else
+ echo "done"
fi
cleanup() {