wok-6.x rev 23951
taziso/bootusbkey: up to 2TB
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Sep 21 09:52:25 2020 +0000 (2020-09-21) |
parents | 1a30965ea03c |
children | ecbe8682cfda |
files | syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/taziso |
line diff
1.1 --- a/syslinux/stuff/iso2exe/init Sun Sep 20 21:21:51 2020 +0000 1.2 +++ b/syslinux/stuff/iso2exe/init Mon Sep 21 09:52:25 2020 +0000 1.3 @@ -35,7 +35,9 @@ 1.4 getiso() 1.5 { 1.6 mkdir -p $media 1.7 - for dev in /sys/block/?d?/?d??*; do 1.8 + for dev in /sys/block/*; do 1.9 + dev=$(ls $dev/$(basename $dev)* 2> /dev/null) 1.10 + [ "$dev" ] || continue 1.11 mount /dev/$(basename $dev) $mnt 1.12 if checkmagic $mnt/$ISO; then 1.13 mount -o loop,ro $mnt/$ISO $media 1.14 @@ -52,7 +54,7 @@ 1.15 uncpio64() 1.16 { 1.17 i=$1 1.18 - sed 's|$| |' /proc/cpuinfo | grep ' lm ' && [ -s ${i}64 ] && i=${i}64 1.19 + grep ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64 1.20 [ -s "$i" ] || return 1.21 echo -en "\n Extracting $(basename $i) ..." 1.22 case $(get 0 $i) in 1.23 @@ -93,7 +95,8 @@ 1.24 losetup -o 124 /dev/loop6 $(ls -r $media/boot/rootfs?*.* | sed q) 1.25 mount -r /dev/loop6 /sqfs 1.26 fi 1.27 - cp -a /sqfs/dev/fuse /sqfs/dev/tty[12] /sqfs/dev/[hs]d* /dev 1.28 + cp -a /sqfs/dev/fuse /sqfs/dev/tty[12] /dev 1.29 + for i in /sqfs/dev/* ; do [ -b $i ] && cp -a $i /dev ; done 1.30 ln -s /sqfs/lib/* lib 2>/dev/null 1.31 ln -fs /sqfs/usr /sqfs/var / 1.32 mkdir /etc && cp /sqfs/etc/dialogrc /etc 2>/dev/null 1.33 @@ -167,16 +170,6 @@ 1.34 kexec -e 1.35 } 1.36 1.37 -runmemtest() 1.38 -{ 1.39 - gotcdfile "memtest*" && dokexec 1.40 -} 1.41 - 1.42 -runpxe() 1.43 -{ 1.44 - gotcdfile "?pxe*" && dokexec 1.45 -} 1.46 - 1.47 shell() 1.48 { 1.49 trap text 2 1.50 @@ -187,6 +180,7 @@ 1.51 [ -x /usr/s$BIN ] || mv /bin/mount.posixovl.iso2exe \ 1.52 /usr/s$BIN 2>/dev/null || mv /bin/mount.posixovl.iso2exe /$BIN 2>/dev/null 1.53 mount_proc 1.54 +mdev -s 2> /dev/null || 1.55 for i in /sys/block/*/dev /sys/block/*/*/dev; do 1.56 [ -s "$i" ] || continue 1.57 n=${i%/dev}
2.1 --- a/syslinux/stuff/iso2exe/taziso Sun Sep 20 21:21:51 2020 +0000 2.2 +++ b/syslinux/stuff/iso2exe/taziso Mon Sep 21 09:52:25 2020 +0000 2.3 @@ -33,7 +33,7 @@ 2.4 done | xargs echo -en 2.5 } 2.6 2.7 -word32s2bin() 2.8 +quads2bin() 2.9 { 2.10 for i in $@ ; do 2.11 printf '\\\\x%02X\\\\x%02X\\\\x%02X\\\\x%02X' $(($i&255)) \ 2.12 @@ -41,17 +41,6 @@ 2.13 done | xargs echo -en 2.14 } 2.15 2.16 -word64s2bin() 2.17 -{ 2.18 - for i in $@ ; do 2.19 -# printf '\\\\x%02X\\\\x%02X\\\\x%02X\\\\x%02X\\\\x%02X\\\\x%02X\\\\x%02X\\\\x%02X' \ 2.20 -# $(($i&255)) $((($i>>8)&255)) $((($i>>16)&255)) $((($i>>24)&255)) \ 2.21 -# $((($i>>32)&255)) $((($i>>40)&255)) $((($i>>48)&255)) $((($i>>56)&255)) 2.22 - printf '\\\\x%02X\\\\x%02X\\\\x%02X\\\\x%02X\\\\x00\\\\x00\\\\x00\\\\x00' $(($i&255)) \ 2.23 - $((($i>>8)&255)) $((($i>>16)&255)) $((($i>>24)&255)) 2.24 - done | xargs echo -en 2.25 -} 2.26 - 2.27 gettazboot() 2.28 { 2.29 echo -e "\nCreating $(basename $1) ..." 2.30 @@ -75,12 +64,13 @@ 2.31 2.32 size() 2.33 { 2.34 - [ -L "$1" ] && case "$(readlink "$1")" in 2.35 - /*) set -- $(readlink "$1") ;; 2.36 - *) set -- $(dirname "$1")/$(readlink "$1") ;; 2.37 - esac 2.38 - [ ! -b "$1" ] && echo $(stat -c %s "$1") || 2.39 - echo $(($(cat /sys/block/${1#/dev/}/size)*512)) 2.40 + stat -c %s "$1" 2.41 +} 2.42 + 2.43 +sectcnt() 2.44 +{ 2.45 + [ ! -b "$1" ] && echo $(($(size "$1")/512)) || 2.46 + cat /sys/block/${1#/dev/}/size 2.47 } 2.48 2.49 uncpio() 2.50 @@ -1207,7 +1197,7 @@ 2.51 fi 2.52 2.53 # perform dd in progress bar 2.54 - max=$(($(size "$ISO")/1024/1024)) 2.55 + max=$(($(sectcnt "$ISO")/2048)) 2.56 i=0; while [ $i -le $max ]; do 2.57 ddq if="$ISO" bs=1024k count=1 skip=$i seek=$i of=$device 2.58 echo $((($i*100)/$max)) 2.59 @@ -1216,32 +1206,32 @@ 2.60 6 70 0 > /dev/tty 2>&1 2.61 2.62 # GPT partition + fat32 format for the remaining space 2.63 - sectors=$(($(size $device)/512)) 2.64 - word32s2bin $(($sectors-1)) | ddq bs=1 seek=458 of=$device # pmbr 2.65 - word32s2bin 0 | ddq bs=1 seek=$((512+16)) of=$device 2.66 - word64s2bin $(($sectors-3)) | ddq bs=1 seek=$((512+48)) of=$device 2.67 + sectors=$(($(sectcnt $device)-1)) 2.68 + quads2bin $sectors | ddq bs=1 seek=458 of=$device # pmbr 2.69 + quads2bin 0 | ddq bs=1 seek=$((512+16)) of=$device 2.70 + quads2bin $(($sectors-2)) 0 | ddq bs=1 seek=$((512+48)) of=$device 2.71 uudecode - <<EOT | gunzip | ddn bs=128 seek=9 of=$device # partiton fat32 2.72 begin-base64 644 - 2.73 H4sIAAAAAAACA1u04MLrpzuNXdoPZGzbrjbz+C/fHwyfEro9Z7E93Fi5/8sH 2.74 BhzAiSGRoZghkyGZQYEhBcguAWIFhgIgWQRkZ4JxPkMeAyEAAOuEo7uAAAAA 2.75 ==== 2.76 EOT 2.77 - last=$(($(size "$ISO")/512)) 2.78 + last=$(sectcnt "$ISO") 2.79 custom=$((4*$(get 32848 $device 4))) 2.80 [ $custom -gt $(($last-4)) ] && last=$(($custom+4)) # room for cmdline 2.81 - word64s2bin $last | ddq bs=1 seek=$((1024+128+32)) of=$device # vfat first address 2.82 - word64s2bin $(($sectors-3)) | ddq bs=1 seek=$((1024+128+40)) of=$device # vfat last address 2.83 - word32s2bin $(gpt_crc32 1024 $(($(get 596 $device 4)*$(get 592 $device 4)))) | \ 2.84 - ddq bs=1 seek=$((512+88)) of=$device # CRC32 partitions 2.85 - ddn of=$device if=$device bs=512 skip=1 seek=$(($sectors-1)) count=1 2.86 - ddn of=$device if=$device bs=512 skip=2 seek=$(($sectors-2)) count=1 2.87 - word64s2bin $(($sectors-1)) 1 | ddq bs=1 seek=$(($sectors*512-512+24)) of=$device # my gpt, alt gpt 2.88 - word64s2bin $(($sectors-1)) | ddq bs=1 seek=$((512+32)) of=$device # alt gpt 2.89 - word64s2bin $(($sectors-2)) | ddq bs=1 seek=$(($sectors*512-512+72)) of=$device 2.90 - word32s2bin $(gpt_crc32 $(($sectors*512-512)) $(get 524 $device 4)) | \ 2.91 - ddq bs=1 seek=$(($sectors*512-512+16)) of=$device # CRC32 header 2.92 - word32s2bin $(gpt_crc32 512 $(get 524 $device 4)) | \ 2.93 - ddq bs=1 seek=$((512+16)) of=$device # CRC32 header 2.94 + quads2bin $last 0 | ddq bs=1 seek=$((1024+128+32)) of=$device # vfat first address 2.95 + quads2bin $(($sectors-2)) 0 | ddq bs=1 seek=$((1024+128+40)) of=$device # vfat last address 2.96 + quads2bin $(gpt_crc32 1024 $(($(get 596 $device 4)*$(get 592 $device 4)))) | \ 2.97 + ddq bs=1 seek=$((512+88)) of=$device # CRC32 partitions 2.98 + ddn of=$device if=$device bs=512 skip=1 seek=$sectors count=1 2.99 + ddn of=$device if=$device bs=512 skip=2 seek=$(($sectors-1)) count=1 2.100 + quads2bin $sectors 0 1 0 | ddq bs=1 seek=$(($sectors*512+24)) of=$device # my gpt, alt gpt 2.101 + quads2bin 1 0 $sectors 0 | ddq bs=1 seek=$((512+24)) of=$device # my gpt, alt gpt 2.102 + quads2bin $(($sectors-1)) 0 | ddq bs=1 seek=$(($sectors*512+72)) of=$device 2.103 + i=$(get 524 $device 4) 2.104 + quads2bin $(gpt_crc32 $(($sectors*512)) $i) | \ 2.105 + ddq bs=1 seek=$(($sectors*512+16)) of=$device # CRC32 header 2.106 + quads2bin $(gpt_crc32 512 $i) | ddq bs=1 seek=$((512+16)) of=$device # CRC32 header 2.107 partprobe $device 2.108 homedev=/dev/$(basename /sys/block/${device#/dev/}/${device#/dev/}*2) 2.109 mkdosfs -n 'SLITAZ HOME' $homedev 2.110 @@ -1468,8 +1458,7 @@ 2.111 len="$len $l"; l=0 2.112 done 2.113 rdadrs=${RDADRS:-$(((($syssize*16)+0x1F0000) & -4096))} 2.114 - words2bin $(($rdadrs & 0xFFFF)) $(($rdadrs >> 16)) | ddn \ 2.115 - bs=1 seek=536 of=/tmp/fd$$ 2.116 + quads2bin $rdadrs | ddn bs=1 seek=536 of=/tmp/fd$$ 2.117 fi 2.118 n=$(echo $len | wc -w) 2.119 if [ $((494 - $(get 494 /tmp/fd$$))) -ge $(($n * 4)) ]; then 2.120 @@ -1488,8 +1477,7 @@ 2.121 ddn bs=1 seek=60 of=/tmp/fd$$ 2.122 fi 2.123 for r in $len ; do 2.124 - words2bin $(($r & 0xFFFF)) $(($r >> 16)) | ddn \ 2.125 - bs=1 seek=$i of=/tmp/fd$$ 2.126 + quads2bin $r | ddn bs=1 seek=$i of=/tmp/fd$$ 2.127 i=$(($i + 4)) 2.128 done 2.129 split -b 1440k /tmp/fd$$ fd$$ 2.130 @@ -1569,7 +1557,14 @@ 2.131 exit 2.132 fi 2.133 ISO="${1:-/dev/null}" 2.134 -[ ${ISO:0:1} != "/" ] && ISO=$(cd $(dirname $ISO); echo $PWD/$(basename $ISO)) 2.135 +while [ -L "$ISO" ]; do 2.136 + media="$(readlink "$ISO")" 2.137 + case "$media" in 2.138 + /*) ISO="$media" ;; 2.139 + *) ISO="$(dirname "$ISO")/$media" ;; 2.140 + esac 2.141 +done 2.142 +[ "${ISO:0:1}" != "/" ] && ISO="$(cd $(dirname "$ISO"); echo $PWD/$(basename "$ISO"))" 2.143 [ -z "$(isiso 2> /dev/null)" ] && echo "Usage : $0 file.iso" && exit 1 2.144 media=/tmp/media$$ 2.145 mkdir -p $media