wok rev 18824

syslinux/iso2exe.sh: show flavor.info size
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Jan 16 16:19:14 2016 +0100 (2016-01-16)
parents e574ee12df54
children df7942dc271b
files syslinux/stuff/iso2exe/iso2exe.sh
line diff
     1.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh	Sat Jan 16 10:00:54 2016 +0000
     1.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh	Sat Jan 16 16:19:14 2016 +0100
     1.3 @@ -15,7 +15,7 @@
     1.4  
     1.5  get()
     1.6  {
     1.7 -	echo $(od -j $(($1)) -N ${3:-2} -t u${3:-2} -An $2)
     1.8 +	echo $(od -j $(($1)) -N ${3:-2} -t u${3:-2} -An "$2")
     1.9  }
    1.10  
    1.11  compress()
    1.12 @@ -125,20 +125,34 @@
    1.13  	fi
    1.14  }
    1.15  
    1.16 +gzsize()
    1.17 +{
    1.18 +	echo $(($(hexdump -C | awk ' {
    1.19 +		for (i = 2; i < 18; i++) if ($i != "00") break;
    1.20 +		if (i == 18) {
    1.21 +			for (i = 17; i > 1; i--) if ($i != "00") break;
    1.22 +			print "0x" $1 " + 2 - " (16 - i) 
    1.23 +			exit
    1.24 +		}
    1.25 +	}')))
    1.26 +}
    1.27 +
    1.28  fileofs()
    1.29  {
    1.30 -	[ $(get 1024 $ISO) -eq 35615 ] && i=1024 || i=$((512*(1+$(get 417 $ISO 1))))
    1.31 -	stub=$(($(get 20 $ISO) - 0xC0))
    1.32 +	[ $(get 1024 "$ISO") -eq 35615 ] && i=1024 ||
    1.33 +	i=$((512*(1+$(get 417 "$ISO" 1))))
    1.34 +	stub=$(($(get 20 "$ISO") - 0xC0))
    1.35  	SIZE=0; OFFSET=0
    1.36  	case "$1" in
    1.37  	win32.exe)	[ $i -eq 1024 ] || SIZE=$(($i - 512));;
    1.38  	syslinux.mbr)	[ $i -eq 1024 ] || OFFSET=$(($i - 512)); SIZE=512;;
    1.39 -	flavor.info)	OFFSET=$i; SIZE=-1;;
    1.40 -	floppy.boot)	SIZE=$(($(get 26 $ISO 1)*512))
    1.41 -			OFFSET=$(($(get 64 $ISO) - 0xC0 - $SIZE));;
    1.42 -	rootfs.gz)	SIZE=$(get 24 $ISO); OFFSET=$(($stub - $SIZE));;
    1.43 -	tazboot.com)	OFFSET=$(($(get 64 $ISO) - 0xC0))
    1.44 -			SIZE=$(($stub - $(get 24 $ISO) - $OFFSET));;
    1.45 +	flavor.info)	OFFSET=$i
    1.46 +			SIZE=$(ddq bs=512 skip=$(($i/512)) if="$ISO" | gzsize);;
    1.47 +	floppy.boot)	SIZE=$(($(get 26 "$ISO" 1)*512))
    1.48 +			OFFSET=$(($(get 64 "$ISO") - 0xC0 - $SIZE));;
    1.49 +	rootfs.gz)	SIZE=$(get 24 "$ISO"); OFFSET=$(($stub - $SIZE));;
    1.50 +	tazboot.com)	OFFSET=$(($(get 64 "$ISO") - 0xC0))
    1.51 +			SIZE=$(($stub - $(get 24 "$ISO") - $OFFSET));;
    1.52  	dosstub)	OFFSET=$stub; SIZE=$((0x8000 - $OFFSET));;
    1.53  	md5)		OFFSET=$((0x7FF0)); SIZE=16;;
    1.54  	esac
    1.55 @@ -146,28 +160,31 @@
    1.56  
    1.57  list()
    1.58  {
    1.59 +	HEAP=0
    1.60 +	TOP=32768
    1.61  	for f in win32.exe syslinux.mbr flavor.info floppy.boot \
    1.62 -		 dosstub rootfs.gz tazboot.com md5 ; do
    1.63 +		 tazboot.com rootfs.gz dosstub md5 ; do
    1.64  		fileofs $f
    1.65  		[ $SIZE -eq 0 ] && continue
    1.66 -		[ -n "${OFFSET:6}" ] && continue
    1.67 +		[ "${OFFSET:6}" ] && continue
    1.68  		[ $OFFSET -lt 0 ] && continue
    1.69 -		[ $(get $OFFSET $ISO 2) -eq 0 ] && continue
    1.70 -		echo -n "$f at $(printf "%X\n" $OFFSET)"
    1.71 -		[ $SIZE -eq -1 ] || echo -n " ($SIZE bytes)"
    1.72 -		echo .
    1.73 +		[ $(get $OFFSET "$ISO") -eq 0 ] && continue
    1.74 +		printf "$f at %04X ($SIZE bytes).\n" $OFFSET
    1.75 +		if [ $OFFSET -le $i ]; then
    1.76 +			[ $OFFSET -ge $HEAP ] && HEAP=$(($OFFSET+$SIZE))
    1.77 +		else
    1.78 +			[ $OFFSET -lt $TOP ] && TOP=$OFFSET
    1.79 +		fi
    1.80  	done
    1.81 +	printf "%d free bytes in %04X..%04X\n" $(($TOP - $HEAP)) $HEAP $TOP
    1.82  }
    1.83  
    1.84  extract()
    1.85  {
    1.86  	for f in $@; do
    1.87  		fileofs $f
    1.88 -		case "$SIZE" in
    1.89 -		0) ;;
    1.90 -		-1) ddq bs=1 count=20480 skip=$OFFSET if="$ISO" | zcat >$f ;;
    1.91 -		*) ddq bs=1 count=$SIZE skip=$OFFSET if="$ISO" >$f ;;
    1.92 -		esac
    1.93 +		[ $SIZE -eq 0 ] ||
    1.94 +		ddq bs=1 count=$SIZE skip=$OFFSET if="$ISO" >$f
    1.95  	done
    1.96  }
    1.97