wok-next rev 17562

syslinux/iso2exe: use iso size to compute md5sum
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Feb 07 15:39:46 2015 +0100 (2015-02-07)
parents 4460c3cc7f05
children fc3051b88ee8
files syslinux/stuff/iso2exe/boot.c syslinux/stuff/iso2exe/bootiso.S syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/iso2exe.sh syslinux/stuff/iso2exe/libdos.c syslinux/stuff/iso2exe/libdos.h
line diff
     1.1 --- a/syslinux/stuff/iso2exe/boot.c	Fri Feb 06 22:54:07 2015 +0000
     1.2 +++ b/syslinux/stuff/iso2exe/boot.c	Sat Feb 07 15:39:46 2015 +0100
     1.3 @@ -158,16 +158,7 @@
     1.4  			cmdfile = argv[1] + 1;
     1.5  		else {
     1.6  			cmdfile = NULL;
     1.7 -#asm
     1.8 -		push	ds
     1.9 -		pop	es
    1.10 -		mov	si, #0x82
    1.11 -		mov	di, #_args
    1.12 -		mov	cx, #0x7E/2
    1.13 -		rep
    1.14 -		 seg	cs
    1.15 -		  movsw
    1.16 -#endasm
    1.17 +			copycmdline(args);
    1.18  		}
    1.19  	}
    1.20  	if (cmdfile) {
     2.1 --- a/syslinux/stuff/iso2exe/bootiso.S	Fri Feb 06 22:54:07 2015 +0000
     2.2 +++ b/syslinux/stuff/iso2exe/bootiso.S	Sat Feb 07 15:39:46 2015 +0100
     2.3 @@ -119,7 +119,7 @@
     2.4  	jmp	halt
     2.5  	.org	0x01BE
     2.6  
     2.7 -	.org	0x7F10
     2.8 +	.org	0x7F26
     2.9  ////////////////////////////// DOS EXE code ///////////////////////////////////
    2.10  
    2.11  exestart:
    2.12 @@ -134,14 +134,16 @@
    2.13  	cwd				// clear dx
    2.14  	pushw	%dx			// dos exit()
    2.15  	je	abort
    2.16 +	pushw	%si
    2.17  	int	$0x21			// get DOS version
    2.18 -	cmpb	$3, %al
    2.19 +	popw	%di			// %di = 0x100: .COM start address
    2.20 +	addb	$-3, %al
    2.21  	movb	$EXESTR(noDOS3), %al
    2.22 -	jb	abort
    2.23 +	jnc	abort
    2.24  	movw	$(EXELOC(0x8000))/2, %cx
    2.25  chklp:
    2.26  	lodsw
    2.27 -	addw	%ax, %dx
    2.28 +	addw	%ax, %dx	// break C
    2.29  	loop	chklp
    2.30  chked:
    2.31  	movw	$0x1000+EXESTR(chkerr), %ax
    2.32 @@ -164,15 +166,11 @@
    2.33  	addb	%ah, %bh	// test F0 and 00 cases
    2.34  	cmpb	%ah, %bh
    2.35  	movb	$EXESTR(no386), %al
    2.36 -#undef NEED386
    2.37 -#ifdef NEED386
    2.38 -	jbe	abort		// C=8086/80186, Z=80286
    2.39 -#else
    2.40  	jbe	is86		// C=8086/80186, Z=80286
    2.41 -#endif
    2.42  is386:
    2.43  	smsww	%ax		// not privileged
    2.44  	andb	$1, %al
    2.45 +	movw	$10, %si
    2.46  	jne	tstvcpi
    2.47  	movl	%cr0, %eax	// privileged
    2.48  	incl	%eax
    2.49 @@ -182,7 +180,6 @@
    2.50  realmode:
    2.51  is86:
    2.52  	call	puts
    2.53 -	movw	$0x0100, %di
    2.54  	movw	comstart-end_header(%di), %si		// .com address
    2.55  	pushw	%di
    2.56  	movb	$0x7C/2, %ch	// 31K-31.5K, > com length
    2.57 @@ -191,15 +188,13 @@
    2.58  	ret
    2.59  
    2.60  VersionVCPI:
    2.61 -	cmpb	$0x40, %dl		// >= 4.0 ?
    2.62 -	jb	NoVCPI
    2.63  	xchgw	%ax, %si		// movb	$EXESTR(vm86modemsg), %al
    2.64 -	jmp	realmode
    2.65 +	cmpb	$0x40, %cl		// EMM386 / VCPI 4.0 mini
    2.66 +	jnc	realmode		// %si = 0
    2.67  tstvcpi:
    2.68  	pushw	%ds
    2.69  	movw	%dx, %ds		// %dx = 0
    2.70  	movw	0x67*4+2, %ds
    2.71 -	movw	$10, %si
    2.72  	lodsw
    2.73  	xorw	$0x4D45, %ax		// EM(MX) or EM(MQ)
    2.74  	lodsw
    2.75 @@ -217,7 +212,7 @@
    2.76  	je	VersionVCPI
    2.77  	int	$0x67
    2.78  	testb	%ah, %ah
    2.79 -	xchgw	%ax, %dx
    2.80 +	xchgw	%ax, %cx
    2.81  	jmp	ChkVCPI
    2.82  CmdVCPI:
    2.83  	.byte	0x40			// status
    2.84 @@ -227,39 +222,36 @@
    2.85  
    2.86  vm86modemsg:
    2.87  // --------------- Must be in 7F40 7FFF range ------------------------
    2.88 -	.ascii	"vm"			// vm86
    2.89 -	.byte	EXESTR(_86)
    2.90 +	.ascii	"vm86"			// vm86 mode
    2.91 +	.byte	EXESTR(mode)
    2.92  ERRvcpi:
    2.93 -	.ascii	"No VCPI-4.0/EMM"	// No VCPI-4.0/EMM386
    2.94 -	.byte	EXESTR(_386)
    2.95 -noDOS3:
    2.96 -	.ascii	"No DOS 3"		// No DOS 3
    2.97 -	.byte	EXESTR(eol)
    2.98 +	.ascii	"EMM"			// EMM386 need
    2.99 +no386:
   2.100 +	.ascii	"386"			// 386 need
   2.101 +	.byte	EXESTR(need)
   2.102  chkerr:
   2.103 -	.ascii	"Broken c"		// Broken code
   2.104 +	.ascii	"Bad c"			// Bad code
   2.105  	.byte	EXESTR(ode)
   2.106  rmPaging:
   2.107  	.ascii	"Un"			// Unreal mode
   2.108  realmodemsg:
   2.109 -	.ascii	"real m"		// real mode
   2.110 +	.ascii	"real"			// real mode
   2.111  // --------------- Must be in 7FC0 7FFF range ------------------------
   2.112 +mode:
   2.113 +	.ascii	" m"
   2.114  ode:
   2.115 -	.ascii	"od"
   2.116 -eeol:
   2.117 -	.ascii  "e"
   2.118 +	.ascii	"ode"
   2.119  	.byte	EXESTR(eol)
   2.120 -no386:
   2.121 -	.ascii	"No "			// No 386
   2.122 -_386:
   2.123 -	.ascii	"3"
   2.124 -_86:
   2.125 -	.ascii	"86"
   2.126 +noDOS3:
   2.127 +	.ascii	"DOS3"			// DOS3 need
   2.128 +need:
   2.129 +	.ascii	" need"
   2.130  	.byte	EXESTR(eol)
   2.131  help:
   2.132 -	.ascii	"SliTaz boot loader"	// SliTaz boot loader
   2.133 +	.ascii	"SliTaz iso boot"	// SliTaz iso boot
   2.134  eol:
   2.135  	.ascii	"\r\n"
   2.136 -	.byte	1
   2.137 +	.byte	1			// putstr will return
   2.138  
   2.139  	.space	16,0			// ISO md5
   2.140  	.org	0x8000
     3.1 --- a/syslinux/stuff/iso2exe/init	Fri Feb 06 22:54:07 2015 +0000
     3.2 +++ b/syslinux/stuff/iso2exe/init	Sat Feb 07 15:39:46 2015 +0100
     3.3 @@ -70,8 +70,9 @@
     3.4  			done >> /tmp/data
     3.5  			while ! grep -q "^$n	" /tmp/data ; do
     3.6  				clear
     3.7 -				[ $(wc -l < /tmp/data) -gt 20 ] && 
     3.8 -				less /tmp/data || cat /tmp/data
     3.9 +				[ $(wc -l < /tmp/data) -gt 22 ] && 
    3.10 +				sed 's/..3.;4.m/===/g;$aPress q to continue' \
    3.11 +				/tmp/data | less || cat /tmp/data
    3.12  				echo -en "\n   <- Enter the selection number\r"
    3.13  				read n
    3.14  			done 2> /dev/null
    3.15 @@ -637,22 +638,24 @@
    3.16  
    3.17  gotisomd5()
    3.18  {
    3.19 +	[ "$(which md5sum 2> /dev/null)" ] &&
    3.20  	[ $(get 18 /dev/loop0) -ne 0 ] && echo -en "\"$1\"	\"$2\""
    3.21  }
    3.22  
    3.23  isomd5()
    3.24  {
    3.25  	dotwait "Checking iso image"
    3.26 -	[ "$(ddq if=/dev/loop0 bs=32k skip=1 | md5sum)" == \
    3.27 +	[ "$(ddq if=/dev/loop0 bs=2k skip=16 \
    3.28 +	     count=$(echo $(get 32848 /dev/loop0)) | md5sum)" == \
    3.29  	  "$(ddq if=/dev/loop0 bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \
    3.30  	     sed 's/ //g')  -" ] && echo "OK" || echo "ERROR"
    3.31 -	echo -n "Checking iso hybrid boot"
    3.32 +	echo -en "\rChecking iso hybrid boot"
    3.33  	n=$(($(get 2 /dev/loop0)-1+($(get 4 /dev/loop0)-1)*512))
    3.34  	s=$(get 0 /dev/loop0 2 $n | awk '{ i+= $0 } END { print i }')
    3.35  	[ $(((1+$s+$(get $(($n+1)) /dev/loop0 1)) % 65536)) -eq 0 ] &&
    3.36  	echo "OK" || echo "ERROR"
    3.37  	rm -f /tmp/wait
    3.38 -	echo "Press RETURN to continue."
    3.39 +	echo -e "\rPress RETURN to continue."
    3.40  	read n
    3.41  }
    3.42  
    3.43 @@ -746,11 +749,11 @@
    3.44  			$ll $lh $(($n & 0xFFFF)) $(($n >> 16)) | \
    3.45  			ddq bs=1 seek=446 of=$device
    3.46  		if [ "$(which mkdosfs 2> /dev/null)" ]; then
    3.47 -			losetup -o $((512*$ofs)) /dev/loop0 $device
    3.48 -			mkdosfs -n "SLITAZ BOOT" /dev/loop0
    3.49 +			losetup -o $((512*$ofs)) /dev/loop2 $device
    3.50 +			mkdosfs -n "SLITAZ BOOT" /dev/loop2
    3.51  			words2bin $(($ofs & 0xFFFF)) $(($ofs >> 16)) | \
    3.52 -				ddq bs=1 seek=28 of=/dev/loop0
    3.53 -			losetup -d /dev/loop0
    3.54 +				ddq bs=1 seek=28 of=/dev/loop2
    3.55 +			losetup -d /dev/loop2
    3.56  		fi
    3.57   	fi ; }
    3.58  }
    3.59 @@ -831,7 +834,8 @@
    3.60  {
    3.61  	n=0
    3.62  	dotwait "Extract filesystem..."
    3.63 -	for i in $(ls_r /media/cdrom/boot/rootfs*); do
    3.64 +	for i in $(ls_r /media/cdrom/boot/rootfs*gz); do
    3.65 +		grep -q ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64
    3.66  		[ $((n++)) -eq 0 ] || uncpio $i
    3.67  	done
    3.68  	rm -f /tmp/wait
     4.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh	Fri Feb 06 22:54:07 2015 +0000
     4.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh	Sat Feb 07 15:39:46 2015 +0100
     4.3 @@ -205,7 +205,8 @@
     4.4  	*)	cat > /dev/null
     4.5  	esac
     4.6  	
     4.7 -	[ ! -s "$1" ] && echo "usage: $0 image.iso [--undo]" 1>&2 && exit 1
     4.8 +	[ ! -s "$1" ] &&
     4.9 +	echo "usage: $0 image.iso [--undo|\"DOS help message\"]" 1>&2 && exit 1
    4.10  	case "${2/--/-}" in
    4.11  	-u*|-r*|-w*)
    4.12  	    case "$(get 0 $1)" in
    4.13 @@ -237,10 +238,13 @@
    4.14  	add_fdbootstrap $1
    4.15  	printf "%d free bytes in %04X..%04X\n" $(($OFS-$HOLE)) $HOLE $OFS
    4.16  	store 26 ${RANDOM:-0} $1
    4.17 -	if [ $(stat -c %s $1) -gt 32768 ]; then
    4.18 -		echo "Adding ISO image md5 ..."
    4.19 -		echo -en "$(ddq if=$1 bs=32k skip=1 | md5sum | cut -c-32 | sed \
    4.20 -		  's/\(..\)/\\x\1/g')" | ddq bs=16 seek=2047 conv=notrunc of=$1
    4.21 +	[ "$2" ] && echo "$2               " | \
    4.22 +		ddq bs=1 seek=$((0x7FDE)) count=15 conv=notrunc of=$1
    4.23 +	if [ $(stat -c %s $1) -gt 34816 ]; then
    4.24 +		echo "Adding ISO image md5 at 7FF0 (16 bytes) ..."
    4.25 +		echo -en "$(ddq if=$1 bs=2k skip=16 count=$(get 32848 $1) | \
    4.26 +			md5sum | cut -c-32 | sed 's/\(..\)/\\x\1/g')" | \
    4.27 +			ddq bs=16 seek=2047 conv=notrunc of=$1
    4.28  	fi
    4.29  	echo -n "Adding boot checksum..."
    4.30  	store 64 $(od -v -j 66 -N 32702 -t u2 -w2 -An $1 | \
     5.1 --- a/syslinux/stuff/iso2exe/libdos.c	Fri Feb 06 22:54:07 2015 +0000
     5.2 +++ b/syslinux/stuff/iso2exe/libdos.c	Sat Feb 07 15:39:46 2015 +0100
     5.3 @@ -189,3 +189,27 @@
     5.4  		mov	_versiondos, ax
     5.5  #endasm
     5.6  }
     5.7 +
     5.8 +void copycmdline(char store[])
     5.9 +{
    5.10 +#asm
    5.11 +		push	si
    5.12 +		push	di
    5.13 +		push	ds
    5.14 +		pop	es
    5.15 +		mov	si, #0x81
    5.16 +space:
    5.17 +		seg	cs
    5.18 +		lodsb
    5.19 +		cmp	al, #0x20
    5.20 +		je	space
    5.21 +		dec	si
    5.22 +		mov	di, [bp+4]
    5.23 +		mov	cx, #0x80/2
    5.24 +		rep
    5.25 +		 seg	cs
    5.26 +		  movsw
    5.27 +		pop	di
    5.28 +		pop	si
    5.29 +#endasm
    5.30 +}
     6.1 --- a/syslinux/stuff/iso2exe/libdos.h	Fri Feb 06 22:54:07 2015 +0000
     6.2 +++ b/syslinux/stuff/iso2exe/libdos.h	Sat Feb 07 15:39:46 2015 +0100
     6.3 @@ -9,10 +9,18 @@
     6.4  extern void dosshutdown(void);
     6.5  extern int versiondos;
     6.6  extern int dosversion(void);
     6.7 +extern void copycmdline(char store[]);
     6.8  # else
     6.9  #define progname() (argv[0])
    6.10  #define chdirname(x) chdir(dirname(x))
    6.11  #define dosshutdown()
    6.12  #define dosversion() (0)
    6.13 +#define copycmdline(x) { \
    6.14 +	int n; \
    6.15 +	char *s, *p; \
    6.16 +	for (n = 1, s = x; n < argc; n++, *s++ = ' ') \
    6.17 +		for (p = argv[n]; *p; *s++ = *p++); \
    6.18 +	*s = 0; \
    6.19 +}
    6.20  # endif
    6.21  #endif