wok diff syslinux/stuff/iso2exe/iso2exe.sh @ rev 17451
syslinux/iso2exe: add --undo
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Dec 17 12:25:20 2014 +0100 (2014-12-17) |
parents | 589a225cacc7 |
children | aa3f469a31d7 |
line diff
1.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Sun Oct 19 14:21:26 2014 +0200 1.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Wed Dec 17 12:25:20 2014 +0100 1.3 @@ -114,17 +114,48 @@ 1.4 add_doscom $DATA > /dev/null 1.5 add_fdbootstrap $DATA > /dev/null 1.6 name=${3:-bootiso} 1.7 + BOOTISOSZ=$((0x8000 - $OFS + $HSZ)) 1.8 cat <<EOT 1.9 1.10 -#define $(echo $name | tr '[a-z]' '[A-Z]')SZ $((0x8000 - $OFS + $HSZ)) 1.11 +#define $(echo $name | tr '[a-z]' '[A-Z]')SZ $BOOTISOSZ 1.12 1.13 #ifdef WIN32 1.14 static char $name[] = { 1.15 $(hexdump -v -n $HSZ -e '" " 16/1 "0x%02X, "' -e '" // %04.4_ax |" 16/1 "%_p" "| \n"' $DATA | sed 's/ 0x ,/ /g') 1.16 $(hexdump -v -s $OFS -e '" " 16/1 "0x%02X, "' -e '" // %04.4_ax |" 16/1 "%_p" "| \n"' $DATA | sed 's/ 0x ,/ /g') 1.17 +EOT 1.18 + 1.19 +for mode in data offset ; do 1.20 + ofs=0 1.21 + while read tag str; do 1.22 + if [ "$mode" == "data" ]; then 1.23 + echo -en "$str\0" | hexdump -v -e '" " 16/1 "0x%02X, "' \ 1.24 + -e '" // %04.4_ax |" 16/1 "%_p" "| \n"' | \ 1.25 + sed 's/ 0x ,/ /g' 1.26 + else 1.27 + if [ $ofs -eq 0 ]; then 1.28 + cat <<EOT 1.29 }; 1.30 +#else 1.31 +static char *$name; 1.32 #endif 1.33 +#define ELTORITOOFS 3 1.34 EOT 1.35 + fi 1.36 + echo "#define $tag $(($BOOTISOSZ+$ofs))" 1.37 + ofs=$(($(echo -en "$str\0" | wc -c)+$ofs)) 1.38 + fi 1.39 + done <<EOT 1.40 +READSECTORERR Read sector failure. 1.41 +USAGE Usage: isohybrid.exe file.iso [--forced] 1.42 +OPENERR Can't open r/w the iso file. 1.43 +ELTORITOERR No EL TORITO SPECIFICATION signature. 1.44 +CATALOGERR Invalid boot catalog. 1.45 +HYBRIDERR No isolinux.bin hybrid signature. 1.46 +SUCCESSMSG Now you can create a USB key with your .iso file.\\\\nSimply rename it to a .exe file and run it. 1.47 +FORCEMSG You can add --forced to proceed anyway. 1.48 +EOT 1.49 +done 1.50 rm -rf $DATA 1.51 exit ;; 1.52 --exe) 1.53 @@ -148,14 +179,24 @@ 1.54 main() 1.55 { 1.56 [ $(id -u) -ne 0 ] && exec su -c "$0 $@" < /dev/tty 1.57 - case "$1" in 1.58 - --get) shift 1.59 + case "${1/--/-}" in 1.60 + -get) shift 1.61 uudecode | unlzma | tar xOf - $@ 1.62 exit ;; 1.63 *) cat > /dev/null 1.64 esac 1.65 1.66 - [ ! -s "$1" ] && echo "usage: $0 image.iso" 1>&2 && exit 1 1.67 + [ ! -s "$1" ] && echo "usage: $0 image.iso [--undo]" 1>&2 && exit 1 1.68 + case "${2/--/-}" in 1.69 + -u*|-r*|-w*) 1.70 + case "$(get 0 $1)" in 1.71 + 23117) 1.72 + ddq if=$1 bs=512 count=2 skip=$(get 69 $1 1) of=$1 conv=notrunc 1.73 + ddq if=/dev/zero bs=1k seek=1 count=31 of=$1 conv=notrunc ;; 1.74 + *) ddq if=/dev/zero bs=1k count=32 of=$1 conv=notrunc ;; 1.75 + esac 1.76 + exit 0 1.77 + esac 1.78 case "$(get 0 $1)" in 1.79 23117) echo "The file $1 is already an EXE file." 1>&2 && exit 1;; 1.80 0) [ -x /usr/bin/isohybrid ] && isohybrid $1 && echo "Do isohybrid"