slitaz-tools diff oldstuff/gtkdialog/bootfloppybox @ rev 813

Current state, features stabilized and open for bugfixes and translations.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Sep 09 03:27:04 2013 +0300 (2013-09-09)
parents fb636ac549ab
children 5bb075010572
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/oldstuff/gtkdialog/bootfloppybox	Mon Sep 09 03:27:04 2013 +0300
     1.3 @@ -0,0 +1,1477 @@
     1.4 +#! /bin/sh
     1.5 +# 
     1.6 +# Gtkdialog box for the mount command. Part of SliTaz tools.
     1.7 +#
     1.8 +VERSION=20120412
     1.9 +
    1.10 +# Check if user is root.
    1.11 +check_root()
    1.12 +{
    1.13 +	if test $(id -u) != 0 ; then
    1.14 +		echo -e "
    1.15 +You must be root to run `basename $0`. Please type 'su' and 
    1.16 +root password to become super-user.\n"
    1.17 +		exit 0
    1.18 +	fi
    1.19 +}
    1.20 +
    1.21 +# This function is used after each screen to continue or abort install.
    1.22 +check_retval()
    1.23 +{
    1.24 +	case $retval in
    1.25 +		1)
    1.26 +			rm -f /tmp/floppybox.grub.menu
    1.27 +			echo -e "\nVoluntary exit.\n" && exit 0 ;;
    1.28 +		255)
    1.29 +			rm -f /tmp/floppybox.grub.menu
    1.30 +			echo -e "ESC pressed.\n" && exit 0 ;;
    1.31 +	esac
    1.32 +}
    1.33 +
    1.34 +# Trigger floppy driver to update /sys/devices/platform/
    1.35 +dd if=/dev/fd0 bs=1k count=1 > /dev/null 2>&1
    1.36 +
    1.37 +# check or list floppy devices.
    1.38 +list_floppy()
    1.39 +{
    1.40 +	local list
    1.41 +	list=""
    1.42 +	for i in /sys/devices/platform/floppy.*/block/*; do
    1.43 +		[ -d $i ] || continue
    1.44 +		list="$list $(basename $i)"
    1.45 +	done
    1.46 +	[ -n "$1" ] || echo $list
    1.47 +	[ -n "$list" ]
    1.48 +}
    1.49 +
    1.50 +# dialog to select the floppy device
    1.51 +select_floppy()
    1.52 +{
    1.53 +	DEVICE="$DIALOG --title \" Floppy device \" --backtitle \"Boot Floppy Creation\" --clear --extra-button --extra-label \"Format\" --colors --radiolist \"
    1.54 +Select boot device
    1.55 +\" 18 70 50"
    1.56 +	on=on
    1.57 +	for i in $(list_floppy); do
    1.58 +		DEVICE="$DEVICE /dev/$i 'Floppy in $i' $on"
    1.59 +		on=off
    1.60 +	done
    1.61 +	DEVICE="$DEVICE floppy \"floppy image file boot.fd\" $on"
    1.62 +	DEVICE="$DEVICE cdrom \"cdrom image file boot.iso\" off 2>&1 1>&3"
    1.63 +	exec 3>&1
    1.64 +	DEVICE=`eval $DEVICE`
    1.65 +	retval=$?
    1.66 +	exec 3>&-
    1.67 +	check_retval
    1.68 +	if [ "$retval" = "3" ]; then
    1.69 +		case "$DEVICE" in
    1.70 +		/dev/*) fdformat -n $DEVICE;;
    1.71 +		esac
    1.72 +    	fi
    1.73 +}
    1.74 +
    1.75 +# Build menu for grub or grub4dos
    1.76 +mkmenu()
    1.77 +{
    1.78 +if [ "$1" = "grub4dos" ]; then
    1.79 +	SAVEDEFAULT="save default"
    1.80 +	cat > /tmp/floppybox.grub.menu <<EOT
    1.81 +# grub4dos menu
    1.82 +default /default
    1.83 +EOT
    1.84 +else
    1.85 +	SAVEDEFAULT="savedefault"
    1.86 +	cat > /tmp/floppybox.grub.menu <<EOT
    1.87 +# grub menu
    1.88 +default saved
    1.89 +EOT
    1.90 +fi
    1.91 +cat >> /tmp/floppybox.grub.menu <<EOT
    1.92 +timeout 8
    1.93 +color yellow/brown light-green/black
    1.94 +
    1.95 +EOT
    1.96 +entry=0
    1.97 +[ -f /boot/gpxe ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
    1.98 +title gPXE (Boot from the Web, PXE/iSCSI/AoE support)
    1.99 +	kernel /boot/gpxe $(dd if=/boot/gpxe bs=1 skip=519 count=255 2>/dev/null | strings)
   1.100 +
   1.101 +EOT
   1.102 +[ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ] \
   1.103 +	&& entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
   1.104 +title Smart Boot Manager (text - boot floppy, hard disk or CD/DVD)
   1.105 +	kernel /boot/memdisk floppy c=80 h=2 s=18
   1.106 +	initrd /boot/btmgr.gz
   1.107 +
   1.108 +EOT
   1.109 +http://mirror.slitaz.org/boot/plpbt.bin
   1.110 +[ -f /usr/share/boot/plpbt.bin ] \
   1.111 +	&& entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
   1.112 +title Plop Boot Manager (graphic - boot floppy, hard disk, CD/DVD or USB)
   1.113 +	kernel /boot/plpbt.bin
   1.114 +
   1.115 +EOT
   1.116 +[ -f /usr/share/boot/etherboot ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
   1.117 +title Etherboot (LAN boot, PXE or NBI)
   1.118 +	kernel /boot/etherboot
   1.119 +
   1.120 +EOT
   1.121 +[ -f /usr/share/boot/memtest.lzma -a -f /usr/share/boot/memdisk.lzma ] \
   1.122 +&& entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
   1.123 +title Memtest86+ (Test system memory)
   1.124 +	kernel /boot/memdisk floppy c=80 h=2 s=18
   1.125 +	initrd /boot/memtest.gz
   1.126 +
   1.127 +EOT
   1.128 +[ "$1" = "grub4dos" ] && entry=$(($entry + 3)) && cat >> /tmp/floppybox.grub.menu <<EOT
   1.129 +title Windows (scan ntldr)
   1.130 +	fallback $(($entry -3 + 1))
   1.131 +        find --set-root /ntldr
   1.132 +	chainloader /ntldr
   1.133 +	$SAVEDEFAULT --wait=2
   1.134 +
   1.135 +title Windows (scan cmldr)
   1.136 +	fallback $(($entry -3 + 2))
   1.137 +        find --set-root /cmldr
   1.138 +        chainloader /cmldr
   1.139 +	$SAVEDEFAULT --wait=2
   1.140 +
   1.141 +title Windows (scan io.sys)
   1.142 +	fallback $(($entry -3 + 3))
   1.143 +        find --set-root /io.sys
   1.144 +        chainloader /io.sys
   1.145 +	$SAVEDEFAULT --wait=2
   1.146 +
   1.147 +EOT
   1.148 +entry=$(($entry + 3)) && cat >> /tmp/floppybox.grub.menu <<EOT
   1.149 +title Windows (example on /dev/hda1)
   1.150 +	rootnoverify (hd0,0)
   1.151 +	chainloader +1
   1.152 +	$SAVEDEFAULT
   1.153 +
   1.154 +title Slitaz Frugal (example on /dev/hda1)
   1.155 +	root (hd0,0)
   1.156 +	kernel /boot/bzImage rw root=/dev/null vga=normal
   1.157 +	initrd /boot/rootfs.gz
   1.158 +	$SAVEDEFAULT
   1.159 +
   1.160 +title Slitaz Installed (example on /dev/hda2)
   1.161 +	root (hd0,1)
   1.162 +	kernel /boot/bzImage ro root=/dev/hda2 vga=normal
   1.163 +	$SAVEDEFAULT
   1.164 +
   1.165 +EOT
   1.166 +[ "$1" = "grub4dos" ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
   1.167 +title Slitaz cdrom image (example on /dev/hda1, DEFRAGMENTED)
   1.168 +        map (hd0,0)/boot/slitaz-cooking.iso (hd1)
   1.169 +        map --hook
   1.170 +        kernel (hd1)/boot/bzImage rw root=/dev/null vga=normal
   1.171 +        initrd (hd1)/boot/rootfs.gz
   1.172 +	$SAVEDEFAULT
   1.173 +
   1.174 +EOT
   1.175 +false && [ -f /usr/share/boot/grub.exe.lzma ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
   1.176 +title Grub4Dos
   1.177 +	kernel /boot/grub/grub.exe --config-file="configfile (fd0)/boot/grub/menu4dos.lst"
   1.178 +
   1.179 +EOT
   1.180 +}
   1.181 +
   1.182 +# Install grub or grub4dos on floppy
   1.183 +install_grub()
   1.184 +{
   1.185 +	LOOP=""
   1.186 +	GRUB_DEV=${DEVICE#/dev/}
   1.187 +	GRUB_DEV=${GRUB_DEV%% *}
   1.188 +	case "$DEVICE" in
   1.189 +	floppy*)
   1.190 +		LOOP="-o loop"
   1.191 +		GRUB_DEV=fd0
   1.192 +		DEVICE=boot.fd
   1.193 +		dd if=/dev/zero of=$DEVICE bs=18k count=80;;
   1.194 +	esac
   1.195 +	grep -qs "^# $2 menu" /tmp/floppybox.grub.menu || mkmenu $2
   1.196 +	case "$DEVICE" in
   1.197 +	/dev/*|boot.fd)
   1.198 +		yes y | mke2fs $DEVICE
   1.199 +		mkdir /media/floppy
   1.200 +		mount $LOOP $DEVICE /media/floppy
   1.201 +		if [ "$2" = "grub4dos" ]; then
   1.202 +			mkdir -p /media/floppy/boot
   1.203 +			unlzma -c /usr/share/boot/grldr.lzma > /media/floppy/grldr
   1.204 +			cp $1/boot/* /media/floppy/boot 2> /dev/null
   1.205 +			cp /tmp/floppybox.grub.menu /media/floppy/menu.lst
   1.206 +			umount -d /media/floppy
   1.207 +			bootlace --floppy --sectors-per-track=18 --heads=2 \
   1.208 +				 --chs --ext2 $DEVICE
   1.209 +		else
   1.210 +			mkdir -p /media/floppy/boot/grub
   1.211 +			cp /usr/lib/grub/i386-pc/stage? /media/floppy/boot/grub
   1.212 +			cp -a $1/boot /media/floppy
   1.213 +			cp /tmp/floppybox.grub.menu /media/floppy/boot/grub/menu.lst
   1.214 +			grub-set-default --root-directory=/media/floppy 0
   1.215 +			echo "($GRUB_DEV) $(losetup | grep $DEVICE | cut -d: -f1)" > $1/device.map
   1.216 +			[ -n "$LOOP" ] && LOOP="--device-map=$1/device.map"
   1.217 +			grub $LOOP --batch <<EOT
   1.218 +root ($GRUB_DEV)
   1.219 +setup ($GRUB_DEV)
   1.220 +quit
   1.221 +EOT
   1.222 +			umount -d /media/floppy
   1.223 +		fi ;;
   1.224 +	cdrom*)
   1.225 +		mkdir -p $1/boot/grub 2> /dev/null
   1.226 +		cp /tmp/floppybox.grub.menu $1/boot/grub/menu.lst
   1.227 +		if [ "$2" = "grub4dos" ]; then
   1.228 +			unlzma -c /usr/share/boot/grldr.lzma > $1/boot/grub/grldr
   1.229 +			genisoimage -R -o boot.iso -b boot/grub/grldr \
   1.230 +				-c boot/boot.cat -no-emul-boot -boot-load-seg 0x1000 \
   1.231 +				-hide boot/boot.cat -input-charset iso8859-1 $1
   1.232 +		else
   1.233 +			cp /usr/lib/grub/i386-pc/stage2_eltorito $1/boot/grub
   1.234 +			genisoimage -R -o boot.iso -b boot/grub/stage2_eltorito \
   1.235 +				-c boot/boot.cat -no-emul-boot -boot-load-size 4 \
   1.236 +				-hide boot/boot.cat -input-charset iso8859-1 \
   1.237 +				-boot-info-table $1
   1.238 +		fi ;;
   1.239 +	esac
   1.240 +}
   1.241 +
   1.242 +# Build /init for floppies from iso image
   1.243 +buildinit()
   1.244 +{
   1.245 +	mv $1/init $1/init.org
   1.246 +	for i in /dev/tty0 /dev/[sh]d[ab]? ; do
   1.247 +		[ -e $1$i ] || cp -a $i $1/dev
   1.248 +	done
   1.249 +	cat > $1/init <<EOTEOT
   1.250 +#!/bin/sh
   1.251 +
   1.252 +cat_floppy()
   1.253 +{
   1.254 +	tmp="\$(dd if=/dev/fd0 count=1 2> /dev/null | md5sum)"
   1.255 +	echo -n "Insert floppy \$num for \$name and press Enter or Q to skip"
   1.256 +	while true; do
   1.257 +		echo -n ":"
   1.258 +		read -t 10 answer < /dev/tty0
   1.259 +		case "\$answer" in
   1.260 +		Q*|q*|A*|a*) break 3;;
   1.261 +		esac
   1.262 +		dd if=/dev/fd0 count=1 > /tmp/bs.\$\$ 2> /dev/null
   1.263 +		[ -s /tmp/bs.\$\$ ] || continue
   1.264 +		[ "\$(md5sum < /tmp/bs.\$\$)" != "\$tmp" ] || continue
   1.265 +		rm -f /tmp/bs.\$\$
   1.266 +		break
   1.267 +	done
   1.268 +	dd if=/dev/fd0 of=/tmp/rootfs.\$num 2> /dev/null || continue
   1.269 +	cat /tmp/rootfs.\$num >> \$1
   1.270 +	rm -f /tmp/rootfs.\$num
   1.271 +	num=\$((\$num+1))
   1.272 +}
   1.273 +
   1.274 +mount -t proc proc /proc
   1.275 +total=\$(grep MemTotal /proc/meminfo | sed 's/[^0-9]//g')
   1.276 +# the floppy driver may not be included in kernel
   1.277 +insmod /lib/modules/*/kernel/drivers/block/floppy.ko.gz 2> /dev/null
   1.278 +# loram may put floppy.ko.gz module in /lib
   1.279 +insmod /lib/floppy.ko.gz 2> /dev/null
   1.280 +case "\$(/sbin/blkid 2>&1)" in
   1.281 +*not\ found*)
   1.282 +	cat <<EOT
   1.283 +
   1.284 +You can preinstall SliTaz in an ext3 partition with this floppy set.
   1.285 +
   1.286 +Simply enter the device name (/dev/XXXX) to create the slitaz/install.sh or
   1.287 +leave it blank to skip :
   1.288 +EOT
   1.289 +	read -t 60 device < /dev/tty0
   1.290 +	[ -n "\$device" ] && mount \$device /mnt && mkdir /mnt/slitaz ;;
   1.291 +*TYPE=\"ext*)
   1.292 +	cat <<EOT
   1.293 +
   1.294 +You can preinstall SliTaz in one of these ext3 partitions:
   1.295 +\$(blkid | grep 'TYPE="ext')
   1.296 +
   1.297 +Simply enter the device name (/dev/XXXX) to create the slitaz/install.sh or
   1.298 +leave it blank to skip :
   1.299 +EOT
   1.300 +	read -t 60 device < /dev/tty0
   1.301 +	[ -n "\$device" ] && mount \$device /mnt && mkdir /mnt/slitaz ;;
   1.302 +*)
   1.303 +	cat <<EOT
   1.304 +
   1.305 +You can preinstall SliTaz in an ext3 partition with this floppy set.
   1.306 +After the boot process is completed, create a partition with 'fdisk',
   1.307 +format it with 'mke2fs -j' and reboot from the floppies again.
   1.308 +
   1.309 +EOT
   1.310 +esac
   1.311 +umount /proc
   1.312 +while read name min num count file md5; do
   1.313 +	[ -e \$file ] && continue
   1.314 +	[ \$total -lt \$min ] && break
   1.315 +	while [ \$count -ne 0 ]; do
   1.316 +		cat_floppy /tmp/rootfs
   1.317 +		count=\$((\$count-1))
   1.318 +	done
   1.319 +	echo "\$md5  /tmp/rootfs" | md5sum -c || break
   1.320 +	cpio -idmu < /tmp/rootfs > /dev/null 2>&1 ||
   1.321 +	( zcat /tmp/rootfs 2> /dev/null || unlzma -c /tmp/rootfs ) | cpio -idmu
   1.322 +	if [ -d /mnt/slitaz ]; then
   1.323 +		cp /tmp/rootfs /mnt/slitaz/rootfs.\$num ||
   1.324 +		mv -f /mnt/slitaz /mnt/slitaz-aborted
   1.325 +	fi
   1.326 +	rootfslist="\$rootfslist \$num"
   1.327 +	rm -f /tmp/rootfs*
   1.328 +	mkdir /sbin 2> /dev/null
   1.329 +done <<EOT
   1.330 +$(while read line; do echo $line; done)
   1.331 +EOT
   1.332 +if [ -d /mnt/slitaz ]; then
   1.333 +	cat > /mnt/slitaz/install.sh <<EOT
   1.334 +#!/bin/sh
   1.335 +
   1.336 +if [ -z "\\\$1" ]; then
   1.337 +	echo "Usage: \\\$0 target-directory"
   1.338 +	exit 1
   1.339 +fi
   1.340 +dir=\\\$(cd \\\$(dirname \\\$0); pwd)
   1.341 +cd \\\$1
   1.342 +for i in 0 \$rootfslist ; do
   1.343 +	[ -s \\\$dir/rootfs.\\\$i ] || continue
   1.344 +	cpio -idmu < \\\$dir/rootfs.\\\$i > /dev/null 2>&1 ||
   1.345 +	( zcat \\\$dir/rootfs.\\\$i 2> /dev/null || unlzma -c \\\$dir/rootfs.\\\$i ) | cpio -idmu
   1.346 +done
   1.347 +if ! mv -f init.org init 2> /dev/null; then
   1.348 +	for i in \\\$(ls rootfs*gz | sed '1!G;h;\\\$!d'); do
   1.349 +		mount -o loop,ro \\\$i /media/cdrom && rm -f \\\$i
   1.350 +		cp -a /media/cdrom/. .
   1.351 +		umount -d /media/cdrom
   1.352 +	done
   1.353 +fi
   1.354 +mkdir boot && cp \\\$dir/bzImage boot 
   1.355 +cp -a /usr/lib/grub/i386-pc boot/grub
   1.356 +cat > boot/grub/menu.lst<<EOF
   1.357 +# /boot/grub/menu.lst: GRUB boot loader configuration.
   1.358 +#
   1.359 +
   1.360 +# By default, boot the first entry.
   1.361 +default 0
   1.362 +
   1.363 +# Boot automatically after 8 secs.
   1.364 +timeout 8
   1.365 +
   1.366 +# Change the colors.
   1.367 +color yellow/brown light-green/black
   1.368 +
   1.369 +title	SliTaz GNU/Linux
   1.370 +	kernel /boot/bzImage root=\$device
   1.371 +                
   1.372 +EOF
   1.373 +grub-install --no-floppy --root-directory=\\\$PWD \${device%[1-9]*}
   1.374 +cd -
   1.375 +EOT
   1.376 +	chmod +x /mnt/slitaz/install.sh
   1.377 +	num=1
   1.378 +	name="the Linux kernel"
   1.379 +	dd count=0 of=/mnt/slitaz/bzImage.fd > /dev/null 2>&1
   1.380 +	fullsize=1
   1.381 +	while [ \$(stat -c %s /mnt/slitaz/bzImage.fd) -lt \$fullsize ]; do
   1.382 +		cat_floppy /mnt/slitaz/bzImage.fd
   1.383 +		setup=\$(dd if=/mnt/slitaz/bzImage.fd skip=497 bs=1 count=1 2> /dev/null | hexdump -e '"" 1/1 "%d" "\n"')
   1.384 +		syssize=\$(dd if=/mnt/slitaz/bzImage.fd skip=500 bs=1 count=4 2> /dev/null | hexdump -e '"" 1/4 "%d" "\n"')
   1.385 +		cmdline=\$(dd if=/mnt/slitaz/bzImage.fd skip=552 bs=1 count=4 2> /dev/null | hexdump -e '"" 1/4 "%d" "\n"')
   1.386 +		initrd=\$(dd if=/mnt/slitaz/bzImage.fd skip=540 bs=1 count=4 2> /dev/null | hexdump -e '"" 1/4 "%d" "\n"')
   1.387 +		[ \$cmdline -eq 0 ] || cmdline=512
   1.388 +		size=\$((512 + \$setup * 512 + \$cmdline + \$syssize * 16))
   1.389 +		[ -s /etc/slitaz-release ] || initrd=0
   1.390 +		fullsize=\$((\$size + \$initrd + 512))
   1.391 +		[ \$(stat -c %s /mnt/slitaz/bzImage.fd) -lt \$size ] ||
   1.392 +			name="the first initramfs"
   1.393 +	done
   1.394 +	[ -s /etc/slitaz-release ] &&
   1.395 +	dd if=/mnt/slitaz/bzImage.fd bs=512 skip=\$((\$setup+1+\$cmdline/512+(31+\$syssize)/32)) > /mnt/slitaz/rootfs.0 &&
   1.396 +	dd bs=1 seek=\$initrd count=0 of=/mnt/slitaz/rootfs.0
   1.397 +	dd if=/dev/zero of=/mnt/slitaz/bzImage.fd conv=notrunc bs=1 count=4 seek=552
   1.398 +	dd if=/dev/zero of=/mnt/slitaz/bzImage.fd conv=notrunc bs=1 count=8 seek=536
   1.399 +	dd if=/mnt/slitaz/bzImage.fd bs=512 count=\$((\$setup+1)) > /mnt/slitaz/bzImage
   1.400 +	dd if=/mnt/slitaz/bzImage.fd bs=512 skip=\$((\$setup+1+\$cmdline/512)) >> /mnt/slitaz/bzImage
   1.401 +	rm -f /mnt/slitaz/bzImage.fd
   1.402 +	size=\$((512 + \$setup * 512 + \$syssize * 16))
   1.403 +	dd bs=1 seek=\$size count=0 of=/mnt/slitaz/bzImage > /dev/null 2>&1
   1.404 +	[ \$(stat -c %s /mnt/slitaz/bzImage) -eq \$size ] ||
   1.405 +	mv -f /mnt/slitaz /mnt/slitaz-aborted
   1.406 +fi
   1.407 +[ -d /sbin ] && mv -f /init.org /init && exec /init
   1.408 +exec /bin/ash < /dev/tty0 > /dev/tty0 2>&1
   1.409 +EOTEOT
   1.410 +	chmod +x $1/init
   1.411 +}
   1.412 +
   1.413 +# write a 32 bits data
   1.414 +# usage: storelong offset data32 file
   1.415 +storelong()
   1.416 +{
   1.417 +	printf "00000  %02X %02X %02X %02X \n" \
   1.418 +		$(( $2 & 255 )) $(( ($2>>8) & 255 )) \
   1.419 +		$(( ($2>>16) & 255 )) $(( ($2>>24) & 255 )) | \
   1.420 +	hexdump -R | dd bs=1 conv=notrunc of=$3 seek=$(( $1 )) 2> /dev/null
   1.421 +}
   1.422 +
   1.423 +# read a 32 bits data
   1.424 +# usage: getlong offset file
   1.425 +getlong()
   1.426 +{
   1.427 +	dd if=$2 bs=1 skip=$(( $1 )) count=4 2> /dev/null | \
   1.428 +		hexdump -e '"" 1/4 "%d" "\n"'
   1.429 +}
   1.430 +
   1.431 +# output floppy images set
   1.432 +floppysetcat()
   1.433 +{
   1.434 +	KERNEL="$1"
   1.435 +	INITRD="$2"
   1.436 +	shift 2
   1.437 +	CMDLINE="$@"
   1.438 +
   1.439 +	# bzImage offsets
   1.440 +	SetupSzOfs=497
   1.441 +	SyssizeOfs=500
   1.442 +	CodeAdrOfs=0x214
   1.443 +	RamfsAdrOfs=0x218
   1.444 +	RamfsLenOfs=0x21C
   1.445 +	ArgPtrOfs=0x228
   1.446 +
   1.447 +	# boot+setup address
   1.448 +	SetupBase=0x90000
   1.449 +
   1.450 +	stacktop=0x9E00
   1.451 +
   1.452 +	bs=/tmp/bs$$
   1.453 +
   1.454 +	# Get and patch boot sector
   1.455 +	dd if=$KERNEL bs=512 count=1 of=$bs 2> /dev/null
   1.456 +	uudecode <<EOT | dd of=$bs conv=notrunc 2> /dev/null
   1.457 +begin-base64 644 -
   1.458 +/L+6nWgAkAcGF4n8McC5HQDzq1sfD6mg8X1ABlfFd3ixBvOlZWaPR3gGH8ZF
   1.459 ++D/6l1hB6DQBvgACA3QO6HYBWwseKAJ0LFNH6AoBXuhmAbAgzRCwCM0QTuhl
   1.460 +ATwIdAOIBK05NigCdPDoPgE8CnXgiHz+ieb/TBD/TBi/9AGBTRz/gMdFMACc
   1.461 +sBCxBUi0k4lEHLABiUQUmGaY0+BIZgMFZtPoaAAQB7+AACn4nHMCAccx21BW
   1.462 +6J4AXrkAgLSH/kQczRVYnXfcoRoCvxwCsQk4RBxyuJPNE+oAACCQsEYoyL7b
   1.463 +AejSAF3rI4D5E3IEOMF3a4D+AnIEOOZ3bGCB/QAGdCoGUlFTlrQCULEGtQTB
   1.464 +xQSwDyHoBJAnFEAn6IwA/s117LAgzRDitOiWAJjNE2FSUCjIdwKwAZg5+HIC
   1.465 +ifhQtALNE5VeWFpyoJVBjuGAxwJPdFFOdfSM4ZU4wXVFiMj+xrEBOOZ1O4j0
   1.466 +/sW2AID9UHIwOi7wAXIqtQBgvt4B/kQMU+gxAFvoOAB1FlKYzRO4AQLNE1rQ
   1.467 +1Dpk/nXqRgjkdeVh64sWB7AxLAO0DrsHAM0QPA1088OwDejv/6wIwHX4w79s
   1.468 +BLFbZQINuA0BZToNdArNFnT0mM0Wju9Hw1g6AEluc2VydCBkaXNrIDEuBw0A
   1.469 +AA==
   1.470 +====
   1.471 +EOT
   1.472 +
   1.473 +	# Get setup
   1.474 +	setupsz=$(getlong $SetupSzOfs $bs)
   1.475 +	setupszb=$(( $setupsz & 255 ))
   1.476 +	dd if=$KERNEL bs=512 skip=1 count=$setupszb 2> /dev/null >> $bs
   1.477 +
   1.478 +	# Store cmdline after setup
   1.479 +	if [ -n "$CMDLINE" ]; then
   1.480 +		echo -n "$CMDLINE" | dd bs=512 count=1 conv=sync 2> /dev/null >> $bs
   1.481 +		storelong ArgPtrOfs $(( $SetupBase + $stacktop )) $bs
   1.482 +	fi
   1.483 +
   1.484 +	# Compute initramfs size
   1.485 +	initrdlen=0
   1.486 +	padding=0
   1.487 +	for i in $( echo $INITRD | sed 's/,/ /' ); do
   1.488 +		[ -s "$i" ] || continue
   1.489 +		initrdlen=$(( $initrdlen + $padding ))
   1.490 +		padding=$(stat -c %s $i)
   1.491 +		initrdlen=$(( $initrdlen + $padding ))
   1.492 +		padding=$(( 4096 - ($padding & 4095) ))
   1.493 +		[ $padding -eq 4096 ] && padding=0
   1.494 +	done
   1.495 +	Ksize=$(( $(getlong $SyssizeOfs $bs)*16 ))
   1.496 +	Kpad=$(( (($Ksize+4095)/4096)*4096 - Ksize ))
   1.497 +	if [ $initrdlen -ne 0 ]; then
   1.498 +		Kbase=$(getlong $CodeAdrOfs $bs)
   1.499 +		storelong $RamfsAdrOfs \
   1.500 +			$(( (0x1000000 - $initrdlen) & 0xFFFF0000 )) $bs
   1.501 +		storelong $RamfsLenOfs $initrdlen $bs
   1.502 +	fi
   1.503 +
   1.504 +	# Output boot sector + setup + cmdline
   1.505 +	dd if=$bs 2> /dev/null
   1.506 +
   1.507 +	# Output kernel code
   1.508 +	dd if=$KERNEL bs=512 skip=$(( $setupszb + 1 )) 2> /dev/null
   1.509 +
   1.510 +	# Pad to next sector
   1.511 +	Kpad=$(( 512 - ($(stat -c %s $KERNEL) & 511) ))
   1.512 +	[ $Kpad -eq 512 ] || dd if=/dev/zero bs=1 count=$Kpad 2> /dev/null
   1.513 +
   1.514 +	# Output initramfs
   1.515 +	padding=0
   1.516 +	for i in $( echo $INITRD | sed 's/,/ /' ); do
   1.517 +		[ -s "$i" ] || continue
   1.518 +		[ $padding -ne 0 ] && dd if=/dev/zero bs=1 count=$padding
   1.519 +		dd if=$i 2> /dev/null
   1.520 +		padding=$(( 4096 - ($(stat -c %s $i) & 4095) ))
   1.521 +		[ $padding -eq 4096 ] && padding=0
   1.522 +	done
   1.523 +
   1.524 +	# Cleanup
   1.525 +	rm -f $bs
   1.526 +}
   1.527 +
   1.528 +# Create boot floppy set from kernel, initrd & cmdline
   1.529 +floppyset()
   1.530 +{
   1.531 +	floppysetcat "$@" | split -b 1440k /dev/stdin floppy$$
   1.532 +	i=1
   1.533 +	ls floppy$$* | while read file ; do
   1.534 +		output=$(printf "fd%03d.img" $i)
   1.535 +		cat $file /dev/zero | dd bs=1k count=1440 of=$output conv=sync 2> /dev/null
   1.536 +		rm -f $file
   1.537 +		i=$(( $i + 1 ))
   1.538 +	done
   1.539 +}
   1.540 +
   1.541 +# Create boot floppy set from a SliTaz ISO image
   1.542 +floppysetfromiso()
   1.543 +{
   1.544 +	mkdir /tmp/iso$$
   1.545 +	mount -o loop,ro $1 /tmp/iso$$
   1.546 +	rootfs="$(ls /tmp/iso$$/boot/rootfs*z 2> /dev/null | tail -1)"
   1.547 +	bzimage=/tmp/iso$$/boot/bzImage
   1.548 +	if [ -z "$rootfs" -o ! -s $bzimage ]; then
   1.549 +		umount -d /tmp/iso$$
   1.550 +		rm -rf /tmp/iso$$
   1.551 +		echo "Not a SliTaz ISO image !"
   1.552 +		return 1
   1.553 +	fi
   1.554 +	mkdir -p /tmp/rootfs$$/fs
   1.555 +	n=1
   1.556 +	for i in $(ls /tmp/iso$$/boot/rootfs*z | sort -r); do
   1.557 +		mkdir /tmp/rootfs$$/$n
   1.558 +		ln -s $i /tmp/rootfs$$/$n
   1.559 +		n=$(($n + 1))
   1.560 +	done
   1.561 +	echo "Unpacking rootfs..."
   1.562 +	( zcat $rootfs 2> /dev/null | unlzma -c $rootfs ) | \
   1.563 +		( cd /tmp/rootfs$$/fs ; cpio -idm > /dev/null )
   1.564 +	if [ $(unlzma -c $rootfs 2> /dev/null| wc -c) -gt $(stat -c %s $rootfs) ]; then
   1.565 +		if [ $(du -ck $rootfs $bzimage | awk 'END { print $1 }') -gt 15296 ]; then
   1.566 +	# The rootfs.gz file is too big, extract a minimum bootfs with busybox stuff
   1.567 +			echo "Extracting bootfs..."
   1.568 +			mv /tmp/rootfs$$/fs /tmp/rootfs$$/fs0
   1.569 +			for i in lib bin sbin usr/bin usr/sbin ; do
   1.570 +				mkdir -p /tmp/rootfs$$/fs/$i
   1.571 +			done
   1.572 +			cd /tmp/rootfs$$/fs0
   1.573 +			dir=$(echo lib/modules/*/kernel/drivers/block)
   1.574 +			[ -d $dir ] && mkdir -p ../fs/$dir
   1.575 +			[ -f $dir/floppy.ko.gz ] && mv $dir/floppy.ko.gz ../fs/$dir
   1.576 +			for i in dev init mnt proc sys tmp ; do
   1.577 +				mv $i ../fs
   1.578 +			done
   1.579 +			mv lib/ld-* ../fs/lib
   1.580 +			LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so bin/busybox | \
   1.581 +			awk '/\/lib\/lib/ { print $3 }' | while read lib ; do
   1.582 +				while [ -L .$lib ]; do
   1.583 +					local target
   1.584 +					target="$(readlink ".$lib")"
   1.585 +					case "$target" in
   1.586 +					/*)	;;
   1.587 +					*)	target="$(dirname $lib)/$target" ;;
   1.588 +					esac
   1.589 +					mv ".$lib" ../fs/lib
   1.590 +					lib="$target"
   1.591 +				done
   1.592 +				mv ".$lib" ../fs/lib
   1.593 +			done
   1.594 +			for i in $(bin/busybox | awk '{ if (s) printf "%s",$0 }
   1.595 +				   /Currently/ { s=1 }' | sed 's/,//g'); do
   1.596 +				for j in bin sbin usr/bin usr/sbin ; do
   1.597 +					[ -e $j/$i ] && mv $j/$i ../fs/$j/$i
   1.598 +				done
   1.599 +			done
   1.600 +			mv bin/busybox ../fs/bin
   1.601 +			[ -e ../fs/bin/cpio ] || mv bin/cpio ../fs/bin
   1.602 +			rm -f ../1/*
   1.603 +			find | cpio -o -H newc | lzma e ../1/rootfs.gz -si
   1.604 +			cd - > /dev/null
   1.605 +			rm -rf /tmp/rootfs$$/fs0
   1.606 +		else
   1.607 +	# The rootfs.gz file fits in 15MB, no need to split it.
   1.608 +			rm -rf /tmp/rootfs$$/1
   1.609 +		fi
   1.610 +	else
   1.611 +	# This is a loram rootfs.gz, extract loram bootstrap
   1.612 +		echo "Splitting loram rootfs..."
   1.613 +		offset=$(awk '/07070100/ { o+=index($0,"07070100"); print int(o/4) ; exit } { o+=1+length() }' < $rootfs)
   1.614 +		dd if=$rootfs skip=$(($offset / 1024)) bs=4k count=1 2> /dev/null | \
   1.615 +		dd skip=$(($offset % 1024)) bs=4 of=/tmp/rootfs$$/1/root 2> /dev/null
   1.616 +		dd if=$rootfs skip=$((1 + ($offset / 1024) )) bs=4k \
   1.617 +			>> /tmp/rootfs$$/1/root 2> /dev/null
   1.618 +		rm -f /tmp/rootfs$$/1/rootfs*
   1.619 +	fi
   1.620 +	# Create extra rootfs floppies
   1.621 +	for i in /tmp/rootfs$$/[1-9]*/root* ; do
   1.622 +		[ -f $i ] || continue
   1.623 +		echo "Creating floppies for rootfs $(basename $(dirname $i) )..."
   1.624 +		case "$(dd if=$i bs=1 count=4 2> /dev/null)" in
   1.625 +		0707) cat $i ;;
   1.626 +		*)    zcat $i 2> /dev/null || unlzma -c $i ;;
   1.627 +		esac | cpio -t > $(dirname $i)/files.list
   1.628 +		sed -i '/ blocks$/d' $(dirname $i)/files.list
   1.629 +		x=$(readlink $i)
   1.630 +		[ -n "$x" ] || x=$i
   1.631 +		pad=$(( $(stat -c %s $x ) % 1474560 ))
   1.632 +		[ $pad -ne 0 ] && pad=$(( 1474560 - $pad ))
   1.633 +		dd if=/dev/zero bs=1 count=$pad 2> /dev/null | cat $i - | \
   1.634 +		split -b 1440k /dev/stdin $(dirname $i)/floppy
   1.635 +	done
   1.636 +	selection="$(grep -s append /tmp/iso$$/boot/isolinux/common.cfg | sed 's/.*append //')"
   1.637 +	[ -n "$selection" ] || selection="0 slitaz"
   1.638 +	set -- $selection
   1.639 +	selection=""
   1.640 +	while [ -n "$2" ]; do
   1.641 +		[ ! -d /tmp/rootfs$$/1 -a -z "$4" ] && break
   1.642 +		case "$1" in
   1.643 +		*G)	selection="$2 $(( ${1%G} * 1024 * 1024 )) $selection" ;;
   1.644 +		*M)	selection="$2 $(( ${1%M} * 1024 )) $selection" ;;
   1.645 +		*)	selection="$2 $1 $selection" ;;
   1.646 +		esac
   1.647 +		shift 2
   1.648 +	done
   1.649 +	echo "Creating /init ..."
   1.650 +	base=100
   1.651 +	set -- $selection
   1.652 +	for i in /tmp/rootfs$$/[1-9]* ; do
   1.653 +		[ -d $i ] || continue
   1.654 +		while read file; do
   1.655 +			[ -e $i/../fs/$file ] && continue
   1.656 +			[ $(grep -- "$file" $i/../*/files.list | wc -l) -eq 1 ] &&
   1.657 +			break
   1.658 +		done < $i/files.list
   1.659 +		printf "%s %s %03d %d %s %s\n" \
   1.660 +			$1 $2 $base $(ls $i/floppy* | wc -l) $file \
   1.661 +			$(cat $i/floppy* | md5sum - | awk '{print $1}')
   1.662 +		base=$(($base + 100))
   1.663 +		shift 2
   1.664 +	done | buildinit /tmp/rootfs$$/fs
   1.665 +	cmdline="$(grep 'append *initrd' /tmp/iso$$/boot/isolinux/isolinux.cfg | tail -n 1 | sed 's/.*gz //')"
   1.666 +	( cd /tmp/rootfs$$/fs ; find | cpio -o -H newc ) | lzma e /tmp/rootfs$$/rootfs -si
   1.667 +	echo "Creating first stage boot floppies..."
   1.668 +	floppyset $bzimage /tmp/rootfs$$/rootfs "$cmdline"
   1.669 +	base=100
   1.670 +	for i in /tmp/rootfs$$/[1-9]* ; do
   1.671 +		[ -d $i ] || continue
   1.672 +		j=0
   1.673 +		for f in $i/floppy* ; do
   1.674 +			mv $f $(printf "fd%03d.img" $(( $base + $j )) )
   1.675 +			j=$(($j + 1))
   1.676 +		done
   1.677 +		base=$(($base + 100))
   1.678 +	done
   1.679 +	rm -rf /tmp/rootfs$$
   1.680 +	umount -d /tmp/iso$$
   1.681 +	rm -rf /tmp/iso$$
   1.682 +}
   1.683 +
   1.684 +# Show new boot floppy set
   1.685 +dialogwritefloppyset()
   1.686 +{
   1.687 +	if ! list_floppy check; then
   1.688 +		du -h fd???.img
   1.689 +		return
   1.690 +	fi
   1.691 +	while true; do
   1.692 +	exec 3>&1
   1.693 +	IMAGE=`$DIALOG --title " Write floppy image " \
   1.694 +		--backtitle "Boot floppy set creation on $DEVICE" --clear \
   1.695 +		--colors --radiolist "
   1.696 +    Insert a blank floppy in drive and
   1.697 +select the floppy image you want to write.
   1.698 +" 18 46 46 \
   1.699 +		$(on="on"; for i in fd???.img; do echo "$i $(du -h $i | cut -f1) $on "; on="off"; done) 2>&1 1>&3`
   1.700 +	retval=$?
   1.701 +	exec 3>&-
   1.702 +	check_retval
   1.703 +	dd if=$IMAGE of=$DEVICE
   1.704 +	done
   1.705 +}
   1.706 +
   1.707 +dialognofloppyset()
   1.708 +{
   1.709 +	cat << EOT
   1.710 +The boot loader can't load the kernel and the initramfs in the first 16MB
   1.711 +of RAM. The total size exceeds 15MB. No floppy image is created.
   1.712 +EOT
   1.713 +}
   1.714 +
   1.715 +# Check for iso 9660 image
   1.716 +isiso()
   1.717 +{
   1.718 +	mkdir /tmp/iso$$
   1.719 +	mount -o loop,ro $1 /tmp/iso$$ 2> /dev/null
   1.720 +	status=$?
   1.721 +	umount -d /tmp/iso$$ 2> /dev/null
   1.722 +	rm -rf /tmp/iso$$
   1.723 +	return $status
   1.724 +}
   1.725 +
   1.726 +dialogfloppyset()
   1.727 +{
   1.728 +	: ${DIALOG=dialog}
   1.729 +	while true; do
   1.730 +	exec 3>&1
   1.731 +	KERNEL=`$DIALOG --title " Select a Linux kernel or a SliTaz iso " \
   1.732 +		--backtitle "Boot floppy set creation on $DEVICE" --clear \
   1.733 +		--colors --fselect "$PWD" 10 70 \
   1.734 +		2>&1 1>&3`
   1.735 +	retval=$?
   1.736 +	exec 3>&-
   1.737 +	check_retval
   1.738 +	[ -f $KERNEL ] && break
   1.739 +	done
   1.740 +	if isiso $KERNEL ; then
   1.741 +		bootfloppybox call mkisofloppies $KERNEL
   1.742 +		dialogwritefloppyset
   1.743 +		return
   1.744 +	fi
   1.745 +	exec 3>&1
   1.746 +	INITRD=`$DIALOG --title " Select an Initramfs " \
   1.747 +		--backtitle "Boot floppy set creation on $DEVICE" --clear \
   1.748 +		--colors --fselect "$PWD" 10 70 \
   1.749 +		2>&1 1>&3`
   1.750 +	retval=$?
   1.751 +	exec 3>&-
   1.752 +	check_retval
   1.753 +	[ -f "$INITRD" ] || INITRD=""
   1.754 +	exec 3>&1
   1.755 +	CMDLINE=`$DIALOG --title " Enter boot command line " \
   1.756 +		--backtitle "Boot floppy set creation on $DEVICE" --clear \
   1.757 +		--colors --inputbox "Kernel command line" 10 70 "rw root=/dev/null autologin" \
   1.758 +		2>&1 1>&3`
   1.759 +	retval=$?
   1.760 +	exec 3>&-
   1.761 +	check_retval
   1.762 +	bootfloppybox call mkfloppies "$KERNEL" "$INITRD" "$CMDLINE" &&
   1.763 +	dialogwritefloppyset ||
   1.764 +	dialognofloppyset
   1.765 +}
   1.766 +
   1.767 +#
   1.768 +# Create floppy image set
   1.769 +#
   1.770 +export IMAGE_SET='
   1.771 +<window title="Image set generator" icon-name="gtk-floppy">
   1.772 +  <vbox>
   1.773 +    <text use-markup="true">
   1.774 +      <label>
   1.775 +"
   1.776 +<b>Create a boot floppy set</b>
   1.777 +"
   1.778 +      </label>
   1.779 +    </text>
   1.780 +    <notebook labels="Slitaz only|Any Linux">
   1.781 +    <frame Slitaz only (no size limit)>
   1.782 +    <vbox>
   1.783 +    <text wrap="false" width-chars="44" use-markup="true">
   1.784 +      <label>
   1.785 +"
   1.786 +Slitaz uses a floppy boot flavor as a first
   1.787 +stage boot to break the tiny loader 15MB limit.
   1.788 +"
   1.789 +      </label>
   1.790 +    </text>
   1.791 +    <hbox>
   1.792 +      <text use-markup="true">
   1.793 +        <label>"<b>Slitaz ISO : </b>"</label>
   1.794 +      </text>
   1.795 +      <entry accept="filename">
   1.796 +        <label>Select a Slitaz ISO image</label>
   1.797 +        <variable>ISO</variable>
   1.798 +      </entry>
   1.799 +      <button>
   1.800 +        <input file stock="gtk-open"></input>
   1.801 +        <action type="fileselect">ISO</action>
   1.802 +      </button>
   1.803 +    </hbox>
   1.804 +    <hbox>
   1.805 +      <text use-markup="true">
   1.806 +        <label>"<b>Output directory : </b>"</label>
   1.807 +      </text>
   1.808 +      <entry accept="directory">
   1.809 +        <label>Select output directory</label>
   1.810 +        <variable>FILE_DIRECTORY</variable>
   1.811 +        <default>/tmp</default>
   1.812 +      </entry>
   1.813 +      <button>
   1.814 +        <input file stock="gtk-open"></input>
   1.815 +        <action type="fileselect">FILE_DIRECTORY</action>
   1.816 +      </button>
   1.817 +    </hbox>
   1.818 +    <hbox>
   1.819 +      <button>
   1.820 +        <input file icon="forward"></input>
   1.821 +        <label>Create image set from ISO boot</label>
   1.822 +	<action>cd $FILE_DIRECTORY; bootfloppybox call mkisofloppiesxterm $ISO</action>
   1.823 +        <action type="closewindow">IMAGE_SET</action>
   1.824 +      </button>
   1.825 +    </hbox>
   1.826 +    </vbox>
   1.827 +    </frame>
   1.828 +    <frame Any Linux distribution (max total size 14-15MB)>
   1.829 +    <vbox>
   1.830 +    <text wrap="false" width-chars="44" use-markup="true">
   1.831 +      <label>
   1.832 +"
   1.833 +The total size of the kernel and the initramfs must be
   1.834 +lower than 14-15MB due to the tiny boot loader design.
   1.835 +"
   1.836 +      </label>
   1.837 +    </text>
   1.838 +    <hbox>
   1.839 +      <text use-markup="true">
   1.840 +        <label>"<b>Kernel      : </b>"</label>
   1.841 +      </text>
   1.842 +      <entry accept="filename">
   1.843 +        <label>Select a linux kernel</label>
   1.844 +        <variable>KERNEL</variable>
   1.845 +      </entry>
   1.846 +      <button>
   1.847 +        <input file stock="gtk-open"></input>
   1.848 +        <action type="fileselect">KERNEL</action>
   1.849 +      </button>
   1.850 +    </hbox>
   1.851 +    <hbox>
   1.852 +      <text use-markup="true">
   1.853 +        <label>"<b>Initramfs : </b>"</label>
   1.854 +      </text>
   1.855 +      <entry accept="filename">
   1.856 +        <label>Select an initramfs/initrd file</label>
   1.857 +        <variable>INITRD</variable>
   1.858 +      </entry>
   1.859 +      <button>
   1.860 +        <input file stock="gtk-open"></input>
   1.861 +        <action type="fileselect">INITRD</action>
   1.862 +      </button>
   1.863 +    </hbox>
   1.864 +    <hbox>
   1.865 +      <text use-markup="true">
   1.866 +        <label>"<b>Cmdline   : </b>"</label>
   1.867 +      </text>
   1.868 +      <entry>
   1.869 +        <label>Enter kernel arguments</label>
   1.870 +        <variable>CMDLINE</variable>
   1.871 +        <default>rw root=/dev/null autologin</default>
   1.872 +      </entry>
   1.873 +    </hbox>
   1.874 +    <hbox>
   1.875 +      <text use-markup="true">
   1.876 +        <label>"<b>Output directory : </b>"</label>
   1.877 +      </text>
   1.878 +      <entry accept="directory">
   1.879 +        <label>Select output directory</label>
   1.880 +        <variable>OUTPUT_DIRECTORY</variable>
   1.881 +        <default>/tmp</default>
   1.882 +      </entry>
   1.883 +      <button>
   1.884 +        <input file stock="gtk-open"></input>
   1.885 +        <action type="fileselect">OUTPUT_DIRECTORY</action>
   1.886 +      </button>
   1.887 +    </hbox>
   1.888 +    <hbox>
   1.889 +      <button>
   1.890 +        <input file icon="forward"></input>
   1.891 +        <label>Create image set</label>
   1.892 +	<action>cd $OUTPUT_DIRECTORY; bootfloppybox call mkfloppies "$KERNEL" "$INITRD" "$CMDLINE"</action>
   1.893 +        <action type="closewindow">IMAGE_SET</action>
   1.894 +      </button>
   1.895 +    </hbox>
   1.896 +    </vbox>
   1.897 +    </frame>
   1.898 +    </notebook>
   1.899 +    <hbox>
   1.900 +      <button>
   1.901 +        <input file icon="gtk-close"></input>
   1.902 +        <action type="closewindow">IMAGE_SET</action>
   1.903 +      </button>
   1.904 +    </hbox>
   1.905 +  </vbox>
   1.906 +</window>
   1.907 +'
   1.908 +
   1.909 +#
   1.910 +# Read/write floppy images
   1.911 +#
   1.912 +export FLOPPY_IMAGE='
   1.913 +<window title="Floppy image manager" icon-name="gtk-floppy">
   1.914 +  <vbox>
   1.915 +    <frame Floppy disk drive>
   1.916 +      <hbox>
   1.917 +        <text use-markup="true">
   1.918 +          <label>"<b>Device : </b>"</label>
   1.919 +        </text>
   1.920 +	<combobox>
   1.921 +          <variable>DEVICE</variable>'
   1.922 +FLOPPY_DEV=""
   1.923 +for i in $(list_floppy); do
   1.924 +	FLOPPY_DEV="$FLOPPY_DEV
   1.925 +	  <item>/dev/$i</item>"
   1.926 +done
   1.927 +	FLOPPY_IMAGE="$FLOPPY_IMAGE$FLOPPY_DEV
   1.928 +	</combobox>
   1.929 +        <button>
   1.930 +          <label>Format floppy</label>
   1.931 +          <input file icon=\"media-floppy\"></input>
   1.932 +	  <action>fdformat -n $DEVICE</action>
   1.933 +        </button>
   1.934 +      </hbox>
   1.935 +    </frame>
   1.936 +    <frame Floppy image file>
   1.937 +      <hbox>
   1.938 +        <text use-markup=\"true\">
   1.939 +          <label>\"<b>File : </b>\"</label>
   1.940 +        </text>
   1.941 +        <entry accept=\"filename\">
   1.942 +          <label>Select a floppy image</label>
   1.943 +          <variable>IMAGE</variable>
   1.944 +        </entry>
   1.945 +        <button>
   1.946 +          <input file stock=\"gtk-open\"></input>
   1.947 +          <action type=\"fileselect\">IMAGE</action>
   1.948 +        </button>
   1.949 +      </hbox>
   1.950 +    </frame>
   1.951 +    <hbox>
   1.952 +      <button>
   1.953 +        <input file icon=\"reload\"></input>
   1.954 +        <label>Create image set</label>
   1.955 +	<action type=\"launch\">IMAGE_SET</action>
   1.956 +      </button>
   1.957 +      <button>
   1.958 +        <input file icon=\"go-jump\"></input>
   1.959 +        <label>Write image to floppy</label>
   1.960 +        <action>dd if=\$IMAGE of=\$DEVICE</action>
   1.961 +      </button>
   1.962 +      <button>
   1.963 +        <input file icon=\"undo\"></input>
   1.964 +        <label>Get floppy image</label>
   1.965 +        <action>dd if=\$DEVICE of=\$IMAGE</action>
   1.966 +      </button>
   1.967 +      <button>
   1.968 +        <input file icon=\"gtk-close\"></input>
   1.969 +        <action type=\"closewindow\">FLOPPY_IMAGE</action>
   1.970 +      </button>
   1.971 +    </hbox>
   1.972 +  </vbox>
   1.973 +</window>
   1.974 +"
   1.975 +
   1.976 +gtkdialogshowfloppyset()
   1.977 +{
   1.978 +#
   1.979 +# Show floppy image set
   1.980 +#
   1.981 +IMAGE_SHOW='
   1.982 +<window title="Image set" icon-name="gtk-floppy">
   1.983 +  <vbox>
   1.984 +    <text use-markup="true">
   1.985 +      <label>
   1.986 +"
   1.987 +<b>Boot floppy images</b>
   1.988 +"
   1.989 +      </label>
   1.990 +    </text>
   1.991 +    <tree>
   1.992 +        <width>50</width><height>140</height>
   1.993 +    	<label>Size|File</label>
   1.994 +    	<input>du -h fd???.img | sed "s/\t/|/" </input>
   1.995 +    </tree>
   1.996 +    <hbox>
   1.997 +'
   1.998 +	[ 0$1 -gt $((15 * 1024 * 1024)) ] &&  IMAGE_SHOW="$IMAGE_SHOW
   1.999 +    <frame WARNING>
  1.1000 +    <text>
  1.1001 +      <label>
  1.1002 +\"This floppy set breaks the 15MB limit ($1 bytes).
  1.1003 +It may not be able to complete the boot process.\"
  1.1004 +      </label>
  1.1005 +    </text>
  1.1006 +    </frame>
  1.1007 +    </hbox>
  1.1008 +    <hbox>
  1.1009 +"
  1.1010 +	list_floppy check && IMAGE_SHOW="$IMAGE_SHOW
  1.1011 +      <button>
  1.1012 +        <input file icon=\"media-floppy\"></input>
  1.1013 +	<label>Manage images</label>
  1.1014 +	<action type=\"launch\">FLOPPY_IMAGE</action>
  1.1015 +      </button>
  1.1016 +"
  1.1017 +	IMAGE_SHOW="$IMAGE_SHOW
  1.1018 +      <button>
  1.1019 +        <input file icon=\"gtk-close\"></input>
  1.1020 +        <action type=\"closewindow\">IMAGE_SET</action>
  1.1021 +      </button>
  1.1022 +    </hbox>
  1.1023 +  </vbox>
  1.1024 +</window>
  1.1025 +"
  1.1026 +	export IMAGE_SHOW
  1.1027 +	gtkdialog --program=IMAGE_SHOW
  1.1028 +}
  1.1029 +
  1.1030 +while true; do
  1.1031 +
  1.1032 +if [ "$1" == "call" ]; then
  1.1033 +	case "$2" in
  1.1034 +	mkmenu) mkmenu $3;;
  1.1035 +	mkisofloppiesxterm)
  1.1036 +		shift 2
  1.1037 +		xterm -geometry 80x16 -title "Build boot floppies from ISO" \
  1.1038 +			-e "$0 call mkisofloppies $@ ; echo -e \"----\nENTER to continue...\" && read close"
  1.1039 +		gtkdialogshowfloppyset
  1.1040 +		;;
  1.1041 +	mkisofloppies)
  1.1042 +		shift 2
  1.1043 +		floppysetfromiso $@
  1.1044 +		;;
  1.1045 +	mkfloppies)
  1.1046 +		shift 2
  1.1047 +		floppyset "$@"
  1.1048 +		sz=$(cat fd???.img | wc -c)
  1.1049 +		if [ -n "$XAUTHORITY" ]; then
  1.1050 +			gtkdialogshowfloppyset $sz
  1.1051 +		else
  1.1052 +			if [ $sz -gt $((15 * 1024 * 1024)) ]; then
  1.1053 +				cat <<EOT
  1.1054 +This floppy set breaks the 15MB limit ($sz bytes).
  1.1055 +It may not be able to complete the boot process.
  1.1056 +EOT
  1.1057 +			fi
  1.1058 +		fi
  1.1059 +		;;
  1.1060 +	install)
  1.1061 +		DIR=/tmp/mkbootfloppy$$
  1.1062 +		mkdir -p $DIR
  1.1063 +		DEVICE=$4
  1.1064 +		file=$5
  1.1065 +		case "$3" in
  1.1066 +		dialog*)
  1.1067 +			shift 2
  1.1068 +			$@
  1.1069 +			;;
  1.1070 +		grub*)
  1.1071 +			mkdir -p $DIR/boot/grub
  1.1072 +			[ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ] \
  1.1073 +				&& cat /usr/share/boot/btmgr /dev/zero | \
  1.1074 +				   dd bs=18k count=80 | gzip -9 > \
  1.1075 +				   $DIR/boot/btmgr.gz \
  1.1076 +				&& unlzma -c /usr/share/boot/memdisk.lzma > \
  1.1077 +					$DIR/boot/memdisk
  1.1078 +			[ -f /usr/share/boot/plpbt.bin ] \
  1.1079 +			  	&& cp /usr/share/boot/plpbt.bin $DIR/boot
  1.1080 +			[ -f /usr/share/boot/etherboot ] \
  1.1081 +				&& cp /usr/share/boot/etherboot $DIR/boot
  1.1082 +			[ -f /boot/gpxe ]\
  1.1083 +				&& cp /boot/gpxe $DIR/boot
  1.1084 +			[ -f /usr/share/boot/memtest.lzma -a \
  1.1085 +			  -f /usr/share/boot/memdisk.lzma ] \
  1.1086 +				&& unlzma -c /usr/share/boot/memtest.lzma | \
  1.1087 +				   cat - /dev/zero | dd bs=18k count=80 | \
  1.1088 +				   gzip -9 > $DIR/boot/memtest.gz \
  1.1089 +				&& unlzma -c /usr/share/boot/memdisk.lzma > \
  1.1090 +					$DIR/boot/memdisk
  1.1091 +			install_grub $DIR $3
  1.1092 +			;;
  1.1093 +		*)
  1.1094 +    			case "$file" in
  1.1095 +    			*.lzma) action="unlzma -c";;
  1.1096 +    			*.gz)   action="zcat";;
  1.1097 +    			*)      action="cat";;
  1.1098 +    			esac
  1.1099 +			case "$DEVICE" in
  1.1100 +			/dev/*) $action $file > $DEVICE;;
  1.1101 +			flopp*) $action $file | cat - /dev/zero | \
  1.1102 +						dd bs=18k count=80 > boot.fd;;
  1.1103 +			cdrom*)
  1.1104 +				mkdir -p $DIR/boot/grub
  1.1105 +				case "$3" in
  1.1106 +				btmgr|memtest)
  1.1107 +					$action $file | cat - /dev/zero | \
  1.1108 +						dd bs=18k count=80 | \
  1.1109 +						gzip -9 > $DIR/boot/$3.gz
  1.1110 +					unlzma -c /usr/share/boot/memdisk.lzma \
  1.1111 +						> $DIR/boot/memdisk
  1.1112 +					cat > /tmp/floppybox.grub.menu << EOT
  1.1113 +# grub menu
  1.1114 +timeout 0
  1.1115 +title $3
  1.1116 +kernel /boot/memdisk floppy c=80 h=2 s=18
  1.1117 +initrd /boot/$3.gz
  1.1118 +EOT
  1.1119 +					;;
  1.1120 +				*)	$action $file > $DIR/boot/$3
  1.1121 +					cat > /tmp/floppybox.grub.menu << EOT
  1.1122 +# grub menu
  1.1123 +timeout 0
  1.1124 +title $3
  1.1125 +kernel /boot/$3
  1.1126 +EOT
  1.1127 +					;;
  1.1128 +				esac
  1.1129 +				install_grub $DIR grub
  1.1130 +				;;
  1.1131 +			esac
  1.1132 +			;;
  1.1133 +		esac
  1.1134 +		rm -rf $DIR
  1.1135 +		;;
  1.1136 +	get-plop)
  1.1137 +		mkdir -p /tmp/get-plop$$
  1.1138 +		PLOP_URL=http://mirror.slitaz.org/boot/plpbt.bin
  1.1139 +		wget -O - $PLOP_URL  > /tmp/get-plop$$/plpbt.bin
  1.1140 +		VERSION="$(strings /tmp/get-plop$$/plpbt.bin \
  1.1141 +		  | grep 'Boot Manager v' | sed 's/.* v\([0-9\.]*\) .*/\1/')"
  1.1142 +		mkdir -p $(dirname /tmp/get-plop$$/plop-$VERSION/fs/$3)
  1.1143 +		mv /tmp/get-plop$$/plpbt.bin \
  1.1144 +		   /tmp/get-plop$$/plop-$VERSION/fs/$3
  1.1145 +		if [ -s /tmp/get-plop$$/plop-$VERSION/fs/$3 ]; then 
  1.1146 +			cat > /tmp/get-plop$$/plop-$VERSION/receipt <<EOT
  1.1147 +PACKAGE="plop"
  1.1148 +VERSION="$VERSION"
  1.1149 +CATEGORY="non-free"
  1.1150 +SHORT_DESC="Plop boot manager."
  1.1151 +WEB_SITE="http://www.plop.at/en/bootmanager.html"
  1.1152 +EOT
  1.1153 +			( cd /tmp/get-plop$$ ; tazpkg pack plop-$VERSION )
  1.1154 +			tazpkg install /tmp/get-plop$$/plop-$VERSION.tazpkg
  1.1155 +		fi
  1.1156 +		rm -rf /tmp/get-plop$$
  1.1157 +		;;
  1.1158 +	*)	echo "Invalid command $0 $@" 1>&2
  1.1159 +		exit 1;;
  1.1160 +	esac
  1.1161 +	exit 0
  1.1162 +fi
  1.1163 +
  1.1164 +if [ -z "$XAUTHORITY" ]; then
  1.1165 +
  1.1166 +    : ${DIALOG=dialog}
  1.1167 +    
  1.1168 +    DEVICE=/dev/fd0
  1.1169 +    list_floppy check || DEVICE="floppy"
  1.1170 +    while true; do
  1.1171 +	exec 3>&1
  1.1172 +	ID_SOURCE=`$DIALOG --title " Choose a boot floppy " \
  1.1173 +		--backtitle "Boot Floppy Creation on $DEVICE" --clear \
  1.1174 +		--extra-button --extra-label "Change floppy" \
  1.1175 +		--colors --radiolist "
  1.1176 +Create a floppy or a cdrom to boot a LiveCD in a PXE network...
  1.1177 +May need a floppy disk in drive. Erase the whole floppy disk.
  1.1178 +		" 18 70 50\
  1.1179 +		FloppySet	"Boot Slitaz with floppies only." on \
  1.1180 +		SmartBtmgr	"Boot any partition or ATAPI CD-ROM." off \
  1.1181 +		Plop		"Boot USB harddisk floppy or CD/DVD." off \
  1.1182 +		Etherboot	"Replacement for proprietary PXE ROMs." off \
  1.1183 +		gPXE		"Boot from http://boot.slitaz.org/" off \
  1.1184 +		Memtest86+	"Memory failures detection tool." off \
  1.1185 +		Grub4DOS	"Enhanced grub version supporting NTFS." off \
  1.1186 +		Grub		"Boot loader with command shell." off \
  1.1187 +		2>&1 1>&3`
  1.1188 +	retval=$?
  1.1189 +	exec 3>&-
  1.1190 +	check_retval
  1.1191 +	if [ "$retval" = "3" ]; then
  1.1192 +		select_floppy
  1.1193 +		continue;
  1.1194 +	fi
  1.1195 +	while read key file pkg; do
  1.1196 +		[ "$key" = "$ID_SOURCE" ] || continue
  1.1197 +		if [ ! -f "$file" ]; then
  1.1198 +			$DIALOG --title " Install package " --colors \
  1.1199 +				--backtitle "Boot Floppy Creation" --clear \
  1.1200 +				--yes-label "Install" \
  1.1201 +				--no-label "Quit" \
  1.1202 +				--yesno "The package $pkg is not yet installed. Install it ?" 18 70
  1.1203 +			retval=$?
  1.1204 +			if [ "$pkg" = "plop" ]; then
  1.1205 +				bootfloppybox call get-plop $file
  1.1206 +			else
  1.1207 +				tazpkg get-install $pkg
  1.1208 +			fi
  1.1209 +		fi
  1.1210 +		bootfloppybox call install "$pkg" "$DEVICE" "$file"
  1.1211 +		exit 0
  1.1212 +	done <<EOT
  1.1213 +FloppySet /bin/dd dialogfloppyset
  1.1214 +SmartBtmgr /usr/share/boot/btmgr btmgr
  1.1215 +Plop /usr/share/boot/plpbt.bin plop
  1.1216 +Etherboot /usr/share/boot/etherboot etherboot
  1.1217 +gPXE /boot/gpxe gpxe
  1.1218 +Memtest86+ /usr/share/boot/memtest.lzma memtest
  1.1219 +Grub4DOS /usr/share/boot/grldr.lzma grub4dos
  1.1220 +Grub /usr/sbin/grub grub
  1.1221 +EOT
  1.1222 +    done
  1.1223 +fi
  1.1224 +#
  1.1225 +# Describe gPXE arguments.
  1.1226 +#
  1.1227 +export HELP='
  1.1228 +<window title="gPXE forced url" icon-name="gtk-floppy">
  1.1229 +<vbox>
  1.1230 +  <text use-markup="true">
  1.1231 +    <label>"
  1.1232 +<b>Web boot parameters</b>"
  1.1233 +    </label>
  1.1234 +  </text>
  1.1235 +  <frame>
  1.1236 +    <text wrap="true" width-chars="58" use-markup="true">
  1.1237 +      <label>
  1.1238 +"Without parameters (i.e. with an empty Boot URL) gPXE will perform a normal PXE boot: IP configuration with DHCP and download the DHCP bootfile with TFTP.
  1.1239 +
  1.1240 +You can override the DHCP bootfile with a Boot URL such as <i>tftp://192.168.0.1/pxe/pxeloader</i>, <i>http://mirror.slitaz.org/pxe/pxelinux.0</i>, or <i>x-tftm://192.168.0.201//lts/vmlinuz.ltsp</i>.
  1.1241 +
  1.1242 +You can override the IP configuration too (useful without a DHCP server), example: <i>ip=192.168.0.10/24 gw=192.168.0.1 dns=192.168.0.1 nodhcp url=http://mirror.slitaz.org/pxe/pxelinux.0</i>
  1.1243 +
  1.1244 +The <i>nodhcp</i> keyword avoids dhcp timeouts and the <i>url=</i> keyword is optional when the url is the only one argument.
  1.1245 +
  1.1246 +Comma separated URL lists are supported. The PXE client will try to load the first URL. If the load fails, it will try the next URL, and so on. 
  1.1247 +"
  1.1248 +      </label>
  1.1249 +    </text>
  1.1250 +  </frame>
  1.1251 +</vbox>
  1.1252 +</window>
  1.1253 +'
  1.1254 +#
  1.1255 +# Write bootfloppy image to floppy device.
  1.1256 +#
  1.1257 +BOOT_DIALOG='
  1.1258 +<window title="bootfloppybox" icon-name="gtk-floppy">
  1.1259 +  <vbox>
  1.1260 + 
  1.1261 +    <text use-markup="true">
  1.1262 +      <label>
  1.1263 +"
  1.1264 +<b>SliTaz - Bootfloppybox</b>"
  1.1265 +      </label>
  1.1266 +    </text>
  1.1267 +    <text wrap="false" width-chars="44" use-markup="true">
  1.1268 +      <label>
  1.1269 +"
  1.1270 +Create a floppy or a cdrom to boot a LiveCD in a PXE network or the WEB...
  1.1271 +May need a floppy disk in drive. Erase the whole floppy disk.
  1.1272 +"
  1.1273 +      </label>
  1.1274 +    </text>
  1.1275 +  
  1.1276 +    <frame Floppy disk drive>
  1.1277 +      <hbox>
  1.1278 +        <text use-markup="true">
  1.1279 +          <label>"<b>Device : </b>"</label>
  1.1280 +        </text>
  1.1281 +	<combobox>
  1.1282 +          <variable>DEVICE</variable>'
  1.1283 +FLOPPY_DEV=""
  1.1284 +for i in $(list_floppy); do
  1.1285 +	FLOPPY_DEV="$FLOPPY_DEV
  1.1286 +	  <item>/dev/$i</item>"
  1.1287 +done
  1.1288 +	BOOT_DIALOG="$BOOT_DIALOG$FLOPPY_DEV
  1.1289 +	  <item>floppy image (boot.fd)</item>
  1.1290 +	  <item>cdrom image (boot.iso)</item>
  1.1291 +	</combobox>"
  1.1292 +if [ -n "$FLOPPY_DEV" ]; then
  1.1293 +	tmp='
  1.1294 +        <button>
  1.1295 +          <label>Format floppy</label>
  1.1296 +          <input file icon="media-floppy"></input>
  1.1297 +	  <action>case "$DEVICE" in /dev/*) fdformat -n $DEVICE;; esac</action>
  1.1298 +        </button>'
  1.1299 +	BOOT_DIALOG="$BOOT_DIALOG$tmp"
  1.1300 +fi
  1.1301 +tmp='
  1.1302 +      </hbox>
  1.1303 +    </frame>
  1.1304 +    <notebook labels="Set|LiveCD|USB|PXE Network|WEB Network|Memory Test|Windows|Expert">
  1.1305 +    <frame Boot floppy set (many floppies)>
  1.1306 +      <vbox>
  1.1307 +      <hbox>
  1.1308 +        <text wrap="true" width-chars="58" use-markup="true">
  1.1309 +          <label>
  1.1310 +"
  1.1311 +Only people without a CD-ROM, USB and Network should use a floppy set. 
  1.1312 +The images are built from an ISO boot or from a Linux kernel, an initramfs
  1.1313 +and a boot command line. Non Slitaz boot floppy sets are limited to 15MB.
  1.1314 +"
  1.1315 +          </label>
  1.1316 +        </text>
  1.1317 +      </hbox>
  1.1318 +      <hbox>
  1.1319 +      <button>
  1.1320 +        <label>Create image set</label>
  1.1321 +        <input file icon="forward"></input>
  1.1322 +	<action type="launch">IMAGE_SET</action>
  1.1323 +      </button>
  1.1324 +      </hbox>
  1.1325 +      </vbox>
  1.1326 +    </frame>
  1.1327 +'  
  1.1328 +BOOT_DIALOG="$BOOT_DIALOG$tmp"
  1.1329 +while read name file pkg desc; do
  1.1330 +    tmp="<frame $name (single floppy)>
  1.1331 +      <hbox>
  1.1332 +    <text wrap=\"true\" width-chars=\"58\" use-markup=\"true\">
  1.1333 +      <label>
  1.1334 +\"
  1.1335 +$(echo -e $desc)
  1.1336 +\"
  1.1337 +      </label>
  1.1338 +    </text>
  1.1339 +      </hbox>
  1.1340 +      <hbox>
  1.1341 +"
  1.1342 +  if [ -f $file ]; then
  1.1343 +    if [ "$pkg" = "grub" -o "$pkg" = "grub4dos" ]; then
  1.1344 +      tmp="$tmp
  1.1345 +      <button>
  1.1346 +        <label>Grub menu</label>
  1.1347 +        <input file icon=\"accessories-text-editor\"></input>
  1.1348 +	<action>bootfloppybox call mkmenu $pkg</action>
  1.1349 +        <action type=\"lauch\">leafpad /tmp/floppybox.grub.menu</action>
  1.1350 +      </button>
  1.1351 +"
  1.1352 +    elif [ "$pkg" = "etherboot" ]; then
  1.1353 +      tmp="$tmp
  1.1354 +      <button>
  1.1355 +        <input file icon=\"browser\"></input>
  1.1356 +	<label>Wiki</label>
  1.1357 +	<action>browser http://doc.slitaz.org/en:guides:pxe &</action>
  1.1358 +      </button>
  1.1359 +"
  1.1360 +    elif [ "$pkg" = "gpxe" ]; then
  1.1361 +      tmp="$tmp
  1.1362 +      <text wrap=\"true\" use-markup=\"true\">
  1.1363 +        <label> \"<b>Boot URL:</b>\" </label>
  1.1364 +      </text>
  1.1365 +      <entry>
  1.1366 +	<default>$(dd if=$file bs=1 skip=519 count=255 2>/dev/null | strings)</default>
  1.1367 +        <variable>URL</variable>
  1.1368 +      </entry>
  1.1369 +      </hbox>
  1.1370 +      <hbox>
  1.1371 +      <button>
  1.1372 +        <input file icon=\"browser\"></input>
  1.1373 +	<label>Wiki</label>
  1.1374 +	<action>browser http://doc.slitaz.org/en:guides:pxe &</action>
  1.1375 +      </button>
  1.1376 +      <button help>
  1.1377 +	<action type=\"launch\">HELP</action>
  1.1378 +      </button>
  1.1379 +      <button>
  1.1380 +        <label>Update</label>
  1.1381 +        <input file icon=\"reload\"></input>
  1.1382 +	<action>echo -n \"\$URL\" | cat - /dev/zero | dd conv=notrunc bs=1 count=255 seek=519 of=$file 2>/dev/null</action>
  1.1383 +      </button>
  1.1384 +"
  1.1385 +    fi
  1.1386 +    receipt=/var/lib/tazpkg/installed/$pkg/receipt
  1.1387 +    if [ -f $receipt ]; then
  1.1388 +      . $receipt
  1.1389 +      tmp="$tmp
  1.1390 +      <button>
  1.1391 +        <input file icon=\"browser\"></input>
  1.1392 +	<label>Web</label>
  1.1393 +	<action>browser $WEB_SITE &</action>
  1.1394 +      </button>
  1.1395 +"
  1.1396 +    fi
  1.1397 +    tmp="$tmp
  1.1398 +      <button>
  1.1399 +        <label>Write floppy</label>
  1.1400 +        <input file icon=\"forward\"></input>
  1.1401 +	<action>bootfloppybox call install \"$pkg\" \"\$DEVICE\" \"$file\"</action>
  1.1402 +      </button>
  1.1403 +      </hbox>
  1.1404 +    </frame>
  1.1405 +"
  1.1406 +  else
  1.1407 +    tmp2="tazpkg get-install $pkg --forced"
  1.1408 +    [ "$pkg" = "plop" ] && tmp2="bootfloppybox call get-plop $file"
  1.1409 +    tmp="$tmp
  1.1410 +      <text wrap=\"true\" width-chars=\"34\" use-markup=\"true\">
  1.1411 +        <label>
  1.1412 +\"<i>The package <b>$pkg</b> is not yet installed</i>\"
  1.1413 +        </label>
  1.1414 +      </text>
  1.1415 +      <button>
  1.1416 +        <input file icon=\"go-jump\"></input>
  1.1417 +	<label>Install</label>
  1.1418 +	<action>[ -f /var/lib/tazpkg/packages.list ] || tazpkg recharge</action>
  1.1419 +	<action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title \"$pkg install\" -e \"$tmp2 ; sleep 2\"</action>
  1.1420 +        <action type=\"exit\">restart</action>
  1.1421 +      </button>
  1.1422 +      </hbox>
  1.1423 +    </frame>
  1.1424 +"
  1.1425 +  fi
  1.1426 +  BOOT_DIALOG="$BOOT_DIALOG$tmp"
  1.1427 +done <<EOT
  1.1428 +SmartBtmgr /usr/share/boot/btmgr btmgr This OS independent Smart Boot Manager can boot \\\\nany partition or ATAPI CD-ROM.
  1.1429 +Plop /usr/share/boot/plpbt.bin plop This non free Boot Manager can boot a floppy disk, hardisk, USB or \\\\nCD/DVD. Hit Ctrl-ESC for text mode.
  1.1430 +Etherboot /usr/share/boot/etherboot etherboot This network bootloader provides a replacement \\\\nfor proprietary PXE or NBI ROMs.
  1.1431 +gPXE /boot/gpxe gpxe PXE / iSCSI / AoE network bootloader.
  1.1432 +Memtest86+ /usr/share/boot/memtest.lzma memtest Memory failures detection tool.
  1.1433 +Grub4DOS /usr/share/boot/grldr.lzma grub4dos Enhanced grub version supporting NTFS.
  1.1434 +Grub /usr/sbin/grub grub General purpose boot loader with command shell.
  1.1435 +EOT
  1.1436 +tmp='
  1.1437 +    </notebook>
  1.1438 +    <hbox>
  1.1439 +'
  1.1440 +BOOT_DIALOG="$BOOT_DIALOG$tmp"
  1.1441 +if [ -e /dev/cdrom ]; then
  1.1442 +tmp='
  1.1443 +      <button>
  1.1444 +        <input file icon="media-cdrom"></input>
  1.1445 +	<label>Burn cdrom image</label>
  1.1446 +	<action>burnbox</action>
  1.1447 +      </button>
  1.1448 +'
  1.1449 +BOOT_DIALOG="$BOOT_DIALOG$tmp"
  1.1450 +fi
  1.1451 +if list_floppy check; then
  1.1452 +tmp='
  1.1453 +      <button>
  1.1454 +        <input file icon="media-floppy"></input>
  1.1455 +	<label>Manage floppy image</label>
  1.1456 +	<action type="launch">FLOPPY_IMAGE</action>
  1.1457 +      </button>
  1.1458 +'
  1.1459 +BOOT_DIALOG="$BOOT_DIALOG$tmp"
  1.1460 +fi
  1.1461 +tmp='
  1.1462 +      <button>
  1.1463 +        <input file icon="exit"></input>
  1.1464 +	<label>Exit</label>
  1.1465 +        <action type="exit">Exit</action>
  1.1466 +      </button>
  1.1467 +    </hbox>
  1.1468 +  
  1.1469 +  </vbox>
  1.1470 +</window>
  1.1471 +'
  1.1472 +BOOT_DIALOG="$BOOT_DIALOG$tmp"
  1.1473 +export BOOT_DIALOG
  1.1474 +
  1.1475 +# Only root can create floppy.
  1.1476 +check_root
  1.1477 +gtkdialog --program=BOOT_DIALOG | grep -q 'EXIT="restart"' && continue
  1.1478 +rm -f /tmp/floppybox.grub.menu
  1.1479 +exit 0
  1.1480 +done