wok rev 13972

syslinux/iso2exe: add win32 stub
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Feb 05 23:32:17 2013 +0100 (2013-02-05)
parents 6f9ba9c78afe
children 3dd8f0cfd04b
files syslinux/receipt syslinux/stuff/iso2exe/Makefile syslinux/stuff/iso2exe/README syslinux/stuff/iso2exe/boot.c syslinux/stuff/iso2exe/bootiso.S syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/iso2exe.sh syslinux/stuff/iso2exe/win32.c
line diff
     1.1 --- a/syslinux/receipt	Mon Feb 04 12:44:22 2013 +0000
     1.2 +++ b/syslinux/receipt	Tue Feb 05 23:32:17 2013 +0100
     1.3 @@ -8,7 +8,7 @@
     1.4  TARBALL="$PACKAGE-$VERSION.tar.xz"
     1.5  WEB_SITE="http://syslinux.zytor.com/"
     1.6  WGET_URL="ftp://ftp.kernel.org/pub/linux/utils/boot/syslinux/$TARBALL"
     1.7 -BUILD_DEPENDS="kbd-base perl nasm dev86 lzma"
     1.8 +BUILD_DEPENDS="kbd-base perl nasm dev86 lzma mingw32-gcc upx"
     1.9  DEPENDS="gpxe memtest"
    1.10  CONFIG_FILES="/boot/isolinux"
    1.11  
     2.1 --- a/syslinux/stuff/iso2exe/Makefile	Mon Feb 04 12:44:22 2013 +0000
     2.2 +++ b/syslinux/stuff/iso2exe/Makefile	Tue Feb 05 23:32:17 2013 +0100
     2.3 @@ -2,15 +2,14 @@
     2.4  BCC=bcc -ansi -O -0 -C-t
     2.5  BCCFLAGS=-D__MSDOS__ -Md
     2.6  
     2.7 -iso2exe: iso2exe.sh bootiso.bin lzcom.bin boot.com init
     2.8 +iso2exe: iso2exe.sh boot.com bootiso.bin init win32.exe
     2.9  	cp iso2exe.sh $@
    2.10  	chmod +x $@
    2.11 -	lzma e boot.com boot.com.lzma -eos
    2.12 -	./$@ --build bootiso.bin lzcom.bin boot.com.lzma init
    2.13 +	./$@ --build boot.com bootiso.bin init win32.exe
    2.14  
    2.15  OBJS = boot.o iso9660.o libdos.o bootlinux.o
    2.16  boot.com: $(OBJS)
    2.17 -	$(BCC) $(BCCFLAGS) -o $@ $(OBJS)
    2.18 +	$(BCC) $(BCCFLAGS) -o $@ $(OBJS) &&  upx --ultra-brute $@
    2.19  
    2.20  boot.o: boot.c iso9660.h bootlinux.h libdos.h
    2.21  
    2.22 @@ -20,8 +19,9 @@
    2.23  
    2.24  libdos.o: libdos.c libdos.h
    2.25  
    2.26 -lzcom.bin: lzcom.S unlzma.S
    2.27 -
    2.28 +win32.exe: win32.c
    2.29 +	i586-pc-mingw32-gcc -s -o $@ $< -lws2_32 && upx --ultra-brute $@
    2.30 +	
    2.31  %.o: %.c
    2.32  	$(BCC) $(BCCFLAGS) -A-l -A$*.lst -c -o $@ $<
    2.33  
     3.1 --- a/syslinux/stuff/iso2exe/README	Mon Feb 04 12:44:22 2013 +0000
     3.2 +++ b/syslinux/stuff/iso2exe/README	Tue Feb 05 23:32:17 2013 +0100
     3.3 @@ -47,8 +47,8 @@
     3.4  - tazlito stores extra flavor info at the 2nd Kb for 'tazlito iso2flavor'.
     3.5  
     3.6  The iso2exe tool moves the isolinux boot sector, installs its own boot sector 
     3.7 -with a DOS .EXE header, and adds a DOS .COM Linux loader and an initramfs in 
     3.8 -the end of the first 32Kb.
     3.9 +with a DOS .EXE header, and adds a WIN32 .EXE installer, a DOS .COM Linux
    3.10 +loader and an initramfs in the end of the first 32Kb.
    3.11  
    3.12      +-----------------+
    3.13      |    untouched    | ISO9660 files including /boot/bzImage and /boot/rootfs*
    3.14 @@ -57,6 +57,8 @@
    3.15      +-----------------+
    3.16      | DOS .COM loader | Load bzImage, the last rootfs*.gz and the ISO initramfs
    3.17      +-----------------+
    3.18 +    |  WIN32 PE .exe  | Windows UMSDOS like installer / USB Key creator.
    3.19 +    +-----------------+
    3.20             unused
    3.21      +-----------------+
    3.22      |  tazlito info   | Flavor missing data for 'tazlito iso2flavor'
    3.23 @@ -64,7 +66,7 @@
    3.24      | isohybrid boot  | Starts isolinux.bin
    3.25  512 +-----------------+
    3.26      |  iso2exe boot   | Boot starts isohybrid (*), .EXE starts DOS .COM loader
    3.27 -  0 +-----------------+
    3.28 +  0 +-----------------+ or 32 bits Windows UMSDOS like installer
    3.29  
    3.30  * Eltorito boot (i.e. bootable CD-ROM by BIOS) is not concerned by iso2exe.
    3.31  
    3.32 @@ -77,6 +79,8 @@
    3.33  
    3.34  - Image/zImage format not supported, bzImage only. Can't boot memtest or gpxe.
    3.35  
    3.36 +- posixovl still needs fixes !
    3.37 +
    3.38  - The tiny Linux loader can't load more than 15Mb of files. (not really a 
    3.39    problem since many-in-1 ISO format).
    3.40  
     4.1 --- a/syslinux/stuff/iso2exe/boot.c	Mon Feb 04 12:44:22 2013 +0000
     4.2 +++ b/syslinux/stuff/iso2exe/boot.c	Tue Feb 05 23:32:17 2013 +0100
     4.3 @@ -42,7 +42,7 @@
     4.4  	loadkernel();
     4.5  	isoopen(rootfs);
     4.6  	loadinitrd();
     4.7 -	lseek(isofd, 28, SEEK_SET);
     4.8 +	lseek(isofd, 24, SEEK_SET);
     4.9  	read(isofd, &magic, 4);
    4.10  	isofilesize = magic & 0xFFFF;
    4.11  	isofileofs = 0x8000 - isofilesize;
     5.1 --- a/syslinux/stuff/iso2exe/bootiso.S	Mon Feb 04 12:44:22 2013 +0000
     5.2 +++ b/syslinux/stuff/iso2exe/bootiso.S	Tue Feb 05 23:32:17 2013 +0100
     5.3 @@ -3,14 +3,14 @@
     5.4  	.org	0
     5.5  
     5.6  CODESZ	=	0x8000			// 16 sectors = 32Kb
     5.7 -#define EXEADRS(x)	x+0xE0
     5.8 -#define EXESTR(x)	x-0x20
     5.9 +#define EXEADRS(x)	x+0xC0
    5.10 +#define EXESTR(x)	x-0x40
    5.11  
    5.12  	.globl	_start
    5.13  _start:
    5.14  	decw	%bp			// Magic number: MZ
    5.15  	popw	%dx
    5.16 -	jmp	start			// Bytes on last page of file
    5.17 +	jmp	start0			// Bytes on last page of file
    5.18  	.word	(CODESZ+511)/512	// Pages in file
    5.19  	.word	0			// Relocations
    5.20  	.word	(end_header-_start)/16	// Size of header in paragraphs
    5.21 @@ -21,24 +21,16 @@
    5.22  	.word	0			// Checksum
    5.23  	.word	EXEADRS(exestart)	// Initial IP value
    5.24  	.word	0xFFF0			// Initial (relative) CS value
    5.25 -	.word	0x001C			// File address of relocation table
    5.26 +initramfssize:
    5.27 +	.word	0			// File address of relocation table
    5.28 +id:
    5.29  	.word	0			// Overlay number
    5.30 -initramfssize:
    5.31 -	.word	0
    5.32 -id:
    5.33 -	.word	0
    5.34 -end_header:
    5.35 -
    5.36 -chksum:
    5.37 -	.word	0
    5.38 -comstart:
    5.39 -	.word	0
    5.40  
    5.41  /////////////////////// Master Boot Record code //////////////////////////////
    5.42  
    5.43 -start:
    5.44 -	incw	%bp
    5.45 +start0:					// File address of relocation table
    5.46  	pushw	%dx			// restore SP
    5.47 +	incw	%bp			// restore %bp
    5.48  	pushw	$0
    5.49  	popw	%ds
    5.50  	movw	$0x7C00, %bx
    5.51 @@ -48,10 +40,22 @@
    5.52  	pushaw
    5.53  	movw	%sp, %bp
    5.54  	pushw	%es
    5.55 +	cld
    5.56 +	pushw	%ds
    5.57 +	popw	%es
    5.58  	call	setreg
    5.59  	rep
    5.60  	movsw
    5.61 +	movw	$0x80, %dx
    5.62  	ljmp	$0, $0x0600+start2
    5.63 +
    5.64 +	.org	60
    5.65 +	.long	0			// PE header offset
    5.66 +end_header:
    5.67 +chksum:
    5.68 +	.word	0
    5.69 +comstart:
    5.70 +	.word	0
    5.71  	
    5.72  readsector2:
    5.73  	incw	%cx
    5.74 @@ -61,16 +65,12 @@
    5.75  	movw	$0x201, %ax
    5.76  	int	$0x13
    5.77  setreg:
    5.78 -	cld
    5.79 -	pushw	%ds
    5.80 -	popw	%es
    5.81  	movw	%bx, %si
    5.82  	movw	$0x0600, %di
    5.83  	movw	$0x0100, %cx
    5.84  return:
    5.85  	ret
    5.86  start2:
    5.87 -	movw	$0x80, %dx
    5.88  dxloop:
    5.89  	call	readsector1
    5.90  	repe
    5.91 @@ -122,7 +122,7 @@
    5.92  	.ascii	"Invalid: paging + "	// Invalid: paging + real mode.
    5.93  realmodemsg:
    5.94  	.ascii	"real"			// real mode.
    5.95 -// --------------- Must be in 00A0 011F range ------------------------
    5.96 +// --------------- Must be in 00C0 013F range ------------------------
    5.97  mode:
    5.98  	.ascii	" mod"
    5.99  eeol:
     6.1 --- a/syslinux/stuff/iso2exe/init	Mon Feb 04 12:44:22 2013 +0000
     6.2 +++ b/syslinux/stuff/iso2exe/init	Tue Feb 05 23:32:17 2013 +0100
     6.3 @@ -17,8 +17,8 @@
     6.4  gettazboot()
     6.5  {
     6.6  	echo "Creating $(basename $1) ..."
     6.7 -	O=$(($(get 34 /mnt/$ISO) - 0xE0))
     6.8 -	L=$((0x8000 - $(get 28 /mnt/$ISO) - $O))
     6.9 +	O=$(($(get 66 /mnt/$ISO) - 0xE0))
    6.10 +	L=$((0x8000 - $(get 24 /mnt/$ISO) - $O))
    6.11  	S=$((32+$L))
    6.12  	P=$((($S+511)/512))
    6.13  	E=$((4096-(32*$P)))
    6.14 @@ -32,7 +32,7 @@
    6.15  
    6.16  checkmagic()
    6.17  {
    6.18 -	[ -s $1 ] && [ $(getarg magic) == $(get 28 $1 4) ]
    6.19 +	[ -s $1 ] && [ $(getarg magic) == $(get 24 $1 4) ]
    6.20  }
    6.21  
    6.22  getiso()
     7.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh	Mon Feb 04 12:44:22 2013 +0000
     7.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh	Tue Feb 05 23:32:17 2013 +0100
     7.3 @@ -25,6 +25,11 @@
     7.4  	done | xargs echo -en | ddq bs=1 conv=notrunc of=$3 seek=$(($1))
     7.5  }
     7.6  
     7.7 +get()
     7.8 +{
     7.9 +	echo $(od -j $(($1)) -N ${3:-2} -t u${3:-2} -An $2)
    7.10 +}
    7.11 +
    7.12  main()
    7.13  {
    7.14  	case "$1" in
    7.15 @@ -58,25 +63,36 @@
    7.16  	( cd $TMP ; find * | cpio -o -H newc ) | \
    7.17  		lzma e $TMP/rootfs.gz -si 2> /dev/null
    7.18  	SIZE=$(wc -c < $TMP/rootfs.gz)
    7.19 -	store 28 $SIZE $1
    7.20 +	store 24 $SIZE $1
    7.21  	OFS=$(( 0x8000 - $SIZE ))
    7.22  	printf "Adding rootfs.gz file at %04X...\n" $OFS
    7.23  	cat $TMP/rootfs.gz | ddq of=$1 bs=1 seek=$OFS conv=notrunc
    7.24  	rm -rf $TMP
    7.25 -	SIZE=$($0 --get lzcom.bin boot.com.lzma | wc -c)
    7.26 +	SIZE=$($0 --get boot.com | wc -c)
    7.27  	OFS=$(( $OFS - $SIZE ))
    7.28  	printf "Adding DOS boot file at %04X...\n" $OFS
    7.29 -	$0 --get lzcom.bin boot.com.lzma | ddq of=$1 bs=1 seek=$OFS conv=notrunc
    7.30 -	store 34 $(($OFS+0xE0)) $1
    7.31 -	store 30 ${RANDOM:-0} $1
    7.32 +	$0 --get boot.com | ddq of=$1 bs=1 seek=$OFS conv=notrunc
    7.33 +	store 66 $(($OFS+0xC0)) $1
    7.34 +	SIZE=$($0 --get win32.exe | tee /tmp/exe$$ | wc -c)
    7.35 +	OFS=$(( 128 + ( ($OFS - $SIZE + 128) & 0xFE00 ) ))
    7.36 +	printf "Adding WIN32 file at %04X...\n" $OFS
    7.37 +	LOC=$((0xAC+$(get 0x94 /tmp/exe$$)))
    7.38 +	for i in $(seq 1 $(get 0x86 /tmp/exe$$)); do
    7.39 +		store $LOC $(($(get $LOC /tmp/exe$$)+$OFS-128)) /tmp/exe$$
    7.40 +		LOC=$(($LOC+40))
    7.41 +	done
    7.42 +	ddq if=/tmp/exe$$ of=$1 bs=1 skip=128 seek=$OFS conv=notrunc
    7.43 +	rm -f /tmp/exe$$ 
    7.44 +	store 60 $OFS $1
    7.45 +	store 26 ${RANDOM:-0} $1
    7.46  	i=34
    7.47  	n=0
    7.48  	echo -n "Adding checksum..."
    7.49  	while [ $i -lt 32768 ]; do
    7.50 -		n=$(($n + $(od -j $i -N 2 -t u2 -An $1) ))
    7.51 +		n=$(($n + $(get $i $1) ))
    7.52  		i=$(($i + 2))
    7.53  	done
    7.54 -	store 32 -$n $1
    7.55 +	store 64 -$n $1
    7.56  	echo " done."
    7.57  }
    7.58  
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/syslinux/stuff/iso2exe/win32.c	Tue Feb 05 23:32:17 2013 +0100
     8.3 @@ -0,0 +1,6 @@
     8.4 +#include <stdio.h>
     8.5 +
     8.6 +int main()
     8.7 +{
     8.8 +	printf("No support for Windows yet.\n");
     8.9 +}