# HG changeset patch # User Pascal Bellard # Date 1640892838 0 # Node ID 27c664d6b7a39bdccbdd532ca8e4cf13dd8b01a3 # Parent 62cc22bebaa99d69a3d4d90769e0a77f79bef1bd syslinux: add apple partitions diff -r 62cc22bebaa9 -r 27c664d6b7a3 syslinux/stuff/iso2exe/bootiso.S --- a/syslinux/stuff/iso2exe/bootiso.S Thu Dec 30 18:02:41 2021 +0000 +++ b/syslinux/stuff/iso2exe/bootiso.S Thu Dec 30 19:33:58 2021 +0000 @@ -600,4 +600,25 @@ .ascii "This program cannot be run in DOS mode.$" .org 0x0778,0xEE + .macro apple_partition count=2, start=1, size=2, name, namesz, type, typesz, start_data, size_data, status + .byte 0x50, 0x4D, 0, 0 /* PM */ +#define BE(x) (((x)>>24)|((((x)>>16)&255)<<8)|((((x)>>8)&255)<<16)|(((x)&255)<<24)) + .long BE(\count) + .long BE(\start) + .long BE(\size) + .ascii "\name" + .ds.b 32-\namesz, 0 + .ascii "\type" + .ds.b 32-\typesz, 0 + .long BE(\start_data) + .long BE(\size_data) + .long BE(\status) + .ds.b 44,0 /* boot code & processor info */ + .endm + + .org 0x800,0 + apple_partition 2, 1, 2, "Apple", 5, "Apple_partition_map", 19, 0, 2, 3 /* valid, allocated */ + .org 0x1000,0 + apple_partition 2, 1, 2, "EFI", 3, "Apple_HFS", 9, 0, 0, 0x40000013 /* valid, allocated, readable, automatically mount at startup */ + .end diff -r 62cc22bebaa9 -r 27c664d6b7a3 syslinux/stuff/iso2exe/iso2exe.sh --- a/syslinux/stuff/iso2exe/iso2exe.sh Thu Dec 30 18:02:41 2021 +0000 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Thu Dec 30 19:33:58 2021 +0000 @@ -15,8 +15,8 @@ local i local n n=$2; for i in $(seq 8 8 ${4:-16}); do - printf '\\\\x%02X' $(($n & 255)) - n=$(($n >> 8)) + printf '\\\\x%02X' $((n & 255)) + n=$((n >> 8)) done | xargs echo -en | ddn bs=1 of=$3 seek=$(($1)) } @@ -47,7 +47,7 @@ $0 --get rootfs.gz > $TMP/rootfs.gz SIZE=$(wc -c < $TMP/rootfs.gz) store 24 $SIZE $1 - OFS=$(( 0x7FF0 - $SIZE )) + OFS=$(( 0x7FF0 - SIZE )) printf "Adding rootfs.gz file at %04X (%d bytes) ...\n" $OFS $SIZE ddn if=$TMP/rootfs.gz of=$1 bs=1 seek=$OFS fi @@ -63,7 +63,7 @@ n=$(stat -c %s /tmp/rezipped$$.gz) printf "Moving tazlito data record at %04X ($n bytes) ...\n" $OFS ddn if=/tmp/rezipped$$.gz bs=1 of=$1 seek=$OFS - HOLE=$(($HOLE+$n)) + HOLE=$((HOLE+n)) rm -f /tmp/rezipped$$.gz if [ -n "$gpt" ]; then store $((0x25E)) $n $1 @@ -73,51 +73,61 @@ add_win32exe() { + $0 --get bootiso.bin 2> /dev/null > /tmp/bin$$ SIZE=$($0 --get win32.exe 2> /dev/null | tee /tmp/exe$$ | wc -c) n=1536 - SIZE=$(($SIZE+$n)) + cut=$((0x98+$(get 0x94 /tmp/exe$$))) ### end of header + if [ $(get 2048 /tmp/bin$$) -eq 19792 ]; then ### Fix EFI Apple partition + o=$(($(get 584 "$1")*512)) + f=$(($(get $((o+0x20)) "$1" 4)/4)) + l=$((($(get $((o+0x28)) "$1" 4)+1)/4-f)) + store $((0x1008)) $(printf "%08x" $f | sed 's|\(..\)\(..\)\(..\)\(..\)|0x\4\3\2\1|') /tmp/bin$$ 32 + store $((0x1054)) $(printf "%08x" $l | sed 's|\(..\)\(..\)\(..\)\(..\)|0x\4\3\2\1|') /tmp/bin$$ 32 + n=4608 + fi + SIZE=$((SIZE+n)) printf "Adding WIN32 file at %04X (%d bytes) ...\n" 0 $SIZE [ -n "$gpt" ] && printf "Adding GPT at %04X (1024 bytes) ...\n" 512 - for i in $(seq 396 40 $((356+$(get 0x86 /tmp/exe$$)*40))); do - x=$(($n + $(get $i /tmp/exe$$))) - store $(($i)) $x /tmp/exe$$ ### section offset + for i in $(seq 396 40 $((356+$(get 0x86 /tmp/exe$$)*40))); do ### 18C 1B4 1DC + x=$((n + $(get $i /tmp/exe$$))) + store $i $x /tmp/exe$$ ### section offset done - cut=$((0x98+$(get 0x94 /tmp/exe$$))) ### end of header - store $((0x94)) $(($n + $cut - 0x98)) /tmp/exe$$ + store $((0x94)) $((n + cut - 0x98)) /tmp/exe$$ ddn if=/tmp/exe$$ of=$1 bs=1 count=$cut - ddn if=/tmp/exe$$ of=$1 bs=1 skip=$cut seek=$(($n+$cut)) + ddn if=/tmp/exe$$ of=$1 bs=1 skip=$cut seek=$((n+cut)) printf "Adding bootiso head at %04X...\n" 0 - $0 --get bootiso.bin 2> /dev/null > /tmp/exe$$ store 510 $((0xAA55)) $1 while read adrs sz; do - ddn if=/tmp/exe$$ of=$1 bs=1 count=$((0x$sz)) seek=$((0x$adrs)) skip=$((0x$adrs)) + ddn if=/tmp/bin$$ of=$1 bs=1 count=$((0x$sz)) seek=$((0x$adrs)) skip=$((0x$adrs)) done < /dev/null | wc -c) if [ $SIZE -ne 0 ]; then - SIZE=$(( $SIZE - 512 )) # sector 2 is data - OFS=$(( $OFS - $SIZE )) + SIZE=$(( SIZE - 512 )) ### sector 2 is data + OFS=$(( OFS - SIZE )) printf "Adding floppy bootstrap file at %04X (%d bytes) ...\n" $OFS $SIZE $0 --get bootfd.bin | \ ddn of=$1 bs=1 count=512 seek=$OFS $0 --get bootfd.bin | \ - ddn of=$1 bs=1 skip=1024 seek=$((512 + $OFS)) - store 26 $(($SIZE/512)) $1 8 + ddn of=$1 bs=1 skip=1024 seek=$((512 + OFS)) + store 26 $((SIZE/512)) $1 8 fi } @@ -163,33 +173,33 @@ case "$1" in win32.exe) [ $x -eq 2048 ] && x=10752 [ $x -eq 1024 ] || SIZE=$x;; - syslinux.mbr) [ $x -eq 1024 ] || OFFSET=$(($x - 512)); SIZE=336;; + syslinux.mbr) [ $x -eq 1024 ] || OFFSET=$((x - 512)); SIZE=336;; flavor.info) [ $(get 22528 "$ISO") -eq 35615 ] && OFFSET=22528 [ $x -eq 2048 ] && x=$(get 0x25C "$ISO") && SIZE=$(get 0x25E "$ISO") [ $(get $x "$ISO") -eq 35615 ] && OFFSET=$x [ $OFFSET -ne 0 ] && [ $SIZE -eq 0 ] && - SIZE=$(ddq bs=512 skip=$(($OFFSET/512)) if="$ISO" | gzsize);; + SIZE=$(ddq bs=512 skip=$((OFFSET/512)) if="$ISO" | gzsize);; floppy.boot) SIZE=$(($(get 26 "$ISO" 1)*512)) - OFFSET=$(($(get 64 "$ISO") - 0xC0 - $SIZE));; - rootfs.gz) SIZE=$(get 24 "$ISO"); OFFSET=$(($stub - $SIZE));; + OFFSET=$(($(get 64 "$ISO") - 0xC0 - SIZE));; + rootfs.gz) SIZE=$(get 24 "$ISO"); OFFSET=$((stub - SIZE));; isoboot.com) OFFSET=$(($(get 64 "$ISO") - 0xC0)) - SIZE=$(($stub - $(get 24 "$ISO") - $OFFSET));; - dosstub) [ "$dosstub" ] && OFFSET=$stub && SIZE=$((0x7FF0 - $OFFSET));; + SIZE=$((stub - $(get 24 "$ISO") - OFFSET));; + dosstub) [ "$dosstub" ] && OFFSET=$stub && SIZE=$((0x7FF0 - OFFSET));; boot.md5) [ $(get 0 "$ISO") -eq 23117 ] && [ $(get 18 "$ISO") -ne 0 ] && OFFSET=$((0x7FF0)) && SIZE=16;; fs.iso) OFFSET=$((0x8000)) - SIZE=$((2048*$c - $OFFSET));; + SIZE=$((2048*c - OFFSET));; custom.magic) ddq bs=2k skip=$c if="$ISO" | ddq bs=1 count=6 | \ - grep -q '#!boot' && OFFSET=$((2048*$c)) && + grep -q '#!boot' && OFFSET=$((2048*c)) && SIZE=39 ;; - custom.append) OFFSET=$((2048*$c+47)) && + custom.append) OFFSET=$((2048*c+47)) && SIZE=$(ddq bs=2k skip=$c if="$ISO" count=1 | \ sed '/^append=/!d;s/^[^=]*=.//' | wc -c);; custom.initrd) x=$(ddq bs=2k skip=$c if="$ISO" count=1 | \ sed '/^append=\|^initrd:/!d' | wc -c) - OFFSET=$((2048*$c+$x+40)) + OFFSET=$((2048*c+x+40)) SIZE=$(($(ddq bs=2k skip=$c if="$ISO" count=1 | \ sed '/^initrd:/!d;s/.*://') + 0));; esac @@ -199,7 +209,7 @@ { OFFSET=$(stat -c %s "$1") [ $OFFSET -gt $HEAP ] && - printf "%d free bytes in %04X..%04X\n" $(($OFFSET - $HEAP)) $HEAP $OFFSET + printf "%d free bytes in %04X..%04X\n" $((OFFSET - HEAP)) $HEAP $OFFSET if [ $(get 510 "$1") -eq 43605 ]; then echo "MBR partitions :" for i in 0 1 2 3; do @@ -216,14 +226,14 @@ o=$(($(get 584 "$1")*512)) i=0 while [ $i -lt $n ]; do - f=$(get $(($o+0x20)) "$1" 4) - l=$(($(get $(($o+0x28)) "$1" 4)-$f)) + f=$(get $((o+0x20)) "$1" 4) + l=$(($(get $((o+0x28)) "$1" 4)-f)) [ $l -eq 0 ] && break - printf " $i:%08X %08X %s\n" $f $(($l+1)) \ - "$(od -An -N 72 -w72 -j $(($o+0x38)) -t a "$1" \ + printf " $i:%08X %08X %s\n" $f $((l+1)) \ + "$(od -An -N 72 -w72 -j $((o+0x38)) -t a "$1" \ | sed 's/ nul//g;s/ //g;s/ sp//g')" - o=$(($o+$s)) - i=$(($i+1)) + o=$((o+s)) + i=$((i+1)) done fi fi @@ -232,12 +242,12 @@ echo "Apple partitions :" i=0 while [ $(get $o "$1") -eq 19792 ]; do - f=$((0x$(od -An -N 4 -j $(($o+8)) -t x1 "$1" | sed 's/ //g'))) - l=$((0x$(od -An -N 4 -j $(($o+0x54)) -t x1 "$1" | sed 's/ //g'))) + f=$((0x$(od -An -N 4 -j $((o+8)) -t x1 "$1" | sed 's/ //g'))) + l=$((0x$(od -An -N 4 -j $((o+0x54)) -t x1 "$1" | sed 's/ //g'))) printf " $i:%08X %08X %s\n" $f $l \ - "$(ddq bs=1 skip=$(($o+16)) count=32 if="$1" | strings -n 1)" - o=$(($o+2048)) - i=$(($i+1)) + "$(ddq bs=1 skip=$((o+16)) count=32 if="$1" | strings -n 1)" + o=$((o+2048)) + i=$((i+1)) done fi } @@ -253,9 +263,9 @@ [ "${OFFSET:8}" ] && continue [ $OFFSET -lt 0 ] && continue [ $(get $OFFSET "$ISO") -eq 0 ] && continue - [ $OFFSET -gt $HEAP ] && [ $(($OFFSET - $HEAP)) -gt 16 ] && - printf "%d free bytes in %04X..%04X\n" $(($OFFSET - $HEAP)) $HEAP $OFFSET - [ $OFFSET -ge $HEAP ] && HEAP=$(($OFFSET+$SIZE)) + [ $OFFSET -gt $HEAP ] && [ $((OFFSET - HEAP)) -gt 16 ] && + printf "%d free bytes in %04X..%04X\n" $((OFFSET - HEAP)) $HEAP $OFFSET + [ $OFFSET -ge $HEAP ] && HEAP=$((OFFSET+SIZE)) printf "$f at %04X ($SIZE bytes).\n" $OFFSET done trailer $ISO @@ -273,7 +283,7 @@ [ $n -eq 0 -o $n -gt 64 ] && continue store $((0x1C0+16*i)) 1 $1 8 store $((0x1C6+16*i)) 0 $1 32 - store $((0x1CA+16*i)) $(($(get $((0x1CA+16*i)) $1 4)+$n)) $1 32 + store $((0x1CA+16*i)) $(($(get $((0x1CA+16*i)) $1 4)+n)) $1 32 done fi } @@ -296,7 +306,7 @@ clear_custom_config() { start=$(custom_config_sector $1) - cnt=$((512 - ($start % 512))) + cnt=$((512 - (start % 512))) [ $cnt -ne 512 ] && ddq if=/dev/zero of=$1 bs=2k seek=$start count=$cnt } @@ -328,7 +338,7 @@ $(tar cf - ${@/init/rootfs.gz} | compress | uuencode -m -) EOT EOM - sed -i 's|[ \t]*###.*||;/^case/,/^esac/d' $0.$$ + sed -i '/^##/d;s|[ \t]*###.*||;/^case/,/^esac/d' $0.$$ mv -f $0.$$ $0; exit ;; --get) cat $2 @@ -341,7 +351,7 @@ add_rootfs $DATA --array > /dev/null add_fdbootstrap $DATA > /dev/null name=${3:-bootiso} - BOOTISOSZ=$((0x8000 - $OFS + $HSZ)) + BOOTISOSZ=$((0x8000 - OFS + HSZ)) cat < xy.exe cat $4 $3 > /tmp/exe$$ S=$(stat -c %s /tmp/exe$$) - store 2 $(($S%512)) /tmp/exe$$ - store 4 $((($S+511)/512)) /tmp/exe$$ + store 2 $((S%512)) /tmp/exe$$ + store 4 $(((S+511)/512)) /tmp/exe$$ store 14 -16 /tmp/exe$$ store 16 -2 /tmp/exe$$ store 20 256 /tmp/exe$$ @@ -535,7 +545,7 @@ case "$(get 0 $1)" in 23117) b=$(get 417 $1 1) - n=$(($(get 64 $1) + 0xC0 - ($(get 26 $1 1)*512) - ($b+1)*512)) + n=$(($(get 64 $1) + 0xC0 - ($(get 26 $1 1)*512) - (b+1)*512)) ddq if=$1 bs=512 count=1 skip=$b of=/tmp/hymbr$$ restore_hybrid_mbr /tmp/hymbr$$ $1 ddn if=/tmp/hymbr$$ of=$1 @@ -547,8 +557,8 @@ ddn if=/dev/zero bs=512 seek=3 count=1 of=$1 else ddn if=/dev/zero bs=512 seek=1 count=1 of=$1 - ddn if=$1 bs=512 seek=2 count=30 skip=$(($b+1)) of=$1 - ddn if=/dev/zero bs=1 seek=$n count=$((0x8000 - $n)) of=$1 + ddn if=$1 bs=512 seek=2 count=30 skip=$((b+1)) of=$1 + ddn if=/dev/zero bs=1 seek=$n count=$((0x8000 - n)) of=$1 fi ;; *) ddn if=/dev/zero bs=1k count=32 of=$1 ;; esac @@ -563,29 +573,21 @@ esac case "$(get 0 $1)" in 23117) echo "The file $1 is already an EXE file." 1>&2 && exit 1;; - 0) [ -x /usr/bin/isohybrid ] && isohybrid -entry 2 $1;; + 0) [ -x /usr/bin/isohybrid ] && isohybrid -entry 2 $1;; ### Add gpt EFI esac gpt= ; [ $(get 450 $1) -eq 65262 ] && gpt=1 - mac= ; [ $(get 2048 $1) -eq 19792 ] && mac=1 - echo "Read hybrid & tazlito data..." - if [ -n "$gpt" ]; then - echo "GUID Partition Table..." - n=3; [ -n "$mac" ] && n=9 && echo "Apple Partition Table..." - ddq if=$1 bs=512 count=$n of=/tmp/hybrid$$ - ddq if=$1 bs=512 skip=44 count=20 of=/tmp/tazlito$$ - else - ddq if=$1 bs=512 count=1 of=/tmp/hybrid$$ - ddq if=$1 bs=512 skip=2 count=20 of=/tmp/tazlito$$ - fi - add_win32exe $1 /tmp/hybrid$$ + echo "Read tazlito data..." + n=2; [ -n "$gpt" ] && n=44 && echo "GUID Partition Table..." + ddq if=$1 bs=512 skip=$n count=20 of=/tmp/tazlito$$ + add_win32exe $1 add_tazlito_info $1 /tmp/tazlito$$ - rm -f /tmp/tazlito$$ /tmp/hybrid$$ + rm -f /tmp/tazlito$$ # keep the largest room for the tazlito info file add_rootfs $1 add_fdbootstrap $1 - printf "%d free bytes in %04X..%04X\n" $(($OFS-$HOLE)) $HOLE $OFS + printf "%d free bytes in %04X..%04X\n" $((OFS-HOLE)) $HOLE $OFS store 440 $(date +%s) $1 32 [ "$2" ] && echo "$2 " | \ ddn bs=1 seek=$((0x7FDE)) count=15 of=$1 @@ -607,20 +609,20 @@ echo "#!boot $(md5sum $DATA | sed 's/ .*//')" | cat - $DATA | \ ddq bs=2k seek=$(custom_config_sector $1) of=$1 newsz=$(stat -c %s $1) - mb=$(((($newsz -1)/1048576)+1)) - HEAP=$(($mb*1048576)) + mb=$((((newsz -1)/1048576)+1)) + HEAP=$((mb*1048576)) ddq bs=1048576 seek=$mb count=0 of=$1 h=$(get 417 "$1" 1) [ -z "$RECURSIVE_PARTITION" ] || h=0 for i in 0 1 2 3 ; do [ $(get $((0x1BE+16*i)) $1 2) = $((0x0080)) ] || continue - store $((0x1CA+16*i)) $(($mb*2048-$h)) $1 32 - store $((0x1C5+16*i)) $(($mb-1)) $1 8 + store $((0x1CA+16*i)) $((mb*2048-h)) $1 32 + store $((0x1C5+16*i)) $((mb-1)) $1 8 done if [ $newsz -gt $isosz ]; then - echo "$(($newsz - $isosz)) extra bytes." + echo "$((newsz - isosz)) extra bytes." else - echo "$(($isosz - 2048*$(get 32848 $1 4) + echo "$((isosz - 2048*$(get 32848 $1 4) - $(stat -c %s $DATA) - 24)) bytes free." fi rm -f $DATA > /dev/null @@ -630,8 +632,8 @@ n=$(($(get 2 $1) - 1 + ($(get 4 $1) - 1)*512)) n=$(($(od -v -N $n -t u2 -w2 -An $1 | \ awk '{ i+= $0 } END { print (i % 65536) }') \ - + $(get $(($n+1)) $1 1))) - store 18 $(( (-$n -1) % 65536 )) $1 + + $(get $((n+1)) $1 1))) + store 18 $(( (-n -1) % 65536 )) $1 fi echo " done." trailer $1 diff -r 62cc22bebaa9 -r 27c664d6b7a3 syslinux/stuff/iso2exe/taziso --- a/syslinux/stuff/iso2exe/taziso Thu Dec 30 18:02:41 2021 +0000 +++ b/syslinux/stuff/iso2exe/taziso Thu Dec 30 19:33:58 2021 +0000 @@ -22,22 +22,22 @@ bytes2bin() { for i in $@ ; do - printf '\\\\x%02X' $(($i&255)) + printf '\\\\x%02X' $((i&255)) done | xargs echo -en } words2bin() { for i in $@ ; do - printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255)) + printf '\\\\x%02X\\\\x%02X' $((i&255)) $(((i>>8)&255)) done | xargs echo -en } quads2bin() { for i in $@ ; do - printf '\\\\x%02X\\\\x%02X\\\\x%02X\\\\x%02X' $(($i&255)) \ - $((($i>>8)&255)) $((($i>>16)&255)) $((($i>>24)&255)) + printf '\\\\x%02X\\\\x%02X\\\\x%02X\\\\x%02X' $((i&255)) \ + $(((i>>8)&255)) $(((i>>16)&255)) $(((i>>24)&255)) done | xargs echo -en } @@ -46,9 +46,9 @@ echo -e "\nCreating $(basename $1) ..." gotcdfile linld.com S=$(($(stat -c %s $file)+12)) - P=$((($S+511)/512)) - E=$((4096-(32*$P))) - words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 -16 \ + P=$(((S+511)/512)) + E=$((4096-(32*P))) + words2bin 0x5A4D $((S%512)) $P 0 2 $E -1 -16 \ -2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1 dd if=$file bs=1 count=$(($(stat -c %s $file)-1)) >> $1 2> /dev/null echo -en '@tazboot.cmd\0' >> $1 @@ -108,7 +108,7 @@ tazusbinitfs() { PAD=$(($(size $1) % 4)) - [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1 + [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - PAD)) >> $1 mkdir -p /tmp/fs$$/etc /tmp/fs$$/lib /tmp/fs$$/home cp -a /etc/locale.conf /etc/locale.conf /tmp/fs$$/etc 2> /dev/null cat > /tmp/fs$$/init1 < cmdline && ls -l $PWD/cmdline ;; initrd:*) cnt=${line#initrd:} - { ddq bs=512 count=$(($cnt / 512)); - ddq bs=1 count=$(($cnt % 512)); } > initrd && + { ddq bs=512 count=$((cnt / 512)); + ddq bs=1 count=$((cnt % 512)); } > initrd && ls -l $PWD/initrd break ;; *) break ;; @@ -1086,7 +1086,7 @@ n=$(($(get 2 "$ISO")-1+($(get 4 "$ISO")-1)*512)) if [ $n -lt 40000 -a $n -gt 32768 ]; then s=$(get 0 "$ISO" 2 $n | awk '{ i+= $0 } END { print i }') - [ $(((1+$s+$(get $(($n+1)) "$ISO" 1)) % 65536)) -eq 0 ] && + [ $(((1+s+$(get $((n+1)) "$ISO" 1)) % 65536)) -eq 0 ] && echo "OK" || echo "ERROR" fi if hascustomconf; then @@ -1215,11 +1215,11 @@ dd if=$device bs=1 skip=$(($1)) count=$(($2)) 2> /dev/null | \ od -v -w1 -t u1 -An | { while read n; do - local x=$((($crc ^ $n) & 255)) + local x=$(((crc ^ n) & 255)) eval x=0x\$t$x - crc=$(((($crc >> 8) & 0x00FFFFFF) ^ $x)) + crc=$((((crc >> 8) & 0x00FFFFFF) ^ x)) done - echo $(($crc ^ 0xFFFFFFFF)) + echo $((crc ^ 0xFFFFFFFF)) } } @@ -1245,8 +1245,8 @@ max=$(($(sectcnt "$ISO")/2048)) i=0; while [ $i -le $max ]; do ddq if="$ISO" bs=1024k count=1 skip=$i seek=$i of=$device - echo $((($i*100)/$max)) - i=$(($i+1)) + echo $(((i*100)/max)) + i=$((i+1)) done | { [ "$1" ] || dialog --gauge \ " The ISO image transfer can be long. Please wait..." \ 6 70 0 > /dev/tty 2>&1; } @@ -1255,7 +1255,7 @@ sectors=$(($(sectcnt $device)-1)) quads2bin $sectors | ddq bs=1 seek=458 of=$device # pmbr quads2bin 0 | ddq bs=1 seek=$((512+16)) of=$device - quads2bin $(($sectors-2)) 0 | ddq bs=1 seek=$((512+48)) of=$device + quads2bin $((sectors-2)) 0 | ddq bs=1 seek=$((512+48)) of=$device uudecode - </dev/null } @@ -1466,7 +1466,7 @@ uudecode <> /tmp/fd$$ bytes2bin $n | ddn bs=1 seek=497 of=/tmp/fd$$ @@ -1476,7 +1476,7 @@ fi syssize=$(echo $(get 500 /tmp/fd$$ 4)) ddq bs=512 skip=$n if=$KERNEL | cat - /dev/zero | \ - ddq bs=512 count=$((($syssize+31)/32)) conv=sync >> /tmp/fd$$ + ddq bs=512 count=$(((syssize+31)/32)) conv=sync >> /tmp/fd$$ base=$(size /tmp/fd$$) len= if [ "$INITRD" ]; then @@ -1488,54 +1488,54 @@ [ -n "$j" ] && i=$j && break done ddq if=$i >> /tmp/fd$$ - l=$(($l+$(size $i))) - r=$((4 - ($l % 4))) + l=$((l+$(size $i))) + r=$((4 - (l % 4))) if [ $r -ne 4 ]; then ddq if=/dev/zero bs=1 count=$r >> /tmp/fd$$ - l=$(($l + $r)) + l=$((l + r)) fi case "$i:$INITRD" in *rootfs.gz:*rootfs.gz,*) continue # loram esac len="$len $l"; l=0 done - rdadrs=${RDADRS:-$(((($syssize*16)+0x1F0000) & -4096))} + rdadrs=${RDADRS:-$((((syssize*16)+0x1F0000) & -4096))} quads2bin $rdadrs | ddn bs=1 seek=536 of=/tmp/fd$$ fi n=$(echo $len | wc -w) - if [ $((494 - $(get 494 /tmp/fd$$))) -ge $(($n * 4)) ]; then + if [ $((494 - $(get 494 /tmp/fd$$))) -ge $((n * 4)) ]; then i=$(($(get 494 /tmp/fd$$))) - bytes2bin $(($i + ($n*4) - 256)) | ddn bs=1 \ + bytes2bin $((i + (n*4) - 256)) | ddn bs=1 \ seek=496 of=/tmp/fd$$ else - i=$(($pos + 0x1FC - ($n*4))) - bytes2bin $(($i % 256)) $((i / 256)) 252 | ddn bs=1 \ + i=$((pos + 0x1FC - (n*4))) + bytes2bin $((i % 256)) $((i / 256)) 252 | ddn bs=1 \ seek=494 of=/tmp/fd$$ - s=$(($i - 2*$(echo "$SIZES" | wc -w))) - p=$(($s - $(ifmemcode | wc -c))) + s=$((i - 2*$(echo "$SIZES" | wc -w))) + p=$((s - $(ifmemcode | wc -c))) ifmemcode | ddn bs=1 seek=$p of=/tmp/fd$$ words2bin $SIZES | ddn bs=1 seek=$s of=/tmp/fd$$ - bytes2bin 154 $(($p%256)) $(($p/256)) 0 144 | \ + bytes2bin 154 $((p%256)) $((p/256)) 0 144 | \ ddn bs=1 seek=60 of=/tmp/fd$$ fi for r in $len ; do quads2bin $r | ddn bs=1 seek=$i of=/tmp/fd$$ - i=$(($i + 4)) + i=$((i + 4)) done split -b 1440k /tmp/fd$$ fd$$ rm -f /tmp/fd$$ n=1; i=0; r=0 set -- $len ls fd$$* | while read file ; do - if [ $i -ge $(($1+$base)) ]; then - base=$(($1+$base-$i)) + if [ $i -ge $(($1+base)) ]; then + base=$(($1+base-i)) shift - r=$(($r+100)); n=0; i=0 + r=$((r+100)); n=0; i=0 fi ddq of=$file bs=18k seek=80 count=0 - i=$(($i+1474560)) - printf "mv %s fd%03d.img\n" $file $(($r+$n)) - n=$(($n+1)) + i=$((i+1474560)) + printf "mv %s fd%03d.img\n" $file $((r+n)) + n=$((n+1)) done | sh du -ch $PWD/fd???.img }