wok-current rev 18848
syslinux/iso2exe: show custom files
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Jan 24 16:04:35 2016 +0100 (2016-01-24) |
parents | c05d347e9bb5 |
children | afe32d499d75 |
files | syslinux/stuff/iso2exe/iso2exe.sh |
line diff
1.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Sat Jan 23 11:28:22 2016 +0100 1.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Sun Jan 24 16:04:35 2016 +0100 1.3 @@ -142,6 +142,7 @@ 1.4 [ $(get 1024 "$ISO") -eq 35615 ] && i=1024 || 1.5 i=$((512*(1+$(get 417 "$ISO" 1)))) 1.6 stub=$(($(get 20 "$ISO") - 0xC0)) 1.7 + c=$(custom_config_sector "$ISO") 1.8 SIZE=0; OFFSET=0 1.9 case "$1" in 1.10 win32.exe) [ $i -eq 1024 ] || SIZE=$(($i - 512));; 1.11 @@ -154,29 +155,42 @@ 1.12 tazboot.com) OFFSET=$(($(get 64 "$ISO") - 0xC0)) 1.13 SIZE=$(($stub - $(get 24 "$ISO") - $OFFSET));; 1.14 dosstub) OFFSET=$stub; SIZE=$((0x8000 - $OFFSET));; 1.15 - md5) OFFSET=$((0x7FF0)); SIZE=16;; 1.16 + boot.md5) OFFSET=$((0x7FF0)); SIZE=16;; 1.17 + fs.iso) OFFSET=$((0x8000)) 1.18 + SIZE=$((2048*$c - $OFFSET));; 1.19 + custom.magic) ddq bs=2k skip=$c if="$ISO" | ddq bs=1 count=6 | \ 1.20 + grep -q '#!boot' && OFFSET=$((2048*$c)) && 1.21 + SIZE=39 ;; 1.22 + custom.append) OFFSET=$((2048*$c+47)) && 1.23 + SIZE=$(ddq bs=2k skip=$c if="$ISO" count=1 | \ 1.24 + sed '/^append=/!d;s/^[^=]*=.//' | wc -c);; 1.25 + custom.initrd) i=$(ddq bs=2k skip=$c if="$ISO" count=1 | \ 1.26 + sed '/^append=\|^initrd:/!d' | wc -c) 1.27 + OFFSET=$((2048*$c+$i+40)) 1.28 + SIZE=$(($(ddq bs=2k skip=$c if="$ISO" count=1 | \ 1.29 + sed '/^initrd:/!d;s/.*://') + 0));; 1.30 esac 1.31 } 1.32 1.33 list() 1.34 { 1.35 HEAP=0 1.36 - TOP=32768 1.37 - for f in win32.exe syslinux.mbr flavor.info floppy.boot \ 1.38 - tazboot.com rootfs.gz dosstub md5 ; do 1.39 + for f in win32.exe syslinux.mbr flavor.info floppy.boot tazboot.com \ 1.40 + rootfs.gz dosstub boot.md5 fs.iso custom.magic custom.append \ 1.41 + custom.initrd; do 1.42 fileofs $f 1.43 - [ $SIZE -eq 0 ] && continue 1.44 - [ "${OFFSET:6}" ] && continue 1.45 + [ $SIZE -le 0 ] && continue 1.46 + [ "${OFFSET:8}" ] && continue 1.47 [ $OFFSET -lt 0 ] && continue 1.48 [ $(get $OFFSET "$ISO") -eq 0 ] && continue 1.49 + [ $OFFSET -gt $HEAP ] && [ $(($OFFSET - $HEAP)) -gt 16 ] && 1.50 + printf "%d free bytes in %04X..%04X\n" $(($OFFSET - $HEAP)) $HEAP $OFFSET 1.51 + [ $OFFSET -ge $HEAP ] && HEAP=$(($OFFSET+$SIZE)) 1.52 printf "$f at %04X ($SIZE bytes).\n" $OFFSET 1.53 - if [ $OFFSET -le $i ]; then 1.54 - [ $OFFSET -ge $HEAP ] && HEAP=$(($OFFSET+$SIZE)) 1.55 - else 1.56 - [ $OFFSET -lt $TOP ] && TOP=$OFFSET 1.57 - fi 1.58 done 1.59 - printf "%d free bytes in %04X..%04X\n" $(($TOP - $HEAP)) $HEAP $TOP 1.60 + OFFSET=$(stat -c %s "$ISO") 1.61 + [ $OFFSET -gt $HEAP ] && 1.62 + printf "%d free bytes in %04X..%04X\n" $(($OFFSET - $HEAP)) $HEAP $OFFSET 1.63 } 1.64 1.65 extract() 1.66 @@ -200,25 +214,6 @@ 1.67 [ $cnt -ne 512 ] && 1.68 ddq if=/dev/zero of=$1 bs=2k seek=$start count=$cnt 1.69 } 1.70 - 1.71 -extract_custom_config() 1.72 -{ 1.73 - ISO="$1" 1.74 - header= 1.75 - ddq bs=2k skip=$(custom_config_sector "$ISO") if="$ISO" | \ 1.76 - while read line; do 1.77 - case "$line" in 1.78 - \#!boot*) header=1 ;; 1.79 - append=*) [ "$header" ] && 1.80 - echo "${line#append=}" > "$ISO.append" && 1.81 - ls -l "$ISO.append" ;; 1.82 - initrd:*) [ "$header" ] && 1.83 - ddq bs=1 count=${line#initrd:} > "$ISO.initrd" && 1.84 - ls -l "$ISO.initrd" ;; 1.85 - esac 1.86 - [ "$header" ] || break 1.87 - done 1.88 -} 1.89 case "$1" in 1.90 --build) 1.91 shift 1.92 @@ -365,9 +360,8 @@ 1.93 exit ;; 1.94 -a*) append="$2" ; shift 2 ;; 1.95 -i*) initrd="$2" ; shift 2 ;; 1.96 - -e*) extract_custom_config "$2" 1.97 - exit ;; 1.98 - -r*) ISO="$2" ; shift 2 1.99 + -r*|-l*) 1.100 + ISO="$2" ; shift 2 1.101 [ -z "$1" ] && list || extract $@ 1.102 exit ;; 1.103 *) cat > /dev/null 1.104 @@ -376,8 +370,7 @@ 1.105 done 1.106 1.107 [ ! -s "$1" ] && cat 1>&2 <<EOT && exit 1 1.108 -usage: $0 [--append custom_cmdline ] [ --initrd custom_initramfs ] image.iso [--force|--undo|"DOS help message"] 1.109 -or: $0 --extract-custom-config image.iso 1.110 +usage: $0 [--list|--read] [--append custom_cmdline ] [ --initrd custom_initrd ] image.iso [--force|--undo|"DOS help message"|filename...] 1.111 EOT 1.112 case "${2/--/-}" in 1.113 -u*|-r*|-w*|-f*)