wok diff syslinux/stuff/iso2exe/iso2exe.sh @ rev 24177
syslinux: add apple partitions
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Dec 30 19:33:58 2021 +0000 (2021-12-30) |
parents | 4e5765b0f66e |
children | f95bb62ba57c |
line diff
1.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Sat Dec 11 16:16:51 2021 +0000 1.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Thu Dec 30 19:33:58 2021 +0000 1.3 @@ -15,8 +15,8 @@ 1.4 local i 1.5 local n 1.6 n=$2; for i in $(seq 8 8 ${4:-16}); do 1.7 - printf '\\\\x%02X' $(($n & 255)) 1.8 - n=$(($n >> 8)) 1.9 + printf '\\\\x%02X' $((n & 255)) 1.10 + n=$((n >> 8)) 1.11 done | xargs echo -en | ddn bs=1 of=$3 seek=$(($1)) 1.12 } 1.13 1.14 @@ -47,7 +47,7 @@ 1.15 $0 --get rootfs.gz > $TMP/rootfs.gz 1.16 SIZE=$(wc -c < $TMP/rootfs.gz) 1.17 store 24 $SIZE $1 1.18 - OFS=$(( 0x7FF0 - $SIZE )) 1.19 + OFS=$(( 0x7FF0 - SIZE )) 1.20 printf "Adding rootfs.gz file at %04X (%d bytes) ...\n" $OFS $SIZE 1.21 ddn if=$TMP/rootfs.gz of=$1 bs=1 seek=$OFS 1.22 fi 1.23 @@ -63,7 +63,7 @@ 1.24 n=$(stat -c %s /tmp/rezipped$$.gz) 1.25 printf "Moving tazlito data record at %04X ($n bytes) ...\n" $OFS 1.26 ddn if=/tmp/rezipped$$.gz bs=1 of=$1 seek=$OFS 1.27 - HOLE=$(($HOLE+$n)) 1.28 + HOLE=$((HOLE+n)) 1.29 rm -f /tmp/rezipped$$.gz 1.30 if [ -n "$gpt" ]; then 1.31 store $((0x25E)) $n $1 1.32 @@ -73,51 +73,61 @@ 1.33 1.34 add_win32exe() 1.35 { 1.36 + $0 --get bootiso.bin 2> /dev/null > /tmp/bin$$ 1.37 SIZE=$($0 --get win32.exe 2> /dev/null | tee /tmp/exe$$ | wc -c) 1.38 n=1536 1.39 - SIZE=$(($SIZE+$n)) 1.40 + cut=$((0x98+$(get 0x94 /tmp/exe$$))) ### end of header 1.41 + if [ $(get 2048 /tmp/bin$$) -eq 19792 ]; then ### Fix EFI Apple partition 1.42 + o=$(($(get 584 "$1")*512)) 1.43 + f=$(($(get $((o+0x20)) "$1" 4)/4)) 1.44 + l=$((($(get $((o+0x28)) "$1" 4)+1)/4-f)) 1.45 + store $((0x1008)) $(printf "%08x" $f | sed 's|\(..\)\(..\)\(..\)\(..\)|0x\4\3\2\1|') /tmp/bin$$ 32 1.46 + store $((0x1054)) $(printf "%08x" $l | sed 's|\(..\)\(..\)\(..\)\(..\)|0x\4\3\2\1|') /tmp/bin$$ 32 1.47 + n=4608 1.48 + fi 1.49 + SIZE=$((SIZE+n)) 1.50 printf "Adding WIN32 file at %04X (%d bytes) ...\n" 0 $SIZE 1.51 [ -n "$gpt" ] && printf "Adding GPT at %04X (1024 bytes) ...\n" 512 1.52 - for i in $(seq 396 40 $((356+$(get 0x86 /tmp/exe$$)*40))); do 1.53 - x=$(($n + $(get $i /tmp/exe$$))) 1.54 - store $(($i)) $x /tmp/exe$$ ### section offset 1.55 + for i in $(seq 396 40 $((356+$(get 0x86 /tmp/exe$$)*40))); do ### 18C 1B4 1DC 1.56 + x=$((n + $(get $i /tmp/exe$$))) 1.57 + store $i $x /tmp/exe$$ ### section offset 1.58 done 1.59 - cut=$((0x98+$(get 0x94 /tmp/exe$$))) ### end of header 1.60 - store $((0x94)) $(($n + $cut - 0x98)) /tmp/exe$$ 1.61 + store $((0x94)) $((n + cut - 0x98)) /tmp/exe$$ 1.62 ddn if=/tmp/exe$$ of=$1 bs=1 count=$cut 1.63 - ddn if=/tmp/exe$$ of=$1 bs=1 skip=$cut seek=$(($n+$cut)) 1.64 + ddn if=/tmp/exe$$ of=$1 bs=1 skip=$cut seek=$((n+cut)) 1.65 printf "Adding bootiso head at %04X...\n" 0 1.66 - $0 --get bootiso.bin 2> /dev/null > /tmp/exe$$ 1.67 store 510 $((0xAA55)) $1 1.68 while read adrs sz; do 1.69 - ddn if=/tmp/exe$$ of=$1 bs=1 count=$((0x$sz)) seek=$((0x$adrs)) skip=$((0x$adrs)) 1.70 + ddn if=/tmp/bin$$ of=$1 bs=1 count=$((0x$sz)) seek=$((0x$adrs)) skip=$((0x$adrs)) 1.71 done <<EOT 1.72 -0000 0080 1.73 -0178 0040 1.74 -0270 0190 1.75 -0600 0178 1.76 +0000 0080 ### DOS stub + MBR 1.77 +0178 0040 ### partition boot code + MBR partitions (178..26F) 1.78 +0270 0190 ### DOS EXE code (400-5FF=head buf) 1.79 +0600 0178 ### iso hybrid boot code 1.80 +0800 0088 ### Apple partition 1 1.81 +1000 0088 ### Apple partition 1 1.82 EOT 1.83 i=$((0x600)) 1.84 OFS=$SIZE 1.85 - rm -f /tmp/exe$$ /tmp/coff$$ 1.86 + rm -f /tmp/exe$$ /tmp/bin$$ 1.87 if [ -z "$RECURSIVE_PARTITION" -a $(get 454 $1 4) -eq 0 ]; then 1.88 - store 448 $((1+$i/512)) $1 8 ### 446+2 SECTOR 1.89 - store 454 $(($i/512)) $1 32 ### 446+8 OFFSET 1.90 + store 448 $((1+i/512)) $1 8 ### 446+2 SECTOR 1.91 + store 454 $((i/512)) $1 32 ### 446+8 OFFSET 1.92 store 458 $(($(stat -c %s $1)/512)) $1 32 ### 446+12 SIZE 1.93 fi 1.94 mkdir /tmp/mnt$$ 1.95 mount -o loop,ro $1 /tmp/mnt$$ 1.96 if [ -s /tmp/mnt$$/boot/linld.com ]; then 1.97 i=$(($(get 20 $1)-0xC0)) 1.98 - store $(($i-6)) $(($(busybox stat -m /tmp/mnt$$/boot/linld.com | sed q)*2048)) $1 32 1.99 - store $(($i-2)) $(stat -c %s /tmp/mnt$$/boot/linld.com) $1 1.100 + store $((i-6)) $(($(busybox stat -m /tmp/mnt$$/boot/linld.com | sed q)*2048)) $1 32 1.101 + store $((i-2)) $(stat -c %s /tmp/mnt$$/boot/linld.com) $1 1.102 r="$(sed '/rootfs[0-9]/!d;s|.* initrd=||;s|/boot/||g;s| .*||' \ 1.103 /tmp/mnt$$/boot/isolinux/isolinux.cfg | tail -n1)" 1.104 if grep -qs rootfs /tmp/mnt$$/boot/isolinux/isolinux.cfg ; then 1.105 echo -n "image=/boot/bzImage initrd=${r:-rootfs.gz},! autologin rdinit=/init.exe" 1.106 else 1.107 echo -n "$(sed '/KERNEL/!d;s|.*KERNEL *|image=|;q' /tmp/mnt$$/boot/isolinux/isolinux.cfg)" 1.108 - fi | ddn bs=1 of=$1 conv=notrunc seek=$(($i-134)) 1.109 + fi | ddn bs=1 of=$1 conv=notrunc seek=$((i-134)) 1.110 fi 1.111 umount /tmp/mnt$$ 1.112 rmdir /tmp/mnt$$ 1.113 @@ -127,14 +137,14 @@ 1.114 { 1.115 SIZE=$($0 --get bootfd.bin 2> /dev/null | wc -c) 1.116 if [ $SIZE -ne 0 ]; then 1.117 - SIZE=$(( $SIZE - 512 )) # sector 2 is data 1.118 - OFS=$(( $OFS - $SIZE )) 1.119 + SIZE=$(( SIZE - 512 )) ### sector 2 is data 1.120 + OFS=$(( OFS - SIZE )) 1.121 printf "Adding floppy bootstrap file at %04X (%d bytes) ...\n" $OFS $SIZE 1.122 $0 --get bootfd.bin | \ 1.123 ddn of=$1 bs=1 count=512 seek=$OFS 1.124 $0 --get bootfd.bin | \ 1.125 - ddn of=$1 bs=1 skip=1024 seek=$((512 + $OFS)) 1.126 - store 26 $(($SIZE/512)) $1 8 1.127 + ddn of=$1 bs=1 skip=1024 seek=$((512 + OFS)) 1.128 + store 26 $((SIZE/512)) $1 8 1.129 fi 1.130 } 1.131 1.132 @@ -163,33 +173,33 @@ 1.133 case "$1" in 1.134 win32.exe) [ $x -eq 2048 ] && x=10752 1.135 [ $x -eq 1024 ] || SIZE=$x;; 1.136 - syslinux.mbr) [ $x -eq 1024 ] || OFFSET=$(($x - 512)); SIZE=336;; 1.137 + syslinux.mbr) [ $x -eq 1024 ] || OFFSET=$((x - 512)); SIZE=336;; 1.138 flavor.info) [ $(get 22528 "$ISO") -eq 35615 ] && OFFSET=22528 1.139 [ $x -eq 2048 ] && x=$(get 0x25C "$ISO") && 1.140 SIZE=$(get 0x25E "$ISO") 1.141 [ $(get $x "$ISO") -eq 35615 ] && OFFSET=$x 1.142 [ $OFFSET -ne 0 ] && [ $SIZE -eq 0 ] && 1.143 - SIZE=$(ddq bs=512 skip=$(($OFFSET/512)) if="$ISO" | gzsize);; 1.144 + SIZE=$(ddq bs=512 skip=$((OFFSET/512)) if="$ISO" | gzsize);; 1.145 floppy.boot) SIZE=$(($(get 26 "$ISO" 1)*512)) 1.146 - OFFSET=$(($(get 64 "$ISO") - 0xC0 - $SIZE));; 1.147 - rootfs.gz) SIZE=$(get 24 "$ISO"); OFFSET=$(($stub - $SIZE));; 1.148 + OFFSET=$(($(get 64 "$ISO") - 0xC0 - SIZE));; 1.149 + rootfs.gz) SIZE=$(get 24 "$ISO"); OFFSET=$((stub - SIZE));; 1.150 isoboot.com) OFFSET=$(($(get 64 "$ISO") - 0xC0)) 1.151 - SIZE=$(($stub - $(get 24 "$ISO") - $OFFSET));; 1.152 - dosstub) [ "$dosstub" ] && OFFSET=$stub && SIZE=$((0x7FF0 - $OFFSET));; 1.153 + SIZE=$((stub - $(get 24 "$ISO") - OFFSET));; 1.154 + dosstub) [ "$dosstub" ] && OFFSET=$stub && SIZE=$((0x7FF0 - OFFSET));; 1.155 boot.md5) [ $(get 0 "$ISO") -eq 23117 ] && 1.156 [ $(get 18 "$ISO") -ne 0 ] && 1.157 OFFSET=$((0x7FF0)) && SIZE=16;; 1.158 fs.iso) OFFSET=$((0x8000)) 1.159 - SIZE=$((2048*$c - $OFFSET));; 1.160 + SIZE=$((2048*c - OFFSET));; 1.161 custom.magic) ddq bs=2k skip=$c if="$ISO" | ddq bs=1 count=6 | \ 1.162 - grep -q '#!boot' && OFFSET=$((2048*$c)) && 1.163 + grep -q '#!boot' && OFFSET=$((2048*c)) && 1.164 SIZE=39 ;; 1.165 - custom.append) OFFSET=$((2048*$c+47)) && 1.166 + custom.append) OFFSET=$((2048*c+47)) && 1.167 SIZE=$(ddq bs=2k skip=$c if="$ISO" count=1 | \ 1.168 sed '/^append=/!d;s/^[^=]*=.//' | wc -c);; 1.169 custom.initrd) x=$(ddq bs=2k skip=$c if="$ISO" count=1 | \ 1.170 sed '/^append=\|^initrd:/!d' | wc -c) 1.171 - OFFSET=$((2048*$c+$x+40)) 1.172 + OFFSET=$((2048*c+x+40)) 1.173 SIZE=$(($(ddq bs=2k skip=$c if="$ISO" count=1 | \ 1.174 sed '/^initrd:/!d;s/.*://') + 0));; 1.175 esac 1.176 @@ -199,7 +209,7 @@ 1.177 { 1.178 OFFSET=$(stat -c %s "$1") 1.179 [ $OFFSET -gt $HEAP ] && 1.180 - printf "%d free bytes in %04X..%04X\n" $(($OFFSET - $HEAP)) $HEAP $OFFSET 1.181 + printf "%d free bytes in %04X..%04X\n" $((OFFSET - HEAP)) $HEAP $OFFSET 1.182 if [ $(get 510 "$1") -eq 43605 ]; then 1.183 echo "MBR partitions :" 1.184 for i in 0 1 2 3; do 1.185 @@ -216,14 +226,14 @@ 1.186 o=$(($(get 584 "$1")*512)) 1.187 i=0 1.188 while [ $i -lt $n ]; do 1.189 - f=$(get $(($o+0x20)) "$1" 4) 1.190 - l=$(($(get $(($o+0x28)) "$1" 4)-$f)) 1.191 + f=$(get $((o+0x20)) "$1" 4) 1.192 + l=$(($(get $((o+0x28)) "$1" 4)-f)) 1.193 [ $l -eq 0 ] && break 1.194 - printf " $i:%08X %08X %s\n" $f $(($l+1)) \ 1.195 - "$(od -An -N 72 -w72 -j $(($o+0x38)) -t a "$1" \ 1.196 + printf " $i:%08X %08X %s\n" $f $((l+1)) \ 1.197 + "$(od -An -N 72 -w72 -j $((o+0x38)) -t a "$1" \ 1.198 | sed 's/ nul//g;s/ //g;s/ sp//g')" 1.199 - o=$(($o+$s)) 1.200 - i=$(($i+1)) 1.201 + o=$((o+s)) 1.202 + i=$((i+1)) 1.203 done 1.204 fi 1.205 fi 1.206 @@ -232,12 +242,12 @@ 1.207 echo "Apple partitions :" 1.208 i=0 1.209 while [ $(get $o "$1") -eq 19792 ]; do 1.210 - f=$((0x$(od -An -N 4 -j $(($o+8)) -t x1 "$1" | sed 's/ //g'))) 1.211 - l=$((0x$(od -An -N 4 -j $(($o+0x54)) -t x1 "$1" | sed 's/ //g'))) 1.212 + f=$((0x$(od -An -N 4 -j $((o+8)) -t x1 "$1" | sed 's/ //g'))) 1.213 + l=$((0x$(od -An -N 4 -j $((o+0x54)) -t x1 "$1" | sed 's/ //g'))) 1.214 printf " $i:%08X %08X %s\n" $f $l \ 1.215 - "$(ddq bs=1 skip=$(($o+16)) count=32 if="$1" | strings -n 1)" 1.216 - o=$(($o+2048)) 1.217 - i=$(($i+1)) 1.218 + "$(ddq bs=1 skip=$((o+16)) count=32 if="$1" | strings -n 1)" 1.219 + o=$((o+2048)) 1.220 + i=$((i+1)) 1.221 done 1.222 fi 1.223 } 1.224 @@ -253,9 +263,9 @@ 1.225 [ "${OFFSET:8}" ] && continue 1.226 [ $OFFSET -lt 0 ] && continue 1.227 [ $(get $OFFSET "$ISO") -eq 0 ] && continue 1.228 - [ $OFFSET -gt $HEAP ] && [ $(($OFFSET - $HEAP)) -gt 16 ] && 1.229 - printf "%d free bytes in %04X..%04X\n" $(($OFFSET - $HEAP)) $HEAP $OFFSET 1.230 - [ $OFFSET -ge $HEAP ] && HEAP=$(($OFFSET+$SIZE)) 1.231 + [ $OFFSET -gt $HEAP ] && [ $((OFFSET - HEAP)) -gt 16 ] && 1.232 + printf "%d free bytes in %04X..%04X\n" $((OFFSET - HEAP)) $HEAP $OFFSET 1.233 + [ $OFFSET -ge $HEAP ] && HEAP=$((OFFSET+SIZE)) 1.234 printf "$f at %04X ($SIZE bytes).\n" $OFFSET 1.235 done 1.236 trailer $ISO 1.237 @@ -273,7 +283,7 @@ 1.238 [ $n -eq 0 -o $n -gt 64 ] && continue 1.239 store $((0x1C0+16*i)) 1 $1 8 1.240 store $((0x1C6+16*i)) 0 $1 32 1.241 - store $((0x1CA+16*i)) $(($(get $((0x1CA+16*i)) $1 4)+$n)) $1 32 1.242 + store $((0x1CA+16*i)) $(($(get $((0x1CA+16*i)) $1 4)+n)) $1 32 1.243 done 1.244 fi 1.245 } 1.246 @@ -296,7 +306,7 @@ 1.247 clear_custom_config() 1.248 { 1.249 start=$(custom_config_sector $1) 1.250 - cnt=$((512 - ($start % 512))) 1.251 + cnt=$((512 - (start % 512))) 1.252 [ $cnt -ne 512 ] && 1.253 ddq if=/dev/zero of=$1 bs=2k seek=$start count=$cnt 1.254 } 1.255 @@ -328,7 +338,7 @@ 1.256 $(tar cf - ${@/init/rootfs.gz} | compress | uuencode -m -) 1.257 EOT 1.258 EOM 1.259 - sed -i 's|[ \t]*###.*||;/^case/,/^esac/d' $0.$$ 1.260 + sed -i '/^##/d;s|[ \t]*###.*||;/^case/,/^esac/d' $0.$$ 1.261 mv -f $0.$$ $0; exit ;; 1.262 --get) 1.263 cat $2 1.264 @@ -341,7 +351,7 @@ 1.265 add_rootfs $DATA --array > /dev/null 1.266 add_fdbootstrap $DATA > /dev/null 1.267 name=${3:-bootiso} 1.268 - BOOTISOSZ=$((0x8000 - $OFS + $HSZ)) 1.269 + BOOTISOSZ=$((0x8000 - OFS + HSZ)) 1.270 cat <<EOT 1.271 1.272 #define $(echo $name | tr '[a-z]' '[A-Z]')SZ $BOOTISOSZ 1.273 @@ -406,14 +416,14 @@ 1.274 }; 1.275 #endif 1.276 1.277 -#define C_array (uint32_t *) ($name + $(($BOOTISOSZ))) 1.278 -#define P_array (char *) ($name + $(($BOOTISOSZ+(64*4)))) 1.279 -#define S_array (char *) ($name + $(($BOOTISOSZ+(64*4)+64))) 1.280 +#define C_array (uint32_t *) ($name + $((BOOTISOSZ))) 1.281 +#define P_array (char *) ($name + $((BOOTISOSZ+(64*4)))) 1.282 +#define S_array (char *) ($name + $((BOOTISOSZ+(64*4)+64))) 1.283 #define ELTORITOOFS 3 1.284 EOT 1.285 fi 1.286 - echo "#define $tag $(($BOOTISOSZ+(64*4)+64+16+$ofs))" 1.287 - ofs=$(($(echo -en "$str\0" | wc -c)+$ofs)) 1.288 + echo "#define $tag $((BOOTISOSZ+(64*4)+64+16+ofs))" 1.289 + ofs=$(($(echo -en "$str\0" | wc -c)+ofs)) 1.290 fi 1.291 done <<EOT 1.292 READSECTORERR Read sector failure. 1.293 @@ -449,7 +459,7 @@ 1.294 done 1.295 cat <<EOT 1.296 #ifdef __MSDOS__ 1.297 -#define BOOTISOFULLSIZE $(($BOOTISOSZ+(64*4)+64+16+$ofs)) 1.298 +#define BOOTISOFULLSIZE $((BOOTISOSZ+(64*4)+64+16+ofs)) 1.299 static char bootiso[BOOTISOFULLSIZE]; 1.300 static data_fixup(void) 1.301 { 1.302 @@ -491,8 +501,8 @@ 1.303 # --exe mvcom.bin x.com y.exe > xy.exe 1.304 cat $4 $3 > /tmp/exe$$ 1.305 S=$(stat -c %s /tmp/exe$$) 1.306 - store 2 $(($S%512)) /tmp/exe$$ 1.307 - store 4 $((($S+511)/512)) /tmp/exe$$ 1.308 + store 2 $((S%512)) /tmp/exe$$ 1.309 + store 4 $(((S+511)/512)) /tmp/exe$$ 1.310 store 14 -16 /tmp/exe$$ 1.311 store 16 -2 /tmp/exe$$ 1.312 store 20 256 /tmp/exe$$ 1.313 @@ -535,7 +545,7 @@ 1.314 case "$(get 0 $1)" in 1.315 23117) 1.316 b=$(get 417 $1 1) 1.317 - n=$(($(get 64 $1) + 0xC0 - ($(get 26 $1 1)*512) - ($b+1)*512)) 1.318 + n=$(($(get 64 $1) + 0xC0 - ($(get 26 $1 1)*512) - (b+1)*512)) 1.319 ddq if=$1 bs=512 count=1 skip=$b of=/tmp/hymbr$$ 1.320 restore_hybrid_mbr /tmp/hymbr$$ $1 1.321 ddn if=/tmp/hymbr$$ of=$1 1.322 @@ -547,8 +557,8 @@ 1.323 ddn if=/dev/zero bs=512 seek=3 count=1 of=$1 1.324 else 1.325 ddn if=/dev/zero bs=512 seek=1 count=1 of=$1 1.326 - ddn if=$1 bs=512 seek=2 count=30 skip=$(($b+1)) of=$1 1.327 - ddn if=/dev/zero bs=1 seek=$n count=$((0x8000 - $n)) of=$1 1.328 + ddn if=$1 bs=512 seek=2 count=30 skip=$((b+1)) of=$1 1.329 + ddn if=/dev/zero bs=1 seek=$n count=$((0x8000 - n)) of=$1 1.330 fi ;; 1.331 *) ddn if=/dev/zero bs=1k count=32 of=$1 ;; 1.332 esac 1.333 @@ -563,29 +573,21 @@ 1.334 esac 1.335 case "$(get 0 $1)" in 1.336 23117) echo "The file $1 is already an EXE file." 1>&2 && exit 1;; 1.337 - 0) [ -x /usr/bin/isohybrid ] && isohybrid -entry 2 $1;; 1.338 + 0) [ -x /usr/bin/isohybrid ] && isohybrid -entry 2 $1;; ### Add gpt EFI 1.339 esac 1.340 1.341 gpt= ; [ $(get 450 $1) -eq 65262 ] && gpt=1 1.342 - mac= ; [ $(get 2048 $1) -eq 19792 ] && mac=1 1.343 - echo "Read hybrid & tazlito data..." 1.344 - if [ -n "$gpt" ]; then 1.345 - echo "GUID Partition Table..." 1.346 - n=3; [ -n "$mac" ] && n=9 && echo "Apple Partition Table..." 1.347 - ddq if=$1 bs=512 count=$n of=/tmp/hybrid$$ 1.348 - ddq if=$1 bs=512 skip=44 count=20 of=/tmp/tazlito$$ 1.349 - else 1.350 - ddq if=$1 bs=512 count=1 of=/tmp/hybrid$$ 1.351 - ddq if=$1 bs=512 skip=2 count=20 of=/tmp/tazlito$$ 1.352 - fi 1.353 - add_win32exe $1 /tmp/hybrid$$ 1.354 + echo "Read tazlito data..." 1.355 + n=2; [ -n "$gpt" ] && n=44 && echo "GUID Partition Table..." 1.356 + ddq if=$1 bs=512 skip=$n count=20 of=/tmp/tazlito$$ 1.357 + add_win32exe $1 1.358 add_tazlito_info $1 /tmp/tazlito$$ 1.359 - rm -f /tmp/tazlito$$ /tmp/hybrid$$ 1.360 + rm -f /tmp/tazlito$$ 1.361 1.362 # keep the largest room for the tazlito info file 1.363 add_rootfs $1 1.364 add_fdbootstrap $1 1.365 - printf "%d free bytes in %04X..%04X\n" $(($OFS-$HOLE)) $HOLE $OFS 1.366 + printf "%d free bytes in %04X..%04X\n" $((OFS-HOLE)) $HOLE $OFS 1.367 store 440 $(date +%s) $1 32 1.368 [ "$2" ] && echo "$2 " | \ 1.369 ddn bs=1 seek=$((0x7FDE)) count=15 of=$1 1.370 @@ -607,20 +609,20 @@ 1.371 echo "#!boot $(md5sum $DATA | sed 's/ .*//')" | cat - $DATA | \ 1.372 ddq bs=2k seek=$(custom_config_sector $1) of=$1 1.373 newsz=$(stat -c %s $1) 1.374 - mb=$(((($newsz -1)/1048576)+1)) 1.375 - HEAP=$(($mb*1048576)) 1.376 + mb=$((((newsz -1)/1048576)+1)) 1.377 + HEAP=$((mb*1048576)) 1.378 ddq bs=1048576 seek=$mb count=0 of=$1 1.379 h=$(get 417 "$1" 1) 1.380 [ -z "$RECURSIVE_PARTITION" ] || h=0 1.381 for i in 0 1 2 3 ; do 1.382 [ $(get $((0x1BE+16*i)) $1 2) = $((0x0080)) ] || continue 1.383 - store $((0x1CA+16*i)) $(($mb*2048-$h)) $1 32 1.384 - store $((0x1C5+16*i)) $(($mb-1)) $1 8 1.385 + store $((0x1CA+16*i)) $((mb*2048-h)) $1 32 1.386 + store $((0x1C5+16*i)) $((mb-1)) $1 8 1.387 done 1.388 if [ $newsz -gt $isosz ]; then 1.389 - echo "$(($newsz - $isosz)) extra bytes." 1.390 + echo "$((newsz - isosz)) extra bytes." 1.391 else 1.392 - echo "$(($isosz - 2048*$(get 32848 $1 4) 1.393 + echo "$((isosz - 2048*$(get 32848 $1 4) 1.394 - $(stat -c %s $DATA) - 24)) bytes free." 1.395 fi 1.396 rm -f $DATA > /dev/null 1.397 @@ -630,8 +632,8 @@ 1.398 n=$(($(get 2 $1) - 1 + ($(get 4 $1) - 1)*512)) 1.399 n=$(($(od -v -N $n -t u2 -w2 -An $1 | \ 1.400 awk '{ i+= $0 } END { print (i % 65536) }') \ 1.401 - + $(get $(($n+1)) $1 1))) 1.402 - store 18 $(( (-$n -1) % 65536 )) $1 1.403 + + $(get $((n+1)) $1 1))) 1.404 + store 18 $(( (-n -1) % 65536 )) $1 1.405 fi 1.406 echo " done." 1.407 trailer $1