wok-current rev 17492
syslinux/iso2exe: check ISO md5
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Jan 03 21:41:48 2015 +0100 (2015-01-03) |
parents | 2c2a6dd5ba40 |
children | 5cad8b9a758c |
files | syslinux/stuff/iso2exe/boot.c syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/iso2exe.sh |
line diff
1.1 --- a/syslinux/stuff/iso2exe/boot.c Fri Jan 02 21:46:16 2015 +0100 1.2 +++ b/syslinux/stuff/iso2exe/boot.c Sat Jan 03 21:41:48 2015 +0100 1.3 @@ -71,10 +71,12 @@ 1.4 loadinitrd(); 1.5 } 1.6 if (*init) { 1.7 - lseek(isofd, 24L, SEEK_SET); 1.8 + lseek(isofd, 20L, SEEK_SET); 1.9 + read(isofd, &isofileofs, 4); 1.10 + isofileofs &= 0xFFFFL; 1.11 read(isofd, &magic, 4); 1.12 isofilesize = magic & 0xFFFFL; 1.13 - isofileofs = 0x7EE0L - isofilesize; 1.14 + isofileofs -= 0xC0L + isofilesize; 1.15 if (isofilesize) loadinitrd(); 1.16 else init=""; 1.17 }
2.1 --- a/syslinux/stuff/iso2exe/init Fri Jan 02 21:46:16 2015 +0100 2.2 +++ b/syslinux/stuff/iso2exe/init Sat Jan 03 21:41:48 2015 +0100 2.3 @@ -1,6 +1,7 @@ 2.4 #!/bin/sh 2.5 2.6 DIALOG=dialog 2.7 +ISOMD5= 2.8 2.9 ddq() 2.10 { 2.11 @@ -118,7 +119,7 @@ 2.12 { 2.13 echo "Creating $(basename $1) ..." 2.14 O=$(($(get 66 /mnt/$ISO) - 0xC0)) 2.15 - L=$((0x7EE0 - $(get 24 /mnt/$ISO) - $O)) 2.16 + L=$(($(get 20 /mnt/$ISO) - 0xC0 - $(get 24 /mnt/$ISO) - $O)) 2.17 S=$((32+$L)) 2.18 P=$((($S+511)/512)) 2.19 E=$((4096-(32*$P))) 2.20 @@ -635,6 +636,21 @@ 2.21 echo -en "\"$1\" \"$2\"" 2.22 } 2.23 2.24 +gotisomd5() 2.25 +{ 2.26 + [ "$(which md5sum 2> /dev/null)" ] && [ "$ISOMD5" ] && 2.27 + echo -en "\"$1\" \"$2\"" 2.28 +} 2.29 + 2.30 +isomd5() 2.31 +{ 2.32 + dotwait "Checking iso image" 2.33 + [ "$(ddq if=/dev/loop0 bs=32k skip=1 | md5sum)" == "$ISOMD5 -" ] && 2.34 + echo "OK" || echo "ERROR" 2.35 + rm -f /tmp/wait 2.36 + sleep 5 2.37 +} 2.38 + 2.39 fdbootstrap() 2.40 { 2.41 sz=$((512 * $(echo $(get 28 /mnt/$ISO 1)))) 2.42 @@ -886,8 +902,9 @@ 2.43 $(cdfile boot/bzImage "live" "Linux RAM boot (full desktop)") \ 2.44 "text" "Linux RAM boot" \ 2.45 $(cdfile README* "readme" "Show the README file") \ 2.46 -$(cdfile md5sum* "md5" "Check ISO files") \ 2.47 -$(cdfile sha*sum* "sha" "Check ISO files") \ 2.48 +$(gotisomd5 "isomd5" "Check the ISO image") \ 2.49 +$(cdfile md5sum* "md5" "Check the ISO files") \ 2.50 +$(cdfile sha*sum* "sha" "Check the ISO files") \ 2.51 $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \ 2.52 $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \ 2.53 $(xfile tazusb "usbkey" "USB key read/write installation") \
3.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Fri Jan 02 21:46:16 2015 +0100 3.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Sat Jan 03 21:41:48 2015 +0100 3.3 @@ -37,6 +37,11 @@ 3.4 mkdir -p $TMP/bin $TMP/dev 3.5 cp -a /dev/?d?* /dev/tty /dev/tty0 $TMP/dev 3.6 $0 --get init > $TMP/init.exe 3.7 + if [ $(stat -c %s $1) -gt 32768 ]; then 3.8 + echo "Compute ISO image md5 ..." 3.9 + sed -i "s/^ISOMD5.*/ISOMD5=$(ddq if=$1 bs=32k skip=1 | \ 3.10 + md5sum | cut -c-32)/" $TMP/init.exe 3.11 + fi 3.12 # mount -o loop,ro $1 $TMP 3.13 # oldslitaz="$(ls $TMP/boot/isolinux/splash.lss 2> /dev/null)" 3.14 # umount -d $TMP 3.15 @@ -57,10 +62,12 @@ 3.16 3.17 add_dosexe() 3.18 { 3.19 - OFS=$((0x7EE0)) 3.20 - printf "Adding DOS/EXE at %04X (%d bytes) ...\n" $OFS $((0x8000 - $OFS)) 3.21 - $0 --get bootiso.bin 2> /dev/null | \ 3.22 - ddq bs=1 skip=$OFS of=$1 seek=$OFS conv=notrunc 3.23 + TMP=/tmp/bootiso$$ 3.24 + $0 --get bootiso.bin > $TMP 2> /dev/null 3.25 + OFS=$(($(get 20 $TMP) - 0xC0)) 3.26 + printf "Adding DOS/EXE stub at %04X (%d bytes) ...\n" $OFS $((0x8000 - $OFS)) 3.27 + ddq if=$TMP bs=1 skip=$OFS of=$1 seek=$OFS conv=notrunc 3.28 + rm -f $TMP 3.29 } 3.30 3.31 add_doscom()