wok diff syslinux/stuff/iso2exe/iso2exe.sh @ rev 20869
syslinux/iso2exe: add cdrom icon
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Feb 23 13:25:31 2019 +0100 (2019-02-23) |
parents | e05d978e5ab8 |
children | 87d7af51ba68 |
line diff
1.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Fri Feb 22 22:16:14 2019 +0100 1.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Sat Feb 23 13:25:31 2019 +0100 1.3 @@ -5,6 +5,11 @@ 1.4 dd $@ 2> /dev/null 1.5 } 1.6 1.7 +ddn() 1.8 +{ 1.9 + ddq $@ conv=notrunc 1.10 +} 1.11 + 1.12 store() 1.13 { 1.14 local i 1.15 @@ -12,7 +17,7 @@ 1.16 n=$2; for i in $(seq 8 8 ${4:-16}); do 1.17 printf '\\\\x%02X' $(($n & 255)) 1.18 n=$(($n >> 8)) 1.19 - done | xargs echo -en | ddq bs=1 conv=notrunc of=$3 seek=$(($1)) 1.20 + done | xargs echo -en | ddn bs=1 of=$3 seek=$(($1)) 1.21 } 1.22 1.23 get() 1.24 @@ -40,28 +45,18 @@ 1.25 $0 --get rootfs.gz > $TMP/rootfs.gz 1.26 SIZE=$(wc -c < $TMP/rootfs.gz) 1.27 store 24 $SIZE $1 1.28 - OFS=$(( $OFS - $SIZE )) 1.29 + OFS=$(( 0x7FF0 - $SIZE )) 1.30 printf "Adding rootfs.gz file at %04X (%d bytes) ...\n" $OFS $SIZE 1.31 - cat $TMP/rootfs.gz | ddq of=$1 bs=1 seek=$OFS conv=notrunc 1.32 + cat $TMP/rootfs.gz | ddn of=$1 bs=1 seek=$OFS 1.33 rm -rf $TMP 1.34 } 1.35 1.36 -add_dosexe() 1.37 -{ 1.38 - TMP=/tmp/bootiso$$ 1.39 - $0 --get bootiso.bin > $TMP 2> /dev/null 1.40 - OFS=$(($(get 20 $TMP) - 0xC0)) 1.41 - printf "Adding DOS/EXE stub at %04X (%d bytes) ...\n" $OFS $((0x7FF0 - $OFS)) 1.42 - ddq if=$TMP bs=1 skip=$OFS of=$1 seek=$OFS conv=notrunc 1.43 - rm -f $TMP 1.44 -} 1.45 - 1.46 add_doscom() 1.47 { 1.48 SIZE=$($0 --get boot.com | wc -c) 1.49 OFS=$(( $OFS - $SIZE )) 1.50 printf "Adding DOS boot file at %04X (%d bytes) ...\n" $OFS $SIZE 1.51 - $0 --get boot.com | ddq of=$1 bs=1 seek=$OFS conv=notrunc 1.52 + $0 --get boot.com | ddn of=$1 bs=1 seek=$OFS 1.53 store 64 $(($OFS+0xC0)) $1 1.54 } 1.55 1.56 @@ -72,7 +67,7 @@ 1.57 zcat $2 | compress /tmp/rezipped$$.gz 1.58 n=$(stat -c %s /tmp/rezipped$$.gz) 1.59 printf "Moving tazlito data record at %04X ($n bytes) ...\n" $OFS 1.60 - ddq if=/tmp/rezipped$$.gz bs=1 of=$1 seek=$OFS conv=notrunc 1.61 + ddn if=/tmp/rezipped$$.gz bs=1 of=$1 seek=$OFS 1.62 HOLE=$(($HOLE+$n)) 1.63 rm -f /tmp/rezipped$$.gz 1.64 if [ -n "$gpt" ]; then 1.65 @@ -94,22 +89,28 @@ 1.66 done 1.67 cut=$((0x98+$(get 0x94 /tmp/exe$$))) ### end of header 1.68 store $((0x94)) $(($n + $cut - 0x98)) /tmp/exe$$ 1.69 - ddq if=/tmp/exe$$ of=$1 conv=notrunc bs=1 count=$cut 1.70 - ddq if=/tmp/exe$$ of=$1 conv=notrunc bs=1 skip=$cut seek=$(($n+$cut)) 1.71 + ddn if=/tmp/exe$$ of=$1 bs=1 count=$cut 1.72 + ddn if=/tmp/exe$$ of=$1 bs=1 skip=$cut seek=$(($n+$cut)) 1.73 printf "Adding bootiso head at %04X...\n" 0 1.74 $0 --get bootiso.bin 2> /dev/null > /tmp/exe$$ 1.75 - ddq if=/tmp/exe$$ of=$1 bs=128 count=1 conv=notrunc ### DOS stub 1.76 - ddq if=/tmp/exe$$ of=$1 bs=1 count=24 seek=$((0x1A0)) skip=$((0x1A0)) conv=notrunc 1.77 - ddq if=$2 bs=1 skip=$((0x1B8)) seek=$((0x1B8)) count=72 of=$1 conv=notrunc 1.78 + x=$(($(get 0x14 /tmp/exe$$ 1)+0x40)) 1.79 + printf "Adding bootiso DOS stub at %04X...\n" $(($n+$x)) 1.80 + ddn if=/tmp/exe$$ of=$1 bs=1 seek=$(($n+$x)) skip=$((0x7F00+$x)) count=$((256-$x)) 1.81 + x=$(($n/256+1)) 1.82 + store $((0x15)) $x /tmp/exe$$ 8 ### exe IP 1.83 + store $((0x6c)) $x /tmp/exe$$ 8 ### puts data 1.84 + ddn if=/tmp/exe$$ of=$1 bs=128 count=1 ### DOS header 1.85 + ddn if=/tmp/exe$$ of=$1 bs=1 count=24 seek=$((0x1A0)) skip=$((0x1A0)) 1.86 + ddn if=$2 bs=1 skip=$((0x1B8)) seek=$((0x1B8)) count=72 of=$1 1.87 store 510 $((0xAA55)) $1 1.88 i=$SIZE; OFS=$(($SIZE+512)) 1.89 store 417 $(($i/512)) $1 8 ### isolinux boot sector 1.90 printf "Moving syslinux hybrid boot record at %04X (512 bytes) ...\n" $i 1.91 - ddq if=$2 bs=1 count=512 of=$1 seek=$i conv=notrunc 1.92 + ddn if=$2 bs=1 count=512 of=$1 seek=$i 1.93 if [ $(get $((0x7C00)) /tmp/exe$$) -eq 60905 ]; then # partition boot code 1.94 - ddq if=/tmp/exe$$ bs=1 count=66 skip=$((0x7DBE)) of=$1 seek=$(($i + 0x1BE)) conv=notrunc 1.95 - ddq if=$1 bs=1 count=3 skip=$i of=$1 seek=$(($i + 0x1BE)) conv=notrunc 1.96 - ddq if=/tmp/exe$$ bs=1 count=3 skip=$((0x7C00)) of=$1 seek=$i conv=notrunc 1.97 + ddn if=/tmp/exe$$ bs=1 count=66 skip=$((0x7DBE)) of=$1 seek=$(($i + 0x1BE)) 1.98 + ddn if=$1 bs=1 count=3 skip=$i of=$1 seek=$(($i + 0x1BE)) 1.99 + ddn if=/tmp/exe$$ bs=1 count=3 skip=$((0x7C00)) of=$1 seek=$i 1.100 fi 1.101 rm -f /tmp/exe$$ /tmp/coff$$ 1.102 if [ -z "$RECURSIVE_PARTITION" -a $(get 454 $1 4) -eq 0 ]; then 1.103 @@ -127,9 +128,9 @@ 1.104 OFS=$(( $OFS - $SIZE )) 1.105 printf "Adding floppy bootstrap file at %04X (%d bytes) ...\n" $OFS $SIZE 1.106 $0 --get bootfd.bin | \ 1.107 - ddq of=$1 bs=1 count=512 seek=$OFS conv=notrunc 1.108 + ddn of=$1 bs=1 count=512 seek=$OFS 1.109 $0 --get bootfd.bin | \ 1.110 - ddq of=$1 bs=1 skip=1024 seek=$((512 + $OFS)) conv=notrunc 1.111 + ddn of=$1 bs=1 skip=1024 seek=$((512 + $OFS)) 1.112 store 26 $(($SIZE/512)) $1 8 1.113 fi 1.114 } 1.115 @@ -260,9 +261,9 @@ 1.116 restore_hybrid_mbr() 1.117 { 1.118 if [ $(get 0 "$1") -eq 60905 ]; then 1.119 - ddq bs=1 conv=notrunc if="$1" of="$1" skip=$((0x1BE)) seek=0 count=3 1.120 - ddq bs=1 skip=$((0x1BE)) count=66 if="$2" | \ 1.121 - ddq bs=1 seek=$((0x1BE)) count=66 of="$1" conv=notrunc 1.122 + ddn bs=1 if="$1" of="$1" skip=$((0x1BE)) seek=0 count=3 1.123 + ddn bs=1 skip=$((0x1BE)) count=66 if="$2" | \ 1.124 + ddq bs=1 seek=$((0x1BE)) count=66 of="$1" 1.125 if [ -n "$RECURSIVE_PARTITION" ]; then 1.126 for i in 0 1 2 3 ; do 1.127 n=$(get $((0x1C6+16*i)) $1 4) 1.128 @@ -324,7 +325,6 @@ 1.129 ddq if=/dev/zero bs=32k count=1 of=$DATA 1.130 add_win32exe $DATA $2 > /dev/null 1.131 HSZ=$OFS 1.132 - add_dosexe $DATA > /dev/null 1.133 add_rootfs $DATA > /dev/null 1.134 add_doscom $DATA > /dev/null 1.135 add_fdbootstrap $DATA > /dev/null 1.136 @@ -485,7 +485,7 @@ 1.137 store 16 -2 /tmp/exe$$ 1.138 store 20 256 /tmp/exe$$ 1.139 store 22 -16 /tmp/exe$$ 1.140 - ddq if=$2 bs=1 seek=64 of=/tmp/exe$$ conv=notrunc 1.141 + ddn if=$2 bs=1 seek=64 of=/tmp/exe$$ 1.142 store 65 $(stat -c %s $3) /tmp/exe$$ 1.143 store 68 $((0x100-0x40+$(stat -c %s $4))) /tmp/exe$$ 1.144 cat /tmp/exe$$ 1.145 @@ -526,19 +526,19 @@ 1.146 n=$(($(get 64 $1) + 0xC0 - ($(get 26 $1 1)*512) - ($b+1)*512)) 1.147 ddq if=$1 bs=512 count=1 skip=$b of=/tmp/hymbr$$ 1.148 restore_hybrid_mbr /tmp/hymbr$$ $1 1.149 - ddq if=/tmp/hymbr$$ of=$1 conv=notrunc 1.150 + ddn if=/tmp/hymbr$$ of=$1 1.151 rm -f /tmp/hymbr$$ 1.152 if [ $(get 512 $1) -eq 17989 ]; then 1.153 n=$(($(get 0x25C $1)/512)) 1.154 - ddq if=$1 bs=512 seek=44 count=20 skip=$n of=$1 conv=notrunc 1.155 - ddq if=/dev/zero bs=512 seek=9 count=35 of=$1 conv=notrunc 1.156 - ddq if=/dev/zero bs=512 seek=3 count=1 of=$1 conv=notrunc 1.157 + ddn if=$1 bs=512 seek=44 count=20 skip=$n of=$1 1.158 + ddn if=/dev/zero bs=512 seek=9 count=35 of=$1 1.159 + ddn if=/dev/zero bs=512 seek=3 count=1 of=$1 1.160 else 1.161 - ddq if=/dev/zero bs=512 seek=1 count=1 of=$1 conv=notrunc 1.162 - ddq if=$1 bs=512 seek=2 count=30 skip=$(($b+1)) of=$1 conv=notrunc 1.163 - ddq if=/dev/zero bs=1 seek=$n count=$((0x8000 - $n)) of=$1 conv=notrunc 1.164 + ddn if=/dev/zero bs=512 seek=1 count=1 of=$1 1.165 + ddn if=$1 bs=512 seek=2 count=30 skip=$(($b+1)) of=$1 1.166 + ddn if=/dev/zero bs=1 seek=$n count=$((0x8000 - $n)) of=$1 1.167 fi ;; 1.168 - *) ddq if=/dev/zero bs=1k count=32 of=$1 conv=notrunc ;; 1.169 + *) ddn if=/dev/zero bs=1k count=32 of=$1 ;; 1.170 esac 1.171 case "${2/--/-}" in 1.172 -f*) 1.173 @@ -571,19 +571,18 @@ 1.174 rm -f /tmp/tazlito$$ /tmp/hybrid$$ 1.175 1.176 # keep the largest room for the tazlito info file 1.177 - add_dosexe $1 1.178 add_rootfs $1 1.179 add_doscom $1 1.180 add_fdbootstrap $1 1.181 printf "%d free bytes in %04X..%04X\n" $(($OFS-$HOLE)) $HOLE $OFS 1.182 store 440 $(date +%s) $1 32 1.183 [ "$2" ] && echo "$2 " | \ 1.184 - ddq bs=1 seek=$((0x7FDE)) count=15 conv=notrunc of=$1 1.185 + ddn bs=1 seek=$((0x7FDE)) count=15 of=$1 1.186 if [ $(stat -c %s $1) -gt 34816 ]; then 1.187 echo "Adding ISO image md5 at 7FF0 (16 bytes) ..." 1.188 echo -en "$(ddq if=$1 bs=2k skip=16 count=$(($(get 32848 "$1" 4)-16)) | \ 1.189 md5sum | cut -c-32 | sed 's/\(..\)/\\x\1/g')" | \ 1.190 - ddq bs=16 seek=2047 conv=notrunc of=$1 1.191 + ddn bs=16 seek=2047 of=$1 1.192 fi 1.193 HEAP=$(($(custom_config_sector $1)*2048)) 1.194 if [ "$append$initrd" ]; then