wok diff syslinux/stuff/iso2exe/init @ 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 054f70cb9bec
children aa46cf9cc35a
line diff
     1.1 --- a/syslinux/stuff/iso2exe/init	Thu Jan 01 22:09:19 2015 +0100
     1.2 +++ b/syslinux/stuff/iso2exe/init	Fri Jan 02 21:46:16 2015 +0100
     1.3 @@ -9,8 +9,8 @@
     1.4  
     1.5  get()
     1.6  {
     1.7 -	od -j $1 -N ${3:-2} -t u${3:-2} -An $2 2> /dev/null ||
     1.8 -	hexdump -s $1 -n ${3:-2} -e "\"\" 1/${3:-2} \"%d\"" $2
     1.9 +	od -j $1 -N ${4:-${3:-2}} -t u${3:-2} -An $2 2> /dev/null ||
    1.10 +	hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %d\"" $2
    1.11  }
    1.12  
    1.13  getarg()
    1.14 @@ -48,8 +48,8 @@
    1.15  		--yesno)
    1.16  			while true; do
    1.17  				clear
    1.18 -				echo "$2" | sed 's/\\n/\n/g'
    1.19 -				echo -en "\n  <-  1:${label:-Yes}  2:Cancel\r"
    1.20 +				echo "$2" | sed 's/\\n\\n/\\n/g;s/\\n/\n/g'
    1.21 +				echo -en "  <-  1:${label:-Yes}  2:Cancel\r"
    1.22  				read x
    1.23  				case "$x" in
    1.24  				''|Y*|y*|1) return 0;;
    1.25 @@ -57,15 +57,16 @@
    1.26  				esac
    1.27  			done ;;
    1.28  		--menu|--radiolist)
    1.29 -			label="$2"
    1.30 +			[ "$1" == "--menu" ] && shft=2 || shft=3
    1.31 +			label=""
    1.32 +			[ "$2" ] && label="\n$2" 
    1.33  			shift 5
    1.34 -			echo -e "$title\n$label\n0	Cancel" > /tmp/data
    1.35 +			echo -e "$title$label\n0	Cancel" > /tmp/data
    1.36  			n=1
    1.37  			while [ "$1" ]; do
    1.38  				eval key_$n='$1'
    1.39  				echo "$((n++))	$2"
    1.40 -				case "$3" in on|off) shift;; esac
    1.41 -				shift 2
    1.42 +				shift $shft
    1.43  			done >> /tmp/data
    1.44  			while ! grep -q "^$n	" /tmp/data ; do
    1.45  				clear
    1.46 @@ -454,6 +455,15 @@
    1.47  	rm -f /tmp/data
    1.48  }
    1.49  
    1.50 +gotcdfile()
    1.51 +{
    1.52 +	for i in /media/cdrom/$1 /media/cdrom/*/$1 \
    1.53 +			/media/cdrom/*/isolinux/$1 ; do
    1.54 +		file=$(ls $i 2> /dev/null | sed q)
    1.55 +		[ -s "$file" ] && break
    1.56 +	done
    1.57 +}
    1.58 +
    1.59  sha()
    1.60  {
    1.61  	gotcdfile sha*sum*
    1.62 @@ -549,9 +559,8 @@
    1.63  pxe()
    1.64  {
    1.65  	gotcdfile ?pxe
    1.66 -	pxe=$(ls $file)
    1.67  	$DIALOG --clear \
    1.68 -		--title " Create $(basename $pxe).exe ? " \
    1.69 +		--title " Create $(basename $file).exe ? " \
    1.70  		--yes-label "Install" --yesno \
    1.71  "\nBoot your operating system from the internet and enjoy a full system
    1.72  working entirely in RAM with speed and stability in mind. The Linux Kernel
    1.73 @@ -559,7 +568,7 @@
    1.74  from the Web using PXE and HTTP protocols.\n
    1.75  " 12 70
    1.76  	[ $? -eq 0 ] || return
    1.77 -	cp $pxe /mnt/$(basename $pxe).exe
    1.78 +	cp $file /mnt/$(basename $file).exe
    1.79  }
    1.80  
    1.81  fdpxe()
    1.82 @@ -587,14 +596,6 @@
    1.83  	[ "$(which $1)" ] && echo -en "\"$2\"	\"$3\""
    1.84  }
    1.85  
    1.86 -gotcdfile()
    1.87 -{
    1.88 -	for file in /media/cdrom/$1 /media/cdrom/*/$1 \
    1.89 -		    /media/cdrom/*/isolinux/$1 ; do
    1.90 -		[ -s $file ] && break
    1.91 -	done
    1.92 -}
    1.93 -
    1.94  cdfile()
    1.95  {
    1.96  	gotcdfile "$1" && echo -en "\"$2\"	\"$3\""
    1.97 @@ -605,6 +606,11 @@
    1.98  	[ "$(which kexec)" ] && cdfile "$@"
    1.99  }
   1.100  
   1.101 +cdfilef()
   1.102 +{
   1.103 +	[ -e /sys/block/fd0 ] && cdfile "$@"
   1.104 +}
   1.105 +
   1.106  cdexe()
   1.107  {
   1.108  	gotcdfile "$1" &&
   1.109 @@ -614,10 +620,21 @@
   1.110  
   1.111  fddata()
   1.112  {
   1.113 +	[ -e /sys/block/fd0 ] && 
   1.114  	[ $(get 28 /mnt/$ISO 1 2> /dev/null || echo 0) -ne 0 ] &&
   1.115  	echo -en "\"$1\"	\"$2\""
   1.116  }
   1.117  
   1.118 +ishybrid()
   1.119 +{
   1.120 +	C=$((2048*$(get $(((17*2048) + 71)) /mnt/$ISO 4)))
   1.121 +	[ $(get $C /mnt/$ISO 4) -eq 1 ] || return
   1.122 +	[ $(get $(($C+30)) /mnt/$ISO 4) -eq $((0x88AA55)) ] || return
   1.123 +	C=$((2048*$(get $(($C+40)) /mnt/$ISO 4)))
   1.124 +	[ $(get $(($C+64)) /mnt/$ISO 4) -eq 1886961915 ] &&
   1.125 +	echo -en "\"$1\"	\"$2\""
   1.126 +}
   1.127 +
   1.128  fdbootstrap()
   1.129  {
   1.130  	sz=$((512 * $(echo $(get 28 /mnt/$ISO 1))))
   1.131 @@ -645,21 +662,32 @@
   1.132  	rm -f /tmp/wait
   1.133  	DEV="$(grep -l 1 /sys/block/*/removable | \
   1.134  		sed 's|/sys/block/\(.*\)/removable|\1|')"
   1.135 +	grep -qs 1 /sys/block/$DEV/ro && return
   1.136  	[ "$DEV" ] || return
   1.137 -	exec 3>&1
   1.138 -	device=`$DIALOG  --clear \
   1.139 +	cat > /tmp/dialog <<EOT
   1.140 +$DIALOG  --clear \
   1.141  	--title " Select your USB key " \
   1.142  	--menu "\nPlease select the USB key according to its known size.\n\n" \
   1.143  	14 70 4 \
   1.144  	$(for i in $DEV ; do
   1.145 -		echo "/dev/$i $(( $(cat /sys/block/$i/size) / 1024 ))MB"	 
   1.146 +		echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2> /dev/null)\" "
   1.147  	done) \
   1.148 -	2>&1 1>&3`
   1.149 +
   1.150 +EOT
   1.151 +	exec 3>&1
   1.152 +	device=$(. /tmp/dialog 2>&1 1>&3)
   1.153  	retval=$?
   1.154  	exec 3>&-
   1.155  	[ $retval -eq 0 ]
   1.156  }
   1.157  
   1.158 +tazusbmsg()
   1.159 +{
   1.160 +	[ "$(which tazusb 2> /dev/null)" ] || return
   1.161 +	echo "You should choose 'USB key read/write installation' to be
   1.162 +able to save the package updates or your own configuration and data files.\n\n"
   1.163 +}
   1.164 +
   1.165  usbbootkey()
   1.166  {
   1.167  	$DIALOG --clear \
   1.168 @@ -668,15 +696,13 @@
   1.169  "\nThe USB key will be used like a CD-ROM. You will not be able to write
   1.170  any data on the boot partition.\n\n
   1.171  An extra FAT32 partition will be created with the remaining free space.\n\n
   1.172 -You should choose 'USB key read/write installation' to be
   1.173 -able to save the package updates or your own configuration and data files.\n\n
   1.174 -Please plug your USB stick in now.\n 
   1.175 +$(tazusbmsg)Please plug your USB stick in now.\n 
   1.176  " 16 70
   1.177  	[ $? -eq 0 ] || return
   1.178  	usbdev || return
   1.179  	
   1.180  	# perform dd in progess bar
   1.181 -	max=$(($(stat -c %s /mnt/$ISO)/1024/1024))
   1.182 +	max=$(($(cat /sys/block/loop0/size)/2048))
   1.183  	i=0; ddq if=/mnt/$ISO bs=1024k | ( 
   1.184  	while ddq bs=1024k count=1 ; do 
   1.185  		i=$(($i + 1))
   1.186 @@ -687,7 +713,7 @@
   1.187  	done ) > $device
   1.188  
   1.189  	# partition + fat32 format for the remining space
   1.190 -	od -j 466 -N 12 -t u2 -An $device | { read dx cx ol oh ll lh 
   1.191 +	get 446 $device 2 12 | { read dx cx ol oh ll lh 
   1.192  	if [ $dx -eq $((0x3F17)) ]; then
   1.193  		cx=$(($cx & 0xFF00))
   1.194  		ofs=$(($ll+($lh<<16)))
   1.195 @@ -828,6 +854,7 @@
   1.196  
   1.197  shell()
   1.198  {
   1.199 +	trap text 2 
   1.200  	getty -n -l /bin/ash 38400 tty1 || sh
   1.201  }
   1.202  
   1.203 @@ -847,6 +874,7 @@
   1.204  dmesg > /tmp/dmesg
   1.205  
   1.206  while true; do
   1.207 +	trap shell 2 
   1.208  	keymap="$(cat /etc/keymap.conf 2> /dev/null)"
   1.209  	locale="$(sed '/^LANG=/!d;s/.*=//' /etc/locale.conf 2> /dev/null)"
   1.210  	cat > /tmp/dialog <<EOT
   1.211 @@ -863,15 +891,15 @@
   1.212  $(gotposixovl		"install"	"Hard disk installation (UMSDOS way)") \
   1.213  $(gotposixovl		"installtaz"	"Hard disk installation (TAZUSB way)") \
   1.214  $(xfile tazusb		"usbkey"	"USB key read/write installation") \
   1.215 -$(cdfile boot/bzImage	"usbbootkey"	"USB boot key (read only)") \
   1.216 +$(ishybrid		"usbbootkey"	"USB boot key (read only)") \
   1.217  $(fddata		"fdbootstrap"	"Create a floppy bootstrap") \
   1.218 -$(cdfile boot/bzImage	"tazboot"	"Get tazboot.exe Linux loader") \
   1.219 +			"tazboot"	"Get tazboot.exe Linux loader" \
   1.220  $(cdexe boot/bzImage	"bzimage"	"Get linux DOS/EXE file") \
   1.221  $(cdexe memtest*	"memtest"	"Get Memtest86 DOS/EXE file") \
   1.222 -$(cdfile memtest*	"fdmemtest"	"Create a Memtest86 boot floppy") \
   1.223 +$(cdfilef memtest*	"fdmemtest"	"Create a Memtest86 boot floppy") \
   1.224  $(cdfilex memtest*	"runmemtest"	"Start Memtest86") \
   1.225  $(cdexe ?pxe		"pxe"		"Get SliTaz Web boot DOS/EXE utility") \
   1.226 -$(cdfile ?pxe		"fdpxe"		"Create a SliTaz Web boot floppy") \
   1.227 +$(cdfilef ?pxe		"fdpxe"		"Create a SliTaz Web boot floppy") \
   1.228  $(cdfilex ?pxe		"runpxe"	"Start the SliTaz Web boot utility") \
   1.229  $(xfile reboot		"restart"	"Restart the computer") \
   1.230  $(xfile poweroff	"stop"		"Power off") \