diff options
author | Tom Deblauwe <deblauwetom@gmail.com> | 2017-11-14 22:12:18 +0100 |
---|---|---|
committer | Tom Deblauwe <deblauwetom@gmail.com> | 2017-11-14 22:12:18 +0100 |
commit | b161aaf30ce2570a565247380c3f20daadc40fa0 (patch) | |
tree | 3f5fc224a3c1b920bb3ecc9d21ef93aae0b61b9b | |
parent | 1a25210690d4b53fa95e3c9ff288af9f1f71a4ce (diff) |
scripts: support fuse_ext2 to write ext4 on Darwin systems
-rwxr-xr-x | scripts/install.sh | 46 |
1 files changed, 34 insertions, 12 deletions
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 <<EOF @@ -76,7 +77,7 @@ EOF exit $1 } -while getopts "c:d:f:ghknp:qs:t" ch; do +while getopts "c:d:ef:ghknp:qs:t" ch; do case $ch { (c) if (( (cfgfs = OPTARG) < 0 || cfgfs > 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) |