wok-current rev 23946

syslinux/taziso: add plop support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Sep 20 14:15:26 2020 +0000 (2020-09-20)
parents a17c0b257e47
children 4d52a83c3268
files busybox/stuff/command_not_found syslinux/stuff/iso2exe/taziso
line diff
     1.1 --- a/busybox/stuff/command_not_found	Fri Sep 18 18:47:32 2020 +0000
     1.2 +++ b/busybox/stuff/command_not_found	Sun Sep 20 14:15:26 2020 +0000
     1.3 @@ -6,7 +6,7 @@
     1.4  grep -E "(: ${PATH//:/|: })" | gzip -9 >$LIST && chmod 666 $LIST
     1.5  
     1.6  lookup() {
     1.7 -	zcat $LIST | grep "/$2$1$" | if read pkg file; then
     1.8 +	zcat $LIST 2> /dev/null | grep "/$2$1$" | if read pkg file; then
     1.9  		cat <<EOT
    1.10  Command '$1' not found, but can be installed as root with:
    1.11  
     2.1 --- a/syslinux/stuff/iso2exe/taziso	Fri Sep 18 18:47:32 2020 +0000
     2.2 +++ b/syslinux/stuff/iso2exe/taziso	Sun Sep 20 14:15:26 2020 +0000
     2.3 @@ -9,6 +9,11 @@
     2.4  	dd $@ 2> /dev/null
     2.5  }
     2.6  
     2.7 +ddn()
     2.8 +{
     2.9 +	ddq conv=notrunc $@
    2.10 +}
    2.11 +
    2.12  get()
    2.13  {
    2.14  	hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %u\n\"" "$2"
    2.15 @@ -43,10 +48,16 @@
    2.16  	ddq if=$file >> $1
    2.17  }
    2.18  
    2.19 +maybe64()
    2.20 +{
    2.21 +	echo -n $1
    2.22 +	grep -q ' lm ' /proc/cpuinfo && [ -s ${1}64 ] && echo 64
    2.23 +}
    2.24 +
    2.25  uncpio()
    2.26  {
    2.27  	i=$1                                                    
    2.28 -	[ $0 = /init.exe ] && sed 's|$| |' /proc/cpuinfo | grep ' lm ' && [ -s ${i}64 ] && i=${i}64
    2.29 +	[ $0 = /init.exe ] && i=$(maybe64 $i)
    2.30  	[ -s "$i" ] || return
    2.31  	echo -en "\n Extracting $(basename $i) ..."
    2.32  	case $(get 0 $i) in
    2.33 @@ -261,6 +272,7 @@
    2.34  	fi
    2.35  	echo -en "\nInstall boot files..."
    2.36  	for i in $media/boot/bzImage* $media/boot/*pxe* \
    2.37 +		$media/boot/plop.exe \
    2.38  		$media/boot/isolinux/he* $media/boot/isolinux/opt* \
    2.39  		$media/README $media/boot/memtest* ; do
    2.40  		[ -s $i ] && cp $i $mnt/slitaz/boot
    2.41 @@ -479,6 +491,7 @@
    2.42  EOT
    2.43  	done <<EOT
    2.44  memtest	MemTest
    2.45 +plop	USB boot
    2.46  pxe	Web boot
    2.47  EOT
    2.48  	unix2dos $mnt/slitaz/boot/menu.lst
    2.49 @@ -608,7 +621,7 @@
    2.50  {
    2.51  	cd /tmp
    2.52  	for i in $(ls_r $media/boot/rootfs*gz); do
    2.53 -		grep -q ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64
    2.54 +		i=$(maybe64 $i)
    2.55  		cat $i
    2.56  		n=$((4 - ($(stat -c %s $i) % 4)))
    2.57  		[ $n -eq 4 ] || dd if=/dev/zero bs=1 count=$n
    2.58 @@ -620,8 +633,7 @@
    2.59  	getcustomconf kexec >/dev/null
    2.60  	[ -s cmdline ] && cmdline="$cmdline $(cat cmdline)" && rm cmdline
    2.61  	[ -s initrd ] && cat initrd >> initrd$$ && rm initrd
    2.62 -	kernel=$media/boot/bzImage
    2.63 -	grep -q ' lm ' /proc/cpuinfo && [ -s ${kernel}64 ] && kernel=${kernel}64
    2.64 +	kernel=$(maybe64 $media/boot/bzImage)
    2.65  	. /etc/locale.conf
    2.66  	kexec -l $kernel --initrd initrd$$ --command-line "$cmdline" &&
    2.67  	rm -f initrd$$
    2.68 @@ -701,7 +713,7 @@
    2.69  \nExample:\nC:\\> linux.exe root=/dev/hda2 ro panic=60\n" 12 70
    2.70  		[ $? -eq 0 ] || return
    2.71  	fi
    2.72 -	cp $media/boot/bzImage linux.exe
    2.73 +	cp $(maybe64 $media/boot/bzImage) linux.exe
    2.74  	du -h $PWD/linux.exe
    2.75  }
    2.76  
    2.77 @@ -796,6 +808,31 @@
    2.78  	gotcdfile '?pxe*' && mkfloppy $file
    2.79  }
    2.80  
    2.81 +plop()
    2.82 +{
    2.83 +	gotcdfile 'plop.exe'
    2.84 +	if [ -z "$1" ]; then
    2.85 +		$DIALOG --clear --title " Create $(basename $file .exe).exe ? " \
    2.86 +			--yes-label "Install" --yesno \
    2.87 +"\nBoot your operating system from a USB disk without BIOS support.\n" 0 0
    2.88 +		[ $? -eq 0 ] || return
    2.89 +	fi
    2.90 +	cp $file $(basename $file .exe).exe
    2.91 +	du -h $PWD/$(basename $file .exe).exe
    2.92 +}
    2.93 +
    2.94 +fdplop()
    2.95 +{
    2.96 +	if [ -z "$1" ]; then
    2.97 +		$DIALOG --clear --title " Create a Plop boot floppy " \
    2.98 +			--yes-label "Create floppy" --yesno \
    2.99 +"\nBoot your operating system from a USB disk without BIOS support.\n\n
   2.100 +Please insert a blank disk in floppy drive.\n" 0 0
   2.101 +		[ $? -eq 0 ] || return
   2.102 +	fi
   2.103 +	gotcdfile 'plop.exe' && mkfloppy $file
   2.104 +}
   2.105 +
   2.106  menuitem()
   2.107  {
   2.108  	[ "$3" ] && shift
   2.109 @@ -943,7 +980,7 @@
   2.110  
   2.111  hasflavor()
   2.112  {
   2.113 -	[ -x /usr/bin/tazlito ] && [ -s $media/boot/bzImage ] && menuitem "$@"
   2.114 +	[ -x /usr/bin/tazlito ] && [ -s $(maybe64 $media/boot/bzImage) ] && menuitem "$@"
   2.115  }
   2.116  
   2.117  gotisomd5()
   2.118 @@ -1017,13 +1054,13 @@
   2.119  	rm -f /tmp/wait
   2.120  	DEV="$(grep -l 1 /sys/block/*/removable | \
   2.121  		sed 's|/sys/block/\(.*\)/removable|\1|')"
   2.122 -	grep -qs 1 /sys/block/$DEV/ro && return
   2.123  	[ "$DEV" ] || return
   2.124  	cat > /tmp/dialog$$ <<EOT
   2.125  $DIALOG  --clear --title " Select your USB key " \
   2.126  	--menu "\nPlease select the USB key according to its known size.\n\n" \
   2.127  	0 0 0 \
   2.128  	$(for i in $DEV ; do
   2.129 +		grep -qs 1 /sys/block/$i/ro ||
   2.130  		echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2> /dev/null)\" "
   2.131  	done) \
   2.132  
   2.133 @@ -1060,18 +1097,16 @@
   2.134  $(tazusbmsg)Please plug your USB stick in now.\n" 16 70
   2.135  		[ $? -eq 0 ] || return
   2.136  		usbdev || return
   2.137 +	fi
   2.138  	
   2.139 -		# perform dd in progress bar
   2.140 -		max=$(($(stat -c %s "$ISO")/2048))
   2.141 -		i=0; ddq if="$ISO" bs=1024k | (
   2.142 -		while ddq bs=1024k count=1 ; do
   2.143 -			i=$(($i + 1))
   2.144 -			[ $i -gt $max ] && break
   2.145 -			echo $((($i*100)/$max)) | dialog --gauge \
   2.146 -				" The ISO image transfer can be long. Please wait..." \
   2.147 -				6 70 0 > /dev/tty 2>&1
   2.148 -		done ) > $device
   2.149 -	fi
   2.150 +	# perform dd in progress bar
   2.151 +	max=$(($(stat -c %s "$ISO")/1024/1024))
   2.152 +	i=0; while [ $i -le $max ]; do
   2.153 +		ddq if="$ISO" bs=1024k count=1 skip=$i seek=$i of=$device
   2.154 +		echo $((($i*100)/$max))
   2.155 +		i=$(($i+1))
   2.156 +	done | dialog --gauge " The ISO image transfer can be long. Please wait..." \
   2.157 +			6 70 0 > /dev/tty 2>&1
   2.158  
   2.159  	# partition + fat32 format for the remaining space
   2.160  	for p in 0 16; do
   2.161 @@ -1097,6 +1132,13 @@
   2.162  		fi
   2.163   		}
   2.164   	done
   2.165 +
   2.166 +	# update boot/exe crc16
   2.167 +	i=$(($(get 2 $1) - 1 + ($(get 4 $1) - 1)*512))
   2.168 +	i=$(($(od -v -N $i -t u2 -w2 -An $device | \
   2.169 +		awk '{ i+= $0 } END { print (i % 65536) }') \
   2.170 +		+ $(get $(($i+1)) $device 1)))
   2.171 +	words2bin $(( (-$i -1) % 65536 )) | ddq bs=1 seek=18 of=$device
   2.172  }
   2.173  
   2.174  usbkey()
   2.175 @@ -1133,22 +1175,6 @@
   2.176  	tazusb gen-iso2usb "$ISO" $device
   2.177  }
   2.178  
   2.179 -dokexec()
   2.180 -{
   2.181 -	kexec -l $file || return
   2.182 -	quit "kexec -e"
   2.183 -}
   2.184 -
   2.185 -runmemtest()
   2.186 -{
   2.187 -	gotcdfile 'memtest*' && dokexec
   2.188 -}
   2.189 -
   2.190 -runpxe()
   2.191 -{
   2.192 -	gotcdfile '?pxe*' && dokexec
   2.193 -}
   2.194 -
   2.195  flavdata()
   2.196  {
   2.197  	[ $(get 1024 "$ISO") -eq 35615 ] && n=2 || n=$((1+$(get 417 "$ISO" 1)))
   2.198 @@ -1159,8 +1185,7 @@
   2.199  
   2.200  hasflavinfo()
   2.201  {
   2.202 -	[ "$(flavdata | ddq bs=1 count=7)" = \
   2.203 -	  "0707010" ] && menuitem "$@"
   2.204 +	[ "$(flavdata | ddq bs=1 count=7)" = "0707010" ] && menuitem "$@"
   2.205  }
   2.206  
   2.207  showfavinfo()
   2.208 @@ -1278,19 +1303,16 @@
   2.209  	[ $(get 514 $KERNEL 4) -eq 1400005704 ] || return
   2.210  	n=$(($(get 497 $KERNEL 1)+1))
   2.211  	ddq bs=512 count=$n if=$KERNEL of=/tmp/fd$$
   2.212 -	uudecode <<EOT | ddq of=/tmp/fd$$ conv=notrunc
   2.213 +	uudecode <<EOT | ddn of=/tmp/fd$$
   2.214  bootloader
   2.215  EOT
   2.216  	pos=$(($n*512))
   2.217  	if [ -n "$CMDLINE" ]; then
   2.218  		echo -n "$CMDLINE" | ddq bs=512 count=1 conv=sync >> /tmp/fd$$
   2.219 -		bytes2bin $n | ddq conv=notrunc \
   2.220 -			bs=1 seek=497 count=1 of=/tmp/fd$$
   2.221 -		words2bin $pos | ddq conv=notrunc \
   2.222 -			bs=1 seek=34 count=2 of=/tmp/fd$$
   2.223 +		bytes2bin $n | ddn bs=1 seek=497 of=/tmp/fd$$
   2.224 +		words2bin $pos | ddn bs=1 seek=34 of=/tmp/fd$$
   2.225  		[ $(get 518 $KERNEL 4) -ge 514 ] &&
   2.226 -		words2bin 32768 9 | ddq conv=notrunc \
   2.227 -			bs=1 seek=552 count=4 of=/tmp/fd$$
   2.228 +		words2bin 32768 9 | ddn bs=1 seek=552 of=/tmp/fd$$
   2.229  	fi
   2.230  	syssize=$(echo $(get 500 /tmp/fd$$ 4))
   2.231  	ddq bs=512 skip=$n if=$KERNEL | cat - /dev/zero | \
   2.232 @@ -1318,28 +1340,28 @@
   2.233  			len="$len $l"; l=0
   2.234  		done
   2.235  		rdadrs=${RDADRS:-$(((($syssize*16)+0x1F0000) & -4096))}
   2.236 -		words2bin $(($rdadrs & 0xFFFF)) $(($rdadrs >> 16)) | ddq \
   2.237 -			conv=notrunc bs=1 seek=536 count=4 of=/tmp/fd$$
   2.238 +		words2bin $(($rdadrs & 0xFFFF)) $(($rdadrs >> 16)) | ddn \
   2.239 +			bs=1 seek=536 of=/tmp/fd$$
   2.240  	fi
   2.241  	n=$(echo $len | wc -w)
   2.242  	if [ $((494 - $(get 494 /tmp/fd$$))) -ge $(($n * 4)) ]; then
   2.243  		i=$(($(get 494 /tmp/fd$$)))
   2.244 -		bytes2bin $(($i + ($n*4) - 256)) | ddq bs=1 conv=notrunc \
   2.245 -			seek=496 count=1 of=/tmp/fd$$
   2.246 +		bytes2bin $(($i + ($n*4) - 256)) | ddn bs=1 \
   2.247 +			seek=496 of=/tmp/fd$$
   2.248  	else
   2.249  		i=$(($pos + 0x1FC - ($n*4)))
   2.250 -		bytes2bin $(($i % 256)) $((i / 256)) 252 | ddq bs=1 \
   2.251 -			conv=notrunc seek=494 count=3 of=/tmp/fd$$
   2.252 +		bytes2bin $(($i % 256)) $((i / 256)) 252 | ddn bs=1 \
   2.253 +			seek=494 of=/tmp/fd$$
   2.254  		s=$(($i - 2*$(echo "$SIZES" | wc -w)))
   2.255  		p=$(($s - $(ifmemcode | wc -c)))
   2.256 -		ifmemcode | ddq bs=1 conv=notrunc seek=$p of=/tmp/fd$$
   2.257 -		words2bin $SIZES | ddq bs=1 conv=notrunc seek=$s of=/tmp/fd$$
   2.258 +		ifmemcode | ddn bs=1 seek=$p of=/tmp/fd$$
   2.259 +		words2bin $SIZES | ddn bs=1 seek=$s of=/tmp/fd$$
   2.260  		bytes2bin 154 $(($p%256)) $(($p/256)) 0 144 | \
   2.261 -		ddq bs=1 conv=notrunc seek=60 of=/tmp/fd$$
   2.262 +		ddn bs=1 seek=60 of=/tmp/fd$$
   2.263  	fi
   2.264  	for r in $len ; do
   2.265 -		words2bin $(($r & 0xFFFF)) $(($r >> 16)) | ddq conv=notrunc \
   2.266 -			bs=1 seek=$i count=4 of=/tmp/fd$$
   2.267 +		words2bin $(($r & 0xFFFF)) $(($r >> 16)) | ddn \
   2.268 +			bs=1 seek=$i of=/tmp/fd$$
   2.269  		i=$(($i + 4))
   2.270  	done
   2.271  	split -b 1440k /tmp/fd$$ fd$$
   2.272 @@ -1461,7 +1483,7 @@
   2.273  $(cdfile 'md5sum*'	"md5"		"Check the ISO files") \
   2.274  $(cdfile 'sha*sum*'	"sha"		"Check the ISO files") \
   2.275  $(xfile isoinfo		"infoiso"	"ISO image info") \
   2.276 -$(cdfilex boot/bzImage	"bootiso"	"Boot the ISO image") \
   2.277 +$(cdfilex 'bzImage*'	"bootiso"	"Boot the ISO image") \
   2.278  $(burnable		"burniso"	"Burn the ISO image") \
   2.279  $(blankable		"blankcd"	"Blank the CD/DVD") \
   2.280  $(gotposixovl		"install"	"Hard disk installation (UMSDOS way)") \
   2.281 @@ -1474,13 +1496,13 @@
   2.282  $(hasflavor		"flavor"	"Get flavor file") \
   2.283  $(cdfile isolinux.cfg	"floppyset"	"Boot floppy set") \
   2.284  $(cdfile linld.com	"tazboot"	"Get tazboot.exe Linux loader") \
   2.285 -$(cdexe boot/bzImage	"bzimage"	"Get linux DOS/EXE file") \
   2.286 +$(cdexe 'bzImage*'	"bzimage"	"Get linux DOS/EXE file") \
   2.287  $(cdexe 'memtest*'	"memtest"	"Get Memtest86 DOS/EXE file") \
   2.288  $(cdfilef 'memtest*'	"fdmemtest"	"Create a Memtest86 boot floppy") \
   2.289 -$(cdfilex 'memtest*'	"runmemtest"	"Start Memtest86") \
   2.290  $(cdexe '?pxe*'		"pxe"		"Get SliTaz Web boot DOS/EXE utility") \
   2.291  $(cdfilef '?pxe*'	"fdpxe"		"Create a SliTaz Web boot floppy") \
   2.292 -$(cdfilex '?pxe*'	"runpxe"	"Start the SliTaz Web boot utility") \
   2.293 +$(cdexe 'plop.exe'	"plop"		"Get USB boot DOS/EXE utility") \
   2.294 +$(cdfilef 'plop.exe'	"fdplop"	"Create a USB boot floppy") \
   2.295  $(initxfile reboot	"restart"	"Restart the computer") \
   2.296  $(initxfile poweroff	"stop"		"Power off") \
   2.297  $(initx			"bootlog"       "Linux boot messages") \