wok rev 17491

syslinux/iso2exe: speedup crc
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Jan 02 21:46:16 2015 +0100 (2015-01-02)
parents 3cbe0810030e
children aa46cf9cc35a
files syslinux/stuff/iso2exe/boot.c syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/iso2exe.sh
line diff
     1.1 --- a/syslinux/stuff/iso2exe/boot.c	Fri Jan 02 18:34:02 2015 +0000
     1.2 +++ b/syslinux/stuff/iso2exe/boot.c	Fri Jan 02 21:46:16 2015 +0100
     1.3 @@ -17,8 +17,8 @@
     1.4    kernel=boot/bzImage\n\
     1.5    initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz,\\slitaz\\extrafs.gz\n\
     1.6    rw root=/dev/null vga=normal autologin\n\n\
     1.7 -  kernel=\\slitaz\\vmlinuz\n\
     1.8 -  root=/dev/sda5 ro\n",iso,iso,iso);
     1.9 +  kernel=\\slitaz\\elks\n\
    1.10 +  root=/dev/bda1 ro\n",iso,iso,iso);
    1.11  	exit(1);
    1.12  }
    1.13  
    1.14 @@ -39,7 +39,6 @@
    1.15  	do {
    1.16  		if (!isoopen(mode)	||	// custom
    1.17  		    !isoopen("bzImage")	|| 	// SliTaz
    1.18 -		    !isoopen("linux24")	||	// dsl
    1.19  		    !isoopen("vmlinuz")	||	// misc
    1.20  		    (!isoopen("linux") && ++isknoppix)) {
    1.21  			magic = loadkernel();
     2.1 --- a/syslinux/stuff/iso2exe/init	Fri Jan 02 18:34:02 2015 +0000
     2.2 +++ b/syslinux/stuff/iso2exe/init	Fri Jan 02 21:46:16 2015 +0100
     2.3 @@ -9,8 +9,8 @@
     2.4  
     2.5  get()
     2.6  {
     2.7 -	od -j $1 -N ${3:-2} -t u${3:-2} -An $2 2> /dev/null ||
     2.8 -	hexdump -s $1 -n ${3:-2} -e "\"\" 1/${3:-2} \"%d\"" $2
     2.9 +	od -j $1 -N ${4:-${3:-2}} -t u${3:-2} -An $2 2> /dev/null ||
    2.10 +	hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %d\"" $2
    2.11  }
    2.12  
    2.13  getarg()
    2.14 @@ -48,8 +48,8 @@
    2.15  		--yesno)
    2.16  			while true; do
    2.17  				clear
    2.18 -				echo "$2" | sed 's/\\n/\n/g'
    2.19 -				echo -en "\n  <-  1:${label:-Yes}  2:Cancel\r"
    2.20 +				echo "$2" | sed 's/\\n\\n/\\n/g;s/\\n/\n/g'
    2.21 +				echo -en "  <-  1:${label:-Yes}  2:Cancel\r"
    2.22  				read x
    2.23  				case "$x" in
    2.24  				''|Y*|y*|1) return 0;;
    2.25 @@ -57,15 +57,16 @@
    2.26  				esac
    2.27  			done ;;
    2.28  		--menu|--radiolist)
    2.29 -			label="$2"
    2.30 +			[ "$1" == "--menu" ] && shft=2 || shft=3
    2.31 +			label=""
    2.32 +			[ "$2" ] && label="\n$2" 
    2.33  			shift 5
    2.34 -			echo -e "$title\n$label\n0	Cancel" > /tmp/data
    2.35 +			echo -e "$title$label\n0	Cancel" > /tmp/data
    2.36  			n=1
    2.37  			while [ "$1" ]; do
    2.38  				eval key_$n='$1'
    2.39  				echo "$((n++))	$2"
    2.40 -				case "$3" in on|off) shift;; esac
    2.41 -				shift 2
    2.42 +				shift $shft
    2.43  			done >> /tmp/data
    2.44  			while ! grep -q "^$n	" /tmp/data ; do
    2.45  				clear
    2.46 @@ -454,6 +455,15 @@
    2.47  	rm -f /tmp/data
    2.48  }
    2.49  
    2.50 +gotcdfile()
    2.51 +{
    2.52 +	for i in /media/cdrom/$1 /media/cdrom/*/$1 \
    2.53 +			/media/cdrom/*/isolinux/$1 ; do
    2.54 +		file=$(ls $i 2> /dev/null | sed q)
    2.55 +		[ -s "$file" ] && break
    2.56 +	done
    2.57 +}
    2.58 +
    2.59  sha()
    2.60  {
    2.61  	gotcdfile sha*sum*
    2.62 @@ -549,9 +559,8 @@
    2.63  pxe()
    2.64  {
    2.65  	gotcdfile ?pxe
    2.66 -	pxe=$(ls $file)
    2.67  	$DIALOG --clear \
    2.68 -		--title " Create $(basename $pxe).exe ? " \
    2.69 +		--title " Create $(basename $file).exe ? " \
    2.70  		--yes-label "Install" --yesno \
    2.71  "\nBoot your operating system from the internet and enjoy a full system
    2.72  working entirely in RAM with speed and stability in mind. The Linux Kernel
    2.73 @@ -559,7 +568,7 @@
    2.74  from the Web using PXE and HTTP protocols.\n
    2.75  " 12 70
    2.76  	[ $? -eq 0 ] || return
    2.77 -	cp $pxe /mnt/$(basename $pxe).exe
    2.78 +	cp $file /mnt/$(basename $file).exe
    2.79  }
    2.80  
    2.81  fdpxe()
    2.82 @@ -587,14 +596,6 @@
    2.83  	[ "$(which $1)" ] && echo -en "\"$2\"	\"$3\""
    2.84  }
    2.85  
    2.86 -gotcdfile()
    2.87 -{
    2.88 -	for file in /media/cdrom/$1 /media/cdrom/*/$1 \
    2.89 -		    /media/cdrom/*/isolinux/$1 ; do
    2.90 -		[ -s $file ] && break
    2.91 -	done
    2.92 -}
    2.93 -
    2.94  cdfile()
    2.95  {
    2.96  	gotcdfile "$1" && echo -en "\"$2\"	\"$3\""
    2.97 @@ -605,6 +606,11 @@
    2.98  	[ "$(which kexec)" ] && cdfile "$@"
    2.99  }
   2.100  
   2.101 +cdfilef()
   2.102 +{
   2.103 +	[ -e /sys/block/fd0 ] && cdfile "$@"
   2.104 +}
   2.105 +
   2.106  cdexe()
   2.107  {
   2.108  	gotcdfile "$1" &&
   2.109 @@ -614,10 +620,21 @@
   2.110  
   2.111  fddata()
   2.112  {
   2.113 +	[ -e /sys/block/fd0 ] && 
   2.114  	[ $(get 28 /mnt/$ISO 1 2> /dev/null || echo 0) -ne 0 ] &&
   2.115  	echo -en "\"$1\"	\"$2\""
   2.116  }
   2.117  
   2.118 +ishybrid()
   2.119 +{
   2.120 +	C=$((2048*$(get $(((17*2048) + 71)) /mnt/$ISO 4)))
   2.121 +	[ $(get $C /mnt/$ISO 4) -eq 1 ] || return
   2.122 +	[ $(get $(($C+30)) /mnt/$ISO 4) -eq $((0x88AA55)) ] || return
   2.123 +	C=$((2048*$(get $(($C+40)) /mnt/$ISO 4)))
   2.124 +	[ $(get $(($C+64)) /mnt/$ISO 4) -eq 1886961915 ] &&
   2.125 +	echo -en "\"$1\"	\"$2\""
   2.126 +}
   2.127 +
   2.128  fdbootstrap()
   2.129  {
   2.130  	sz=$((512 * $(echo $(get 28 /mnt/$ISO 1))))
   2.131 @@ -645,21 +662,32 @@
   2.132  	rm -f /tmp/wait
   2.133  	DEV="$(grep -l 1 /sys/block/*/removable | \
   2.134  		sed 's|/sys/block/\(.*\)/removable|\1|')"
   2.135 +	grep -qs 1 /sys/block/$DEV/ro && return
   2.136  	[ "$DEV" ] || return
   2.137 -	exec 3>&1
   2.138 -	device=`$DIALOG  --clear \
   2.139 +	cat > /tmp/dialog <<EOT
   2.140 +$DIALOG  --clear \
   2.141  	--title " Select your USB key " \
   2.142  	--menu "\nPlease select the USB key according to its known size.\n\n" \
   2.143  	14 70 4 \
   2.144  	$(for i in $DEV ; do
   2.145 -		echo "/dev/$i $(( $(cat /sys/block/$i/size) / 1024 ))MB"	 
   2.146 +		echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2> /dev/null)\" "
   2.147  	done) \
   2.148 -	2>&1 1>&3`
   2.149 +
   2.150 +EOT
   2.151 +	exec 3>&1
   2.152 +	device=$(. /tmp/dialog 2>&1 1>&3)
   2.153  	retval=$?
   2.154  	exec 3>&-
   2.155  	[ $retval -eq 0 ]
   2.156  }
   2.157  
   2.158 +tazusbmsg()
   2.159 +{
   2.160 +	[ "$(which tazusb 2> /dev/null)" ] || return
   2.161 +	echo "You should choose 'USB key read/write installation' to be
   2.162 +able to save the package updates or your own configuration and data files.\n\n"
   2.163 +}
   2.164 +
   2.165  usbbootkey()
   2.166  {
   2.167  	$DIALOG --clear \
   2.168 @@ -668,15 +696,13 @@
   2.169  "\nThe USB key will be used like a CD-ROM. You will not be able to write
   2.170  any data on the boot partition.\n\n
   2.171  An extra FAT32 partition will be created with the remaining free space.\n\n
   2.172 -You should choose 'USB key read/write installation' to be
   2.173 -able to save the package updates or your own configuration and data files.\n\n
   2.174 -Please plug your USB stick in now.\n 
   2.175 +$(tazusbmsg)Please plug your USB stick in now.\n 
   2.176  " 16 70
   2.177  	[ $? -eq 0 ] || return
   2.178  	usbdev || return
   2.179  	
   2.180  	# perform dd in progess bar
   2.181 -	max=$(($(stat -c %s /mnt/$ISO)/1024/1024))
   2.182 +	max=$(($(cat /sys/block/loop0/size)/2048))
   2.183  	i=0; ddq if=/mnt/$ISO bs=1024k | ( 
   2.184  	while ddq bs=1024k count=1 ; do 
   2.185  		i=$(($i + 1))
   2.186 @@ -687,7 +713,7 @@
   2.187  	done ) > $device
   2.188  
   2.189  	# partition + fat32 format for the remining space
   2.190 -	od -j 466 -N 12 -t u2 -An $device | { read dx cx ol oh ll lh 
   2.191 +	get 446 $device 2 12 | { read dx cx ol oh ll lh 
   2.192  	if [ $dx -eq $((0x3F17)) ]; then
   2.193  		cx=$(($cx & 0xFF00))
   2.194  		ofs=$(($ll+($lh<<16)))
   2.195 @@ -828,6 +854,7 @@
   2.196  
   2.197  shell()
   2.198  {
   2.199 +	trap text 2 
   2.200  	getty -n -l /bin/ash 38400 tty1 || sh
   2.201  }
   2.202  
   2.203 @@ -847,6 +874,7 @@
   2.204  dmesg > /tmp/dmesg
   2.205  
   2.206  while true; do
   2.207 +	trap shell 2 
   2.208  	keymap="$(cat /etc/keymap.conf 2> /dev/null)"
   2.209  	locale="$(sed '/^LANG=/!d;s/.*=//' /etc/locale.conf 2> /dev/null)"
   2.210  	cat > /tmp/dialog <<EOT
   2.211 @@ -863,15 +891,15 @@
   2.212  $(gotposixovl		"install"	"Hard disk installation (UMSDOS way)") \
   2.213  $(gotposixovl		"installtaz"	"Hard disk installation (TAZUSB way)") \
   2.214  $(xfile tazusb		"usbkey"	"USB key read/write installation") \
   2.215 -$(cdfile boot/bzImage	"usbbootkey"	"USB boot key (read only)") \
   2.216 +$(ishybrid		"usbbootkey"	"USB boot key (read only)") \
   2.217  $(fddata		"fdbootstrap"	"Create a floppy bootstrap") \
   2.218 -$(cdfile boot/bzImage	"tazboot"	"Get tazboot.exe Linux loader") \
   2.219 +			"tazboot"	"Get tazboot.exe Linux loader" \
   2.220  $(cdexe boot/bzImage	"bzimage"	"Get linux DOS/EXE file") \
   2.221  $(cdexe memtest*	"memtest"	"Get Memtest86 DOS/EXE file") \
   2.222 -$(cdfile memtest*	"fdmemtest"	"Create a Memtest86 boot floppy") \
   2.223 +$(cdfilef memtest*	"fdmemtest"	"Create a Memtest86 boot floppy") \
   2.224  $(cdfilex memtest*	"runmemtest"	"Start Memtest86") \
   2.225  $(cdexe ?pxe		"pxe"		"Get SliTaz Web boot DOS/EXE utility") \
   2.226 -$(cdfile ?pxe		"fdpxe"		"Create a SliTaz Web boot floppy") \
   2.227 +$(cdfilef ?pxe		"fdpxe"		"Create a SliTaz Web boot floppy") \
   2.228  $(cdfilex ?pxe		"runpxe"	"Start the SliTaz Web boot utility") \
   2.229  $(xfile reboot		"restart"	"Restart the computer") \
   2.230  $(xfile poweroff	"stop"		"Power off") \
     3.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh	Fri Jan 02 18:34:02 2015 +0000
     3.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh	Fri Jan 02 21:46:16 2015 +0100
     3.3 @@ -235,14 +235,9 @@
     3.4  	add_fdbootstrap $1
     3.5  	printf "%d free bytes in %04X..%04X\n" $(($OFS-$HOLE)) $HOLE $OFS
     3.6  	store 26 ${RANDOM:-0} $1
     3.7 -	i=66
     3.8 -	n=0
     3.9  	echo -n "Adding checksum..."
    3.10 -	while [ $i -lt 32768 ]; do
    3.11 -		n=$(($n + $(get $i $1) ))
    3.12 -		i=$(($i + 2))
    3.13 -	done
    3.14 -	store 64 -$n $1
    3.15 +	store 64 $(od -v -j 66 -N 32702 -t u2 -w2 -An $1 | \
    3.16 +		   awk '{ i+= $0 } END { print -(i % 65536) }') $1
    3.17  	echo " done."
    3.18  }
    3.19