From b161aaf30ce2570a565247380c3f20daadc40fa0 Mon Sep 17 00:00:00 2001 From: Tom Deblauwe Date: Tue, 14 Nov 2017 22:12:18 +0100 Subject: scripts: support fuse_ext2 to write ext4 on Darwin systems --- scripts/install.sh | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/install.sh b/scripts/install.sh index e843e66a4..b1969ed46 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -63,6 +63,7 @@ speed=115200 panicreboot=10 keep=0 grub=0 +paragon_ext=0 function usage { cat >&2 < 16 )); then print -u2 "$me: -c $OPTARG out of bounds" @@ -86,6 +87,7 @@ while getopts "c:d:f:ghknp:qs:t" ch; do print -u2 "$me: -d $OPTARG out of bounds" exit 1 fi ;; + (e) paragon_ext=1 ;; (f) if [[ $OPTARG != @(ext2|ext3|ext4|xfs) ]]; then print -u2 "$me: filesystem $OPTARG invalid" exit 1 @@ -122,6 +124,10 @@ case $ostype { ;; (Darwin) tools="bc diskutil" + if [[ $paragon_ext == 0 ]]; then + export PATH=/usr/local/opt/e2fsprogs/sbin:/usr/local/opt/e2fsprogs/bin:$PATH + tools="$tools fuse-ext2 umount mkfs.ext4 tune2fs" + fi ;; (*) print -u2 Sorry, not ported to the OS "'$ostype'" yet. @@ -161,9 +167,9 @@ fi case $ostype { (Darwin) - R=/Volumes/ADKROOT; diskutil unmount $R - B=/Volumes/ADKBOOT; diskutil unmount $B - D=/Volumes/ADKDATA; diskutil unmount $D + R=/Volumes/ADKROOT; diskutil unmount $R || umount $R + B=/Volumes/ADKBOOT; diskutil unmount $B || umount $B + D=/Volumes/ADKDATA; diskutil unmount $D || umount $D basedev=$tgt rootpart=${basedev}s1 datapart=${basedev}s2 @@ -174,22 +180,38 @@ case $ostype { fi match=\'${basedev}\''?(s+([0-9]))' function mount_fs { + if [[ $paragon_ext == 0 && $3 = ext4 ]]; then + mkdir -p $2 + fuse-ext2 "$1" "$2" -o rw+ + fi } function umount_fs { (( quiet )) || print "Unmounting filesystem on ${1}..." + if [[ $paragon_ext == 0 ]]; then + umount "$1" || diskutil unmount "$1" || true + rmdir $2 || true + else diskutil unmount "$1" + fi } function create_fs { - (( quiet )) || print "Creating filesystem on ${2}..." - if [[ $3 = ext4 ]]; then - fstype=UFSD_EXTFS4 - fi - if [[ $3 = vfat ]]; then - fstype=fat32 - fi - diskutil eraseVolume $fstype "$2" "$1" + (( quiet )) || printf "Creating filesystem on ${1}" + if [[ $paragon_ext == 0 && $3 = ext4 ]]; then + mkfs.ext4 -L "$2" "$1" + else + if [[ $3 = ext4 ]]; then + fstype=UFSD_EXTFS4 + fi + if [[ $3 = vfat ]]; then + fstype=fat32 + fi + diskutil eraseVolume $fstype "$2" "$1" + fi } function tune_fs { + if [[ $paragon_ext == 0 && $3 = ext4 ]]; then + tune2fs -c 0 -i 0 "$1" + fi } ;; (Linux) -- cgit v1.2.3