wok-next rev 14271

syslinux/iso2exe: refresh init
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Apr 05 13:11:51 2013 +0200 (2013-04-05)
parents a4a3cb53e474
children d1c6014647e3 ae812b1f9914
files syslinux/stuff/iso2exe/init
line diff
     1.1 --- a/syslinux/stuff/iso2exe/init	Fri Apr 05 00:25:09 2013 +0000
     1.2 +++ b/syslinux/stuff/iso2exe/init	Fri Apr 05 13:11:51 2013 +0200
     1.3 @@ -16,8 +16,8 @@
     1.4  gettazboot()
     1.5  {
     1.6  	echo "Creating $(basename $1) ..."
     1.7 -	O=$(($(get 66 /mnt/$ISO) - 0xE0))
     1.8 -	L=$((0x8000 - $(get 24 /mnt/$ISO) - $O))
     1.9 +	O=$(($(get 66 /mnt/$ISO) - 0xC0))
    1.10 +	L=$((0x7EE0 - $(get 24 /mnt/$ISO) - $O))
    1.11  	S=$((32+$L))
    1.12  	P=$((($S+511)/512))
    1.13  	E=$((4096-(32*$P)))
    1.14 @@ -81,7 +81,7 @@
    1.15  	done
    1.16  	cp -a /lib/ld-* /tmp/fs/lib
    1.17  	for i in $(busybox | sed '/Current/,$!d'); do
    1.18 -		ln -s busybox /tmp/fs/bin/${i%,}
    1.19 +		[ -e /tmp/fs/bin/${i%,} ] || ln -s busybox /tmp/fs/bin/${i%,}
    1.20  	done
    1.21  	ln -s /proc/mounts /tmp/fs/etc/mtab
    1.22  	cat > /tmp/fs/init <<EOT
    1.23 @@ -117,42 +117,55 @@
    1.24  
    1.25  doinstall()
    1.26  {
    1.27 -	mkdir /mnt/slitaz
    1.28 +	mkdir -p /mnt/slitaz/boot /mnt/slitaz/mnt/dos
    1.29  	mount.posixovl -F /mnt/slitaz || return
    1.30 -	mkdir -p /mnt/slitaz/boot /mnt/slitaz/mnt/dos
    1.31 -	if [ -d /media/cdrom/fs ]; then
    1.32 -		cp -a /media/cdrom/fs/. /mnt/slitaz
    1.33 -	elif is_loram ; then
    1.34 -		for i in /media/cdrom/boot/rootfs?.* ; do
    1.35 -			[ -s $(basename $i) ] && continue
    1.36 -			cpio -i $i
    1.37 -		done
    1.38 -		for i in $(ls -r /media/cdrom/boot/rootfs*); do
    1.39 -			mount -o loop,ro $i /sqfs/mnt
    1.40 -			cp -a /sqfs/mnt/. /mnt/slitaz
    1.41 -			umount -d /sqfs/mnt
    1.42 -		done
    1.43 +	echo "Install root filesystem..."
    1.44 +	if [ -n "$1" ]; then
    1.45 +		if [ -d /media/cdrom/fs ]; then
    1.46 +			( cd /mnt/slitaz/fs; find | cpio -o -H newc ) | gzip -9
    1.47 +		else
    1.48 +			ls -r /media/cdrom/boot/rootfs* | xargs cat
    1.49 +		fi > /mnt/slitaz/boot/rootfs.gz
    1.50 +		mkdir /mnt/slitaz/home
    1.51 +		initrd=rootfs.gz
    1.52 +		extraargs="/home=$(getuuid)/slitaz/home" # FIXME /dos
    1.53  	else
    1.54 -		for i in $(ls -r /media/cdrom/boot/rootfs*); do
    1.55 -			uncpio $i /mnt/slitaz
    1.56 -		done
    1.57 +		if [ -d /media/cdrom/fs ]; then
    1.58 +			cp -a /media/cdrom/fs/. /mnt/slitaz
    1.59 +		elif is_loram ; then
    1.60 +			for i in /media/cdrom/boot/rootfs?.* ; do
    1.61 +				[ -s $(basename $i) ] && continue
    1.62 +				cpio -i $i
    1.63 +			done
    1.64 +			for i in $(ls -r /media/cdrom/boot/rootfs*); do
    1.65 +				mount -o loop,ro $i /sqfs/mnt
    1.66 +				cp -a /sqfs/mnt/. /mnt/slitaz
    1.67 +				umount -d /sqfs/mnt
    1.68 +			done
    1.69 +		else
    1.70 +			for i in $(ls -r /media/cdrom/boot/rootfs*); do
    1.71 +				uncpio $i /mnt/slitaz
    1.72 +			done
    1.73 +		fi
    1.74 +		mkinitrd /mnt/slitaz/boot/initrd
    1.75 +		initrd=initrd
    1.76 +		extraargs="mount=$(getuuid) subroot=slitaz"
    1.77  	fi
    1.78 +	echo "Install boot files..."
    1.79  	for i in /media/cdrom/boot/bzImage /media/cdrom/boot/*pxe* \
    1.80  		/media/cdrom/boot/isolinux/he* /media/cdrom/boot/isolinux/opt* \
    1.81  		/media/cdrom/README /media/cdrom/boot/memtest* ; do
    1.82  		[ -s $i ] && cp $i /mnt/slitaz/boot
    1.83  	done
    1.84 -	umount -d /media/cdrom
    1.85  	gettazboot /mnt/slitaz/boot/tazboot.exe
    1.86 -	mkinitrd /mnt/slitaz/boot/initrd
    1.87  	unix2dos > /mnt/slitaz/boot/tazboot.cmd <<EOT
    1.88  kernel=\\slitaz\\boot\\bzimage
    1.89 -initrd=\\slitaz\\boot\\initrd
    1.90 -rw root=/dev/null mount=$(getuuid) subroot=slitaz autologin
    1.91 +initrd=\\slitaz\\boot\\$initrd
    1.92 +rw root=/dev/null $extraargs autologin
    1.93  EOT
    1.94  	unix2dos /mnt/slitaz/boot/he* /mnt/slitaz/boot/opt* \
    1.95  		/mnt/slitaz/boot/README
    1.96 -	[ -x /mnt/slitaz/usr/sbin/mount.posixovl ] ||
    1.97 +	[ -d /mnt/slitaz/usr/sbin -a ! -x /mnt/slitaz/usr/sbin/mount.posixovl ] &&
    1.98  	cp $(which mount.posixovl) /mnt/slitaz/usr/sbin
    1.99  	! grep -qs tazboot /mnt/boot.ini && unix2dos >> /mnt/boot.ini <<EOT
   1.100  C:\\slitaz\\boot\\tazboot.exe="SliTaz"
   1.101 @@ -163,28 +176,63 @@
   1.102  [slitaz]
   1.103  device=\\slitaz\\boot\\tazboot.exe
   1.104  EOT
   1.105 -	unix2dos /mnt/config.sys
   1.106 +	unix2dos /mnt/config.sys 2> /dev/null
   1.107  }
   1.108  
   1.109  install()
   1.110  {
   1.111  	$DIALOG --clear \
   1.112 -		--title " SliTaz UMSDOS like installation " \
   1.113 +		--title " SliTaz UMSDOS way installation " \
   1.114  		--yes-label "Install" --yesno \
   1.115  "\nSliTaz will be installed in the subdirectory \\slitaz of the current
   1.116  DOS/Windows partition. You will see your files from /mnt/dos.\n\n
   1.117  You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
   1.118  To uninstall SliTaz, you have only to remove this directory.
   1.119  The file \\boot.ini or \\config.sys may be modified too.\n\n
   1.120 +SliTaz may run slowly on 'UMSDOS way' installation due to the 
   1.121 +posixovl filesystem. The 'TAZUSB way' installation run faster.\n\n
   1.122  To do a traditional installation with disk partitioning,
   1.123  start SliTaz Live with 'SliTaz RAM boot' menu.\n
   1.124 -" 16 70
   1.125 -	[ $? -eq 0 -a -n "$(which mount.posixovl)" ] || return
   1.126 +" 19 70
   1.127 +	[ $? -eq 0 ] || return
   1.128  	doinstall
   1.129 +	umount -d /media/cdrom
   1.130  	umount /proc
   1.131  	exec chroot /mnt/slitaz /sbin/init
   1.132  }
   1.133  
   1.134 +installtaz()
   1.135 +{
   1.136 +	$DIALOG --clear \
   1.137 +		--title " SliTaz TAZUSB way installation " \
   1.138 +		--yes-label "Install" --yesno \
   1.139 +"\nSliTaz will be installed in the subdirectory \\slitaz of the current
   1.140 +DOS/Windows partition. You will see your files from /mnt/dos.\n\n
   1.141 +You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
   1.142 +To uninstall SliTaz, you have only to remove this directory.
   1.143 +The file \\boot.ini or \\config.sys may be modified too.\n\n
   1.144 +The filesystem is loaded entirely into memory upon boot to
   1.145 +increase responsiveness. Only /home lands on hard disk.\n\n
   1.146 +To do a traditional installation with disk partitioning,
   1.147 +start SliTaz Live with 'SliTaz RAM boot' menu.\n
   1.148 +" 19 70
   1.149 +	[ $? -eq 0 ] || return
   1.150 +	doinstall tazusblike
   1.151 +	if [ -d /media/cdrom/fs ]; then
   1.152 +		zcat /mnt/slitaz/boot/rootfs.gz | cpio -idmu
   1.153 +	else
   1.154 +		for i in $(ls -r /media/cdrom/boot/rootfs*); do
   1.155 +			( zcat $i 2> /dev/null || unlzma -c $i ) | cpio -idmu
   1.156 +		done
   1.157 +	fi
   1.158 +	umount -d /media/cdrom
   1.159 +	mkdir /dos
   1.160 +	mount --move /mnt /dos
   1.161 +	ln -s /dos/slitaz/home /home
   1.162 +	umount /proc
   1.163 +	exec /sbin/init
   1.164 +}
   1.165 +
   1.166  tazboot()
   1.167  {
   1.168  	$DIALOG --clear \
   1.169 @@ -288,34 +336,38 @@
   1.170  	dd if=/media/cdrom/boot/gpxe of=/dev/fd0
   1.171  }
   1.172  
   1.173 +xfile()
   1.174 +{
   1.175 +	[ -n "$(which $1)" ] && echo -en "\"$2\"	\"$3\""
   1.176 +}
   1.177 +
   1.178  cdfile()
   1.179  {
   1.180 -	[ -s /media/cdrom/$1 ] && echo -en "$2	${3// /.}"
   1.181 +	[ -s /media/cdrom/$1 ] && echo -en "\"$2\"	\"$3\""
   1.182 +}
   1.183 +
   1.184 +fddata()
   1.185 +{
   1.186 +	[ $(get 28 /mnt/$ISO 1 2> /dev/null || echo 0) -ne 0 ] &&
   1.187 +	echo -en "\"$1\"	\"$2\""
   1.188  }
   1.189  
   1.190  fdbootstrap()
   1.191  {
   1.192 -	sz=$(echo $(get 28 /mnt/$ISO 1))
   1.193 -	if [ 0$sz -eq 0 ]; then
   1.194 -		$DIALOG --clear \
   1.195 -			--title " No floppy bootstrap available " \
   1.196 -			--msgbox \
   1.197 -"\nThe floppy bootstrap code is not available in the ISO file.\n\n
   1.198 -Can't create the floppy.\n
   1.199 -" 9 70
   1.200 -	else
   1.201 -		$DIALOG --clear \
   1.202 -			--title " Create a floppy bootstrap " \
   1.203 -			--yes-label "Continue" --yesno \
   1.204 +	sz=$((512 * $(echo $(get 28 /mnt/$ISO 1))))
   1.205 +	$DIALOG --clear \
   1.206 +		--title " Create a floppy bootstrap " \
   1.207 +		--yes-label "Continue" --yesno \
   1.208  "\nThe floppy will install a driver to access the ISO file
   1.209  on your hard disk and will emulate a CD-ROM during the boot process.\n\n 
   1.210  Please insert a floppy in drive now.\n 
   1.211  " 10 70
   1.212 -		[ $? -eq 0 ] || return
   1.213 -		dd if=/mnt/$ISO of=/dev/fd0 bs=1 count=$(($sz * 512)) \
   1.214 -			skip=$(( $(get 66 /mnt/$ISO) - ($sz * 512) ))
   1.215 -		echo "$ISO" | dd of=/dev/fd0 bs=512 seek=1
   1.216 -	fi
   1.217 +	[ $? -eq 0 ] || return
   1.218 +	dd if=/mnt/$ISO of=/dev/fd0 bs=1 count=512 \
   1.219 +		skip=$(( $(get 66 /mnt/$ISO) - $sz ))
   1.220 +	echo "$ISO" | dd of=/dev/fd0 bs=512 seek=1 count=1
   1.221 +	dd if=/mnt/$ISO of=/dev/fd0 bs=1 count=$sz seek=2 \
   1.222 +		skip=$(( $(get 66 /mnt/$ISO) - $sz + 512 ))
   1.223  }
   1.224  
   1.225  usbdev()
   1.226 @@ -371,7 +423,7 @@
   1.227  to machine.\n\n
   1.228  Please plug your USB stick in now.\n 
   1.229  " 19 70
   1.230 -	[ $? -eq 0 -a -n "$(which tazusb)" ] || return
   1.231 +	[ $? -eq 0 ] || return
   1.232  	usbdev || return
   1.233  	exec 3>&1
   1.234  	format=`$DIALOG  --clear \
   1.235 @@ -469,28 +521,32 @@
   1.236  dmesg > /tmp/dmesg
   1.237  
   1.238  while true; do
   1.239 -	exec 3>&1
   1.240 -	value=`$DIALOG  --clear \
   1.241 +	cat > /tmp/dialog <<EOT
   1.242 +$DIALOG  --clear \
   1.243  	--title " Welcome to SliTaz " \
   1.244 -	--menu "\nPlease select" 19 70 11 \
   1.245 +	--menu "" 21 70 15 \
   1.246  			"live"		"SliTaz RAM boot" \
   1.247  			"text"		"SliTaz RAM boot (text mode only)" \
   1.248  $(cdfile README		"readme"	"Show the README file") \
   1.249  $(cdfile md5sum		"md5"		"Check ISO files") \
   1.250 -			"install"	"Hard disk installation" \
   1.251 -			"usbkey"	"USB key read/write installation" \
   1.252 +$(xfile mount.posixovl	"install"	"Hard disk installation (UMSDOS way)") \
   1.253 +$(xfile mount.posixovl	"installtaz"	"Hard disk installation (TAZUSB way)") \
   1.254 +$(xfile tazusb		"usbkey"	"USB key read/write installation") \
   1.255  			"usbbootkey"	"USB boot key (read only)" \
   1.256 -			"fdbootstrap"	"Floppy bootstrap" \
   1.257 +$(fddata		"fdbootstrap"	"Floppy bootstrap") \
   1.258  			"tazboot"	"Get tazboot.exe Linux loader" \
   1.259  $(cdfile Xboot/memtest	"memtest"	"Get Memtest86") \
   1.260  $(cdfile boot/memtest	"fdmemtest"	"Create a Memtest86 boot floppy") \
   1.261  $(cdfile Xboot/gpxe	"gpxe"		"Get SliTaz Web boot utility") \
   1.262  $(cdfile boot/gpxe	"fdgpxe"	"Create a SliTaz Web boot floppy") \
   1.263 -			"restart"	"Restart the computer" \
   1.264 -			"stop"		"Power off" \
   1.265 +$(xfile reboot		"restart"	"Restart the computer") \
   1.266 +$(xfile poweroff	"stop"		"Power off") \
   1.267  			"bootlog"	"Linux boot messages" \
   1.268  			"shell"		"Shell prompt" \
   1.269 -	2>&1 1>&3`
   1.270 +
   1.271 +EOT
   1.272 +	exec 3>&1
   1.273 +	value=$(sh /tmp/dialog 2>&1 1>&3)
   1.274  	retval=$?
   1.275  	exec 3>&-
   1.276  	[ $retval -eq 0 ] || continue