wok diff syslinux/stuff/iso2exe/iso2exe.sh @ rev 17454

syslinux/iso2exe: create a vfat partition in usb bootkey (DOS case only)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Dec 18 11:42:27 2014 +0100 (2014-12-18)
parents aca562aa836e
children 9a40226bee2e
line diff
     1.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh	Wed Dec 17 12:25:20 2014 +0100
     1.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh	Thu Dec 18 11:42:27 2014 +0100
     1.3 @@ -26,14 +26,15 @@
     1.4  	$0 --get init > $TMP/init.exe
     1.5  	grep -q mount.posixovl.iso2exe $TMP/init.exe &&
     1.6  	cp /usr/sbin/mount.posixovl $TMP/bin/mount.posixovl.iso2exe \
     1.7 -		2> /dev/null && echo "Store mount.posixovl..."
     1.8 +		2> /dev/null && echo "Store mount.posixovl ($(wc -c \
     1.9 +			< /usr/sbin/mount.posixovl) bytes) ..."
    1.10  	find $TMP -type f -print0 | xargs -0 chmod +x
    1.11  	( cd $TMP ; find * | cpio -o -H newc ) | \
    1.12  		lzma e $TMP/rootfs.gz -si 2> /dev/null
    1.13  	SIZE=$(wc -c < $TMP/rootfs.gz)
    1.14  	store 24 $SIZE $1
    1.15  	OFS=$(( $OFS - $SIZE ))
    1.16 -	printf "Adding rootfs.gz file at %04X...\n" $OFS
    1.17 +	printf "Adding rootfs.gz file at %04X (%d bytes) ...\n" $OFS $SIZE
    1.18  	cat $TMP/rootfs.gz | ddq of=$1 bs=1 seek=$OFS conv=notrunc
    1.19  	rm -rf $TMP
    1.20  }
    1.21 @@ -41,7 +42,7 @@
    1.22  add_dosexe()
    1.23  {
    1.24  	OFS=$((0x7EE0))
    1.25 -	printf "Adding DOS/EXE at %04X...\n" $OFS
    1.26 +	printf "Adding DOS/EXE at %04X (%d bytes) ...\n" $OFS $((0x8000 - $OFS))
    1.27  	$0 --get bootiso.bin 2> /dev/null | \
    1.28  	ddq bs=1 skip=$OFS of=$1 seek=$OFS conv=notrunc
    1.29  }
    1.30 @@ -50,16 +51,16 @@
    1.31  {
    1.32  	SIZE=$($0 --get boot.com | wc -c)
    1.33  	OFS=$(( $OFS - $SIZE ))
    1.34 -	printf "Adding DOS boot file at %04X...\n" $OFS
    1.35 +	printf "Adding DOS boot file at %04X (%d bytes) ...\n" $OFS $SIZE
    1.36  	$0 --get boot.com | ddq of=$1 bs=1 seek=$OFS conv=notrunc
    1.37  	store 66 $(($OFS+0xC0)) $1
    1.38  }
    1.39  
    1.40  add_win32exe()
    1.41  {
    1.42 -	printf "Adding WIN32 file at %04X...\n" 0
    1.43  	ddq if=/tmp/exe$$ of=$1 conv=notrunc
    1.44  	SIZE=$($0 --get win32.exe 2> /dev/null | tee /tmp/exe$$ | wc -c)
    1.45 +	printf "Adding WIN32 file at %04X (%d bytes) ...\n" 0 $SIZE
    1.46  	ddq if=/tmp/exe$$ of=$1 conv=notrunc
    1.47  	printf "Adding bootiso head at %04X...\n" 0
    1.48  	$0 --get bootiso.bin 2> /dev/null > /tmp/exe$$
    1.49 @@ -73,7 +74,7 @@
    1.50  	store 69 $(($SIZE/512)) $1 8
    1.51  	store 510 $((0xAA55)) $1
    1.52  	rm -f /tmp/exe$$ /tmp/coff$$
    1.53 -	printf "Moving syslinux hybrid boot record at %04X ...\n" $SIZE
    1.54 +	printf "Moving syslinux hybrid boot record at %04X (512 bytes) ...\n" $SIZE
    1.55  	ddq if=$2 bs=1 count=512 of=$1 seek=$SIZE conv=notrunc
    1.56  	OFS=$(($SIZE+512))
    1.57  }
    1.58 @@ -82,13 +83,14 @@
    1.59  {
    1.60  	SIZE=$($0 --get bootfd.bin 2> /dev/null | wc -c)
    1.61  	if [ $SIZE -ne 0 ]; then
    1.62 -		OFS=$(( $OFS - $SIZE + 512 ))
    1.63 -		printf "Adding floppy bootstrap file at %04X...\n" $OFS
    1.64 +		SIZE=$(( $SIZE -  512 )) # sector 2 is data
    1.65 +		OFS=$(( $OFS - $SIZE ))
    1.66 +		printf "Adding floppy bootstrap file at %04X (%d bytes) ...\n" $OFS $SIZE
    1.67  		$0 --get bootfd.bin | \
    1.68  		ddq of=$1 bs=1 count=512 seek=$OFS conv=notrunc
    1.69  		$0 --get bootfd.bin | \
    1.70  		ddq of=$1 bs=1 skip=1024 seek=$((512 + $OFS)) conv=notrunc
    1.71 -		store 28 $(($SIZE/512 - 1)) $1 8
    1.72 +		store 28 $(($SIZE/512)) $1 8
    1.73  	fi
    1.74  }
    1.75  case "$1" in
    1.76 @@ -206,15 +208,17 @@
    1.77  	ddq if=$1 bs=512 count=1 of=/tmp/hybrid$$
    1.78  	ddq if=$1 bs=512 skip=2 count=20 of=/tmp/tazlito$$
    1.79  	add_win32exe $1 /tmp/hybrid$$
    1.80 -	printf "Moving tazlito data record at %04X ...\n" $OFS
    1.81 +	printf "Moving tazlito data record at %04X (512 bytes) ...\n" $OFS
    1.82  	ddq if=/tmp/tazlito$$ bs=1 count=512 of=$1 seek=$OFS conv=notrunc
    1.83  	rm -f /tmp/tazlito$$ /tmp/hybrid$$
    1.84 +	HOLE=$(($OFS+512))
    1.85  	
    1.86  	# keep the largest room for the tazlito info file
    1.87  	add_dosexe $1
    1.88  	add_rootfs $1
    1.89  	add_doscom $1
    1.90  	add_fdbootstrap $1
    1.91 +	printf "%d free bytes in %04X..%04X\n" $(($OFS-$HOLE)) $HOLE $OFS
    1.92  	store 26 ${RANDOM:-0} $1
    1.93  	i=66
    1.94  	n=0