diff options
Diffstat (limited to 'scripts/install.sh')
-rwxr-xr-x | scripts/install.sh | 143 |
1 files changed, 65 insertions, 78 deletions
diff --git a/scripts/install.sh b/scripts/install.sh index 60c2475a2..1efbaad02 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash #- -# Copyright © 2010-2022 +# Copyright © 2010-2025 # Waldemar Brodkorb <wbx@openadk.org> # Thorsten Glaser <tg@mirbsd.org> # @@ -127,13 +127,6 @@ case $ostype { (Linux) tools="bc mkfs.ext4 mkfs.vfat tune2fs partprobe" ;; -(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. exit 1 @@ -155,7 +148,7 @@ tgt=$2 src=$3 case $target { -(banana-pro|orange-pi0|pcengines-apu|phytec-imx6|phytec-wega|raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi4|raspberry-pi4-64|solidrun-imx6|solidrun-clearfog|default) ;; +(atmel-ngw100|banana-pro|banana-pro-zero|orange-pi0|pcengines-apu|phytec-imx6|phytec-wega|raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi4|raspberry-pi4-64|raspberry-pi5|rockpi4-plus|solidrun-imx6|solidrun-clearfog|imgtec-ci20|default) ;; (*) print -u2 "Unknown target '$target', exiting" exit 1 ;; @@ -171,57 +164,15 @@ fi (( quiet )) || print "Installing $src on $tgt." case $ostype { -(Darwin) - 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 - if [[ $target = raspberry-pi || $target = raspberry-pi0 || $target = raspberry-pi2 || $target = raspberry-pi3 || $target = raspberry-pi3-64 || $target = raspberry-pi4 || $target = raspberry-pi4-64 || $target = phytec-wega ]]; then - bootpart=${basedev}s1 - rootpart=${basedev}s2 - datapart=${basedev}s3 - 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 )) || 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) basedev=$tgt - partitionsep="" + + if [[ "$tgt" == *"nvme0n1"* ]] || [[ "$tgt" == *"mmcblk"* ]]; then + partitionsep="p" + else + partitionsep="" + fi + if [[ $basedev = /dev/loop* ]]; then (( quiet )) || print "${tgt} is a loop device" partitionsep=p @@ -229,7 +180,7 @@ case $ostype { rootpart=${basedev}${partitionsep}1 datapart=${basedev}${partitionsep}2 - if [[ $target = raspberry-pi || $target = raspberry-pi0 || $target = raspberry-pi2 || $target = raspberry-pi3 || $target = raspberry-pi3-64 || $target = raspberry-pi4 || $target = raspberry-pi4-64 ]]; then + if [[ $target = raspberry-pi || $target = raspberry-pi0 || $target = raspberry-pi2 || $target = raspberry-pi3 || $target = raspberry-pi3-64 || $target = raspberry-pi4 || $target = raspberry-pi4-64 || $target = raspberry-pi5 ]]; then bootpart=${basedev}${partitionsep}1 rootpart=${basedev}${partitionsep}2 datapart=${basedev}${partitionsep}3 @@ -271,12 +222,11 @@ if ! T=$(mktemp -d /tmp/openadk.XXXXXXXXXX); then print -u2 Error creating temporary directory. exit 1 fi -if [[ $ostype != Darwin ]]; then - R=$T/rootmnt - B=$T/bootmnt - D=$T/datamnt - mkdir -p "$R" "$B" "$D" -fi + +R=$T/rootmnt +B=$T/bootmnt +D=$T/datamnt +mkdir -p "$R" "$B" "$D" # get disk size dksz=$(dkgetsz "$tgt") @@ -294,7 +244,7 @@ syspartno=0 # data - flexible (parameter) # system - everything else -if [[ $target = raspberry-pi || $target = raspberry-pi0 || $target = raspberry-pi2 || $target = raspberry-pi3 || $target = raspberry-pi3-64 || $target = raspberry-pi4 || $target = raspberry-pi4-64 || $target = phytec-wega ]]; then +if [[ $target = raspberry-pi || $target = raspberry-pi0 || $target = raspberry-pi2 || $target = raspberry-pi3 || $target = raspberry-pi3-64 || $target = raspberry-pi4 || $target = raspberry-pi4-64 || $target = raspberry-pi5 || $target = phytec-wega ]]; then syspartno=1 bootfssz=100 if (( grub )); then @@ -351,7 +301,7 @@ fi #(( partofs = ((coreendsec / secs) + 1) * secs )) # we just use 2048 all the time, since some loaders are longer partofs=2048 -if [[ $target = raspberry-pi || $target = raspberry-pi0 || $target = raspberry-pi2 || $target = raspberry-pi3 || $target = raspberry-pi3-64 || $target = raspberry-pi4 || $target = raspberry-pi4-64 || $target = phytec-wega ]]; then +if [[ $target = raspberry-pi || $target = raspberry-pi0 || $target = raspberry-pi2 || $target = raspberry-pi3 || $target = raspberry-pi3-64 || $target = raspberry-pi4 || $target = raspberry-pi4-64 || $target = raspberry-pi5 || $target = phytec-wega || $target = rockpi4-plus ]]; then (( spartofs = partofs + (100 * 2048) )) else spartofs=$partofs @@ -462,7 +412,7 @@ if (( datafssz )); then dd of="$T/firsttrack" conv=notrunc bs=1 seek=$((0x1CE)) 2>/dev/null fi -if [[ $target = raspberry-pi || $target = raspberry-pi0 || $target = raspberry-pi2 || $target = raspberry-pi3 || $target = raspberry-pi3-64 || $target = raspberry-pi4 || $target = raspberry-pi4-64 || $target = phytec-wega ]]; then +if [[ $target = raspberry-pi || $target = raspberry-pi0 || $target = raspberry-pi2 || $target = raspberry-pi3 || $target = raspberry-pi3-64 || $target = raspberry-pi4 || $target = raspberry-pi4-64 || $target = raspberry-pi5 || $target = phytec-wega ]]; then # move system and data partition from #0/#1 to #1/#2 dd if="$T/firsttrack" bs=1 skip=$((0x1BE)) count=32 of="$T/x" 2>/dev/null dd of="$T/firsttrack" conv=notrunc bs=1 seek=$((0x1CE)) if="$T/x" 2>/dev/null @@ -545,17 +495,25 @@ fi fwdir=$(dirname "$src") case $target { -(banana-pro|orange-pi0) +(rockpi4-plus) + dd if="$fwdir/idbloader.img" of="$tgt" bs=512 seek=64 > /dev/null 2>&1 + dd if="$fwdir/u-boot.itb" of="$tgt" bs=512 seek=16384 > /dev/null 2>&1 + ;; +(imgtec-ci20) + dd if="$fwdir/u-boot-spl.bin" of="$tgt" obs=512 seek=1 > /dev/null 2>&1 + dd if="$fwdir/u-boot-dtb.img" of="$tgt" obs=1k seek=14 > /dev/null 2>&1 + ;; +(banana-pro|banana-pro-zero|orange-pi0) dd if="$fwdir/u-boot-sunxi-with-spl.bin" of="$tgt" bs=1024 seek=8 > /dev/null 2>&1 ;; (solidrun-clearfog) - dd if="$fwdir/u-boot-spl.kwb" of="$tgt" bs=512 seek=1 > /dev/null 2>&1 + dd if="$fwdir/u-boot-with-spl.kwb" of="$tgt" bs=512 seek=1 > /dev/null 2>&1 ;; (solidrun-imx6|phytec-imx6) dd if="$fwdir/SPL" of="$tgt" bs=1024 seek=1 > /dev/null 2>&1 dd if="$fwdir/u-boot.img" of="$tgt" bs=1024 seek=69 > /dev/null 2>&1 ;; -(raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi4|raspberry-pi4-64) +(raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi4|raspberry-pi4-64|raspberry-pi5) (( noformat )) || create_fs "$bootpart" ADKBOOT vfat ;; (phytec-wega) @@ -563,22 +521,29 @@ case $target { ;; } -(( noformat )) || create_fs "$rootpart" ADKROOT ext4 -(( noformat )) || tune_fs "$rootpart" +case $target { +(atmel-ngw100) + (( noformat )) || create_fs "$rootpart" ADKROOT ext2 + (( noformat )) || tune_fs "$rootpart" + ;; +(*) + (( noformat )) || create_fs "$rootpart" ADKROOT ext4 + (( noformat )) || tune_fs "$rootpart" +} (( quiet )) || print Extracting installation archive... mount_fs "$rootpart" "$R" ext4 -xz -dc "$src" | (cd "$R"; tar -xpf -) +gzip -dc "$src" | (cd "$R"; tar -xpf -) if (( datafssz )); then mkdir -m0755 "$R"/data ((keep)) || create_fs "$datapart" ADKDATA ext4 ((keep)) || tune_fs "$datapart" case $target { - (raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi4|raspberry-pi4-64|phytec-wega) + (raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi4|raspberry-pi4-64|raspberry-pi5|phytec-wega) echo "/dev/mmcblk0p3 /data ext4 rw 0 0" >> "$R"/etc/fstab ;; - (banana-pro|orange-pi0|solidrun-clearfog) + (banana-pro|orange-pi0|solidrun-clearfog|rockpi4-plus) echo "/dev/mmcblk0p2 /data ext4 rw 0 0" >> "$R"/etc/fstab ;; (solidrun-imx6|phytec-imx6) @@ -597,7 +562,7 @@ fi (( quiet )) || print Finishing up with bootloader and kernel ... case $target { -(raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi4|raspberry-pi4-64) +(raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi4|raspberry-pi4-64|raspberry-pi5) mount_fs "$bootpart" "$B" vfat for x in "$R"/boot/*; do [[ -e "$x" ]] && mv -f "$R"/boot/* "$B/" @@ -611,7 +576,11 @@ case $target { mkdir "$B/"overlays for x in "$fwdir"/overlays/*.dtbo; do y=$(basename ${x} .dtbo) - [[ -e "$x" ]] && cp "$fwdir"/overlays/${y}.dtbo "$B/"overlays/${y}.dtb + [[ -e "$x" ]] && cp "$fwdir"/overlays/${y}.dtbo "$B/"overlays/${y}.dtbo + done + for x in "$fwdir"/overlays/*.dtb; do + y=$(basename ${x} .dtb) + [[ -e "$x" ]] && cp "$fwdir"/overlays/${y}.dtb "$B/"overlays/${y}.dtb done umount_fs "$B" ;; @@ -627,6 +596,15 @@ case $target { done umount_fs "$B" ;; +(rockpi4-plus) + for x in "$fwdir"/*.dtb; do + [[ -e "$x" ]] && cp "$fwdir"/*.dtb "$R/boot/" + break + done + mkimage -A arm64 -O linux -T script -C none -a 0 -e 0 \ + -n "RockPI4-Plus" \ + -d $fwdir/boot.script.rockpi4 $R/boot/boot.scr.uimg + ;; (solidrun-clearfog) for x in "$fwdir"/*.dtb; do [[ -e "$x" ]] && cp "$fwdir"/*.dtb "$R/boot/" @@ -672,6 +650,15 @@ case $target { -n "BananaPro" \ -d $fwdir/boot.script.bpi $R/boot/boot.scr.uimg ;; +(banana-pro-zero) + for x in "$fwdir"/*.dtb; do + [[ -e "$x" ]] && cp "$fwdir"/*.dtb "$R/boot/" + break + done + mkimage -A arm -O linux -T script -C none -a 0 -e 0 \ + -n "BananaProZero" \ + -d $fwdir/boot.script.bpizero $R/boot/boot.scr.uimg + ;; } cd "$R" |