wok-6.x rev 17476

isolinux/iso2exe: fix mkfloppy
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Dec 29 18:24:44 2014 +0100 (2014-12-29)
parents 3cf0f7376fcf
children 872c5b5c0620
files syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/iso2exe.sh
line diff
     1.1 --- a/syslinux/stuff/iso2exe/init	Sat Dec 27 20:44:28 2014 +0100
     1.2 +++ b/syslinux/stuff/iso2exe/init	Mon Dec 29 18:24:44 2014 +0100
     1.3 @@ -82,14 +82,25 @@
     1.4  
     1.5  uncpio()
     1.6  {
     1.7 -	echo "Extracting $(basename $1) ..."
     1.8 +	echo -en "\n Extracting $(basename $1) ..."
     1.9  	case $(get 0 $1) in
    1.10  	*35615)	( zcat || gunzip ) ;;
    1.11 +	*14333) unxz ;;
    1.12  	*\ 93)	unlzma ;;
    1.13  	*)	cat ;;
    1.14  	esac < $1 | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
    1.15  }
    1.16  
    1.17 +dotwait()
    1.18 +{
    1.19 +	echo -n "${1:-Install filesystem}.."
    1.20 +	touch /tmp/wait
    1.21 +	while [ -e /tmp/wait ]; do
    1.22 +		echo -n "." > /dev/tty0
    1.23 +		sleep 1
    1.24 +	done &
    1.25 +}
    1.26 +
    1.27  getuuid()
    1.28  {
    1.29  	dev=$(mount | sed '/ \/mnt /!d;s/ .*//;s|/dev/||;q')
    1.30 @@ -140,12 +151,12 @@
    1.31  
    1.32  mkinitrd()
    1.33  {
    1.34 -	echo "Creating $(basename $1) ..."
    1.35 +	dotwait "Creating $(basename $1) "
    1.36  	for i in bin lib dev proc tmp mnt etc ; do
    1.37  		mkdir -p /tmp/fs/$i
    1.38  	done
    1.39 -	for i in /dev/console /dev/null /dev/tty /dev/tty1 /dev/tty2 /dev/fuse \
    1.40 -		 /dev/hd* /dev/sd* ; do
    1.41 +	for i in /dev/console /dev/null /dev/tty /dev/tty0 /dev/tty1 /dev/tty2 \
    1.42 +		 /dev/fuse /dev/hd* /dev/sd* ; do
    1.43  		cp -a $i /tmp/fs$i
    1.44  	done
    1.45  	for i in /bin/busybox $(which mount.posixovl) $(which blkid); do
    1.46 @@ -189,7 +200,7 @@
    1.47  EOT
    1.48  	chmod +x /tmp/fs/init
    1.49  	( cd /tmp/fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null
    1.50 -	rm -rf /tmp/fs
    1.51 +	rm -rf /tmp/fs /tmp/wait
    1.52  }
    1.53  
    1.54  is_loram()
    1.55 @@ -211,7 +222,7 @@
    1.56  		sleep 5
    1.57  		return 1
    1.58  	fi
    1.59 -	echo "Install root filesystem in /slitaz..."
    1.60 +	dowait "Install root filesystem in /slitaz.."
    1.61  	if [ "$1" ]; then
    1.62  		if [ -d /media/cdrom/fs ]; then
    1.63  			( cd /mnt/slitaz/fs; find | cpio -o -H newc ) | gzip -9
    1.64 @@ -245,7 +256,7 @@
    1.65  		initrd=initrd
    1.66  		extraargs="mount=$(getuuid) subroot=slitaz"
    1.67  	fi
    1.68 -	echo "Install boot files..."
    1.69 +	echo -en "\nInstall boot files..."
    1.70  	for i in /media/cdrom/boot/bzImage /media/cdrom/boot/*pxe* \
    1.71  		/media/cdrom/boot/isolinux/he* /media/cdrom/boot/isolinux/opt* \
    1.72  		/media/cdrom/README /media/cdrom/boot/memtest* ; do
    1.73 @@ -265,9 +276,10 @@
    1.74  		/mnt/slitaz/boot/README
    1.75  	[ -d /mnt/slitaz/usr/sbin -a ! -x /mnt/slitaz/usr/sbin/mount.posixovl ] &&
    1.76  	cp $(which mount.posixovl) /mnt/slitaz/usr/sbin
    1.77 +	rm -f /tmp/wait
    1.78  false &&
    1.79 -	! grep -qs tazboot /mnt/boot.ini && echo "Update boot.ini ..." &&
    1.80 -	unix2dos >> /mnt/boot.ini <<EOT
    1.81 +	[ -s /mnt/boot.ini ] && ! grep -qs tazboot /mnt/boot.ini &&
    1.82 +	echo "Update boot.ini ..." && unix2dos >> /mnt/boot.ini <<EOT
    1.83  C:\\slitaz\\boot\\tazboot.exe="SliTaz"
    1.84  EOT
    1.85  false &&
    1.86 @@ -321,6 +333,7 @@
    1.87  " 19 70
    1.88  	[ $? -eq 0 ] || return
    1.89  	doinstall tazusblike || return
    1.90 +	dotwait 
    1.91  	if [ -d /media/cdrom/fs ]; then
    1.92  		cp -a /media/cdrom/fs/. /
    1.93  	else
    1.94 @@ -330,6 +343,7 @@
    1.95  	fi
    1.96  	cp /tmp/fs/etc/* /etc
    1.97  	echo "/home=$(getuuid)/slitaz" > /cmdline
    1.98 +	rm -f /tmp/wait
    1.99  	[ -x /init1 ] || return
   1.100  	umount -d /media/cdrom
   1.101  	umount /mnt/slitaz
   1.102 @@ -346,7 +360,7 @@
   1.103  		--title " SliTaz bootloader for DOS " \
   1.104  		--yes-label "Install" --yesno \
   1.105  "\nThe file TAZBOOT.EXE will be created in the top directory. It supports
   1.106 -a bzImage linux kernel, multiple initramfs, a kernel command line and
   1.107 +any linux kernel, multiple initramfs, a kernel command line and
   1.108  an ISO image file loopback (retrieves files from an ISO file).\n\n
   1.109  Usage: tazboot.exe [[@commands]|[kernel=<bzimage>] 
   1.110  [initrd=<rootfs>[,<rootfs2>...]] [iso=<isofile>] cmdline args ...]\n\n
   1.111 @@ -365,8 +379,9 @@
   1.112  
   1.113  md5()
   1.114  {
   1.115 -	echo "Checking files..."
   1.116 -	( cd /media/cdrom ; md5sum -c md5sum ) > /tmp/data
   1.117 +	dotwait "Checking files"
   1.118 +	( cd /media/cdrom ; md5sum -c md5sum* ) > /tmp/data
   1.119 +	rm -f /tmp/wait
   1.120  	$DIALOG --clear \
   1.121  		--title " Checked files " \
   1.122  		--textbox /tmp/data 24 78
   1.123 @@ -387,10 +402,23 @@
   1.124  		--textbox /tmp/dmesg 24 78
   1.125  }
   1.126  
   1.127 +bzimage()
   1.128 +{
   1.129 +	$DIALOG --clear \
   1.130 +		--title " Create linux.exe ? " \
   1.131 +		--yes-label "Install" --yesno \
   1.132 +"\nLinux.exe launches the linux kernel under DOS (in real mode only).
   1.133 +The cmdline arguments are supported except initrd=, vga= (you can try 'rdev -v')
   1.134 +and mem= (partially).\n\nExample:\nC:\\> linux.exe root=/dev/hda2 ro panic=60\n
   1.135 +" 12 70
   1.136 +	[ $? -eq 0 ] || return
   1.137 +	cp /media/cdrom/boot/bzImage /mnt/linux.exe
   1.138 +}
   1.139 +
   1.140  memtest()
   1.141  {
   1.142  	$DIALOG --clear \
   1.143 -		--title " Memtest86 " \
   1.144 +		--title " Create memtest.exe ? " \
   1.145  		--yes-label "Install" --yesno \
   1.146  "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
   1.147  computers. BIOS based memory tests are a quick, cursory check and often
   1.148 @@ -402,12 +430,13 @@
   1.149  
   1.150  mkfloppy()
   1.151  {
   1.152 +	dotwait "Create a $(basename $1) boot floppy"
   1.153  	ddq if=$1 of=/dev/fd0
   1.154  	[ $(($(get 0 $1) - 0x5A4D)) -eq 0 ] || return
   1.155  	J=$(($(get 3 $1 1) + 0x02))
   1.156  	R=$((1 + $(get 497 $1 1) + 1 + ($(get 500 $1)-1)/32))
   1.157  	[ $R -lt 2500 ] || return
   1.158 -	[ $((($(get 500 $file)-1) & 31)) -lt 30 ] &&
   1.159 +	[ $((($(get 500 $1)-1) & 31)) -lt 30 ] &&
   1.160  	ddq if=$file bs=32 count=1 seek=$(($R*16 - 1)) of=/dev/fd0
   1.161  	G="18 0 2 0 0 0 0 0"
   1.162  	[ $J -gt 25 ] || G=""
   1.163 @@ -423,6 +452,7 @@
   1.164  		bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0
   1.165  	done
   1.166  	echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0
   1.167 +	rm -f /tmp/wait
   1.168  }
   1.169  
   1.170  fdmemtest()
   1.171 @@ -440,8 +470,9 @@
   1.172  
   1.173  pxe()
   1.174  {
   1.175 +	pxe=$(ls /media/cdrom/boot/?pxe)
   1.176  	$DIALOG --clear \
   1.177 -		--title " SliTaz Web boot " \
   1.178 +		--title " Create $(basename $pxe).exe ? " \
   1.179  		--yes-label "Install" --yesno \
   1.180  "\nBoot your operating system from the internet and enjoy a full system
   1.181  working entirely in RAM with speed and stability in mind. The Linux Kernel
   1.182 @@ -449,7 +480,6 @@
   1.183  from the Web using PXE and HTTP protocols.\n
   1.184  " 12 70
   1.185  	[ $? -eq 0 ] || return
   1.186 -	pxe=$(ls /media/cdrom/boot/?pxe)
   1.187  	cp $pxe /mnt/$(basename $pxe).exe
   1.188  }
   1.189  
   1.190 @@ -480,7 +510,14 @@
   1.191  
   1.192  cdfile()
   1.193  {
   1.194 -	[ -s /media/cdrom/$1 ] && echo -en "\"$2\"	\"$3\""
   1.195 +	for i in ${1//,/ }; do
   1.196 +		[ -s /media/cdrom/$i ] && echo -en "\"$2\"	\"$3\"" && break
   1.197 +	done
   1.198 +}
   1.199 +
   1.200 +cdfilex()
   1.201 +{
   1.202 +	[ "$(which kexec)" ] && cdfile "$@"
   1.203  }
   1.204  
   1.205  cdexe()
   1.206 @@ -517,8 +554,9 @@
   1.207  
   1.208  usbdev()
   1.209  {
   1.210 -	echo "Wait 5 seconds for USB devices..."
   1.211 +	dotwait "Wait 5 seconds for USB devices"
   1.212  	sleep 5
   1.213 +	rm -f /tmp/wait
   1.214  	DEV="$(grep -l 1 /sys/block/*/removable | \
   1.215  		sed 's|/sys/block/\(.*\)/removable|\1|')"
   1.216  	[ "$DEV" ] || return
   1.217 @@ -559,7 +597,7 @@
   1.218  		[ $i -gt $max ] && break
   1.219  		echo $((($i*100)/$max)) | dialog --gauge \
   1.220  			" The ISO image transfer can be long. Please wait..." \
   1.221 -			6 70 0 > /dev/tty 2>&1
   1.222 +			6 70 0 > /dev/tty0 2>&1
   1.223  	done ) > $device
   1.224  
   1.225  	# partition + fat32 format for the remining space
   1.226 @@ -659,26 +697,46 @@
   1.227  live()
   1.228  {
   1.229  	n=0
   1.230 -	for i in $(ls_r /media/cdrom/boot/rootfs* 2> /dev/null); do
   1.231 +	dotwait "Extract filesystem..."
   1.232 +	for i in $(ls_r /media/cdrom/boot/rootfs*); do
   1.233  		[ $((n++)) -eq 0 ] || uncpio $i
   1.234  	done
   1.235 +	rm -f /tmp/wait
   1.236  	text
   1.237  }
   1.238  
   1.239 +dosync()
   1.240 +{
   1.241 +	sync
   1.242 +	[ ! -L /sqfs ] && umount -d /media/cdrom && umount /mnt
   1.243 +}
   1.244 +
   1.245  restart()
   1.246  {
   1.247 -	sync
   1.248 -	[ ! -L /sqfs ] && umount -d /media/cdrom && umount /mnt
   1.249 +	dosync
   1.250  	reboot -f
   1.251  }
   1.252  
   1.253  stop()
   1.254  {
   1.255 -	sync
   1.256 -	[ ! -L /sqfs ] && umount -d /media/cdrom && umount /mnt
   1.257 +	dosync
   1.258  	poweroff -f
   1.259  }
   1.260  
   1.261 +runmemtest()
   1.262 +{
   1.263 +	kexec -l /media/cdrom/boot/memtest
   1.264 +	dosync
   1.265 +	kexec -e
   1.266 +}
   1.267 +
   1.268 +runpxe()
   1.269 +{
   1.270 +	kexec -l /media/cdrom/boot/?pxe
   1.271 +	dosync
   1.272 +	kexec -e
   1.273 +}
   1.274 +
   1.275  shell()
   1.276  {
   1.277  	getty -n -l /bin/ash 38400 tty1 || sh
   1.278 @@ -711,19 +769,22 @@
   1.279  $(cdfile boot/bzImage	"live"		"SliTaz RAM boot") \
   1.280  			"text"		"SliTaz RAM boot (text mode only)" \
   1.281  $(cdfile README		"readme"	"Show the README file") \
   1.282 -$(cdfile md5sum		"md5"		"Check ISO files") \
   1.283 +$(cdfile md5sum*	"md5"		"Check ISO files") \
   1.284  $(gotposixovl		"install"	"Hard disk installation (UMSDOS way)") \
   1.285  $(gotposixovl		"installtaz"	"Hard disk installation (TAZUSB way)") \
   1.286  $(xfile tazusb		"usbkey"	"USB key read/write installation") \
   1.287  $(cdfile boot/bzImage	"usbbootkey"	"USB boot key (read only)") \
   1.288 -$(fddata		"fdbootstrap"	"Floppy bootstrap") \
   1.289 +$(fddata		"fdbootstrap"	"Create a floppy bootstrap") \
   1.290  $(cdfile boot/bzImage	"tazboot"	"Get tazboot.exe Linux loader") \
   1.291 -$(cdexe boot/memtest	"memtest"	"Get Memtest86") \
   1.292 -$(cdfile boot/memtest	"fdmemtest"	"Create a Memtest86 boot floppy") \
   1.293 -$(cdexe boot/gpxe	"pxe"		"Get SliTaz Web boot utility") \
   1.294 -$(cdfile boot/gpxe	"fdpxe"		"Create a SliTaz Web boot floppy") \
   1.295 -$(cdexe boot/ipxe	"pxe"		"Get SliTaz Web boot utility") \
   1.296 -$(cdfile boot/ipxe	"fdpxe"		"Create a SliTaz Web boot floppy") \
   1.297 +$(cdexe boot/bzImage	"bzimage"	"Get linux DOS/EXE file") \
   1.298 +$(cdexe boot/memtest	"memtest"	"Get Memtest86 DOS/EXE file") \
   1.299 +$(cdfile boot/memtest,boot/isolinux/memtest \
   1.300 +			"fdmemtest"	"Create a Memtest86 boot floppy") \
   1.301 +$(cdfilex boot/memtest,boot/isolinux/memtest \
   1.302 +			"runmemtest"	"Start Memtest86") \
   1.303 +$(cdexe boot/?pxe	"pxe"		"Get SliTaz Web boot DOS/EXE utility") \
   1.304 +$(cdfile boot/?pxe	"fdpxe"		"Create a SliTaz Web boot floppy") \
   1.305 +$(cdfilex boot/?pxe	"runpxe"	"Start the SliTaz Web boot utility") \
   1.306  $(xfile reboot		"restart"	"Restart the computer") \
   1.307  $(xfile poweroff	"stop"		"Power off") \
   1.308  			"bootlog"	"Linux boot messages" \
     2.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh	Sat Dec 27 20:44:28 2014 +0100
     2.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh	Mon Dec 29 18:24:44 2014 +0100
     2.3 @@ -18,6 +18,15 @@
     2.4  	echo $(od -j $(($1)) -N ${3:-2} -t u${3:-2} -An $2)
     2.5  }
     2.6  
     2.7 +compress()
     2.8 +{
     2.9 +	if [ "$(which xz 2> /dev/null)" ]; then
    2.10 +		xz -z -e --format=lzma --lzma1=mode=normal --stdout
    2.11 +	else
    2.12 +		lzma e -si -so
    2.13 +	fi 2> /dev/null
    2.14 +}
    2.15 +
    2.16  add_rootfs()
    2.17  {
    2.18  	TMP=/tmp/iso2exe$$
    2.19 @@ -29,8 +38,7 @@
    2.20  		2> /dev/null && echo "Store mount.posixovl ($(wc -c \
    2.21  			< /usr/sbin/mount.posixovl) bytes) ..."
    2.22  	find $TMP -type f -print0 | xargs -0 chmod +x
    2.23 -	( cd $TMP ; find * | cpio -o -H newc ) | \
    2.24 -		lzma e $TMP/rootfs.gz -si 2> /dev/null
    2.25 +	( cd $TMP ; find * | cpio -o -H newc ) | compress > $TMP/rootfs.gz
    2.26  	SIZE=$(wc -c < $TMP/rootfs.gz)
    2.27  	store 24 $SIZE $1
    2.28  	OFS=$(( $OFS - $SIZE ))
    2.29 @@ -98,7 +106,7 @@
    2.30  	shift
    2.31  	ls -l $@
    2.32  	cat >> $0 <<EOM
    2.33 -$(tar cf - $@ | lzma e -si -so | uuencode -m -)
    2.34 +$(tar cf - $@ | compress | uuencode -m -)
    2.35  EOT
    2.36  EOM
    2.37  	sed -i '/^case/,/^esac/d' $0