slitaz-tools view tinyutils/bootfloppybox @ rev 513

tazx: now backup old xorg config (Thanks Frederic Guilbault)
author Antoine Bodin <gokhlayeh@slitaz.org>
date Sun Oct 31 00:28:18 2010 +0200 (2010-10-31)
parents ca6804d9b56b
children 0f5e3af5a51d
line source
1 #! /bin/sh
2 #
3 # Gtkdialog box for the mount command. Part of SliTaz tools.
4 #
5 VERSION=20100701
7 # Check if user is root.
8 check_root()
9 {
10 if test $(id -u) != 0 ; then
11 echo -e "
12 You must be root to run `basename $0`. Please type 'su' and
13 root password to become super-user.\n"
14 exit 0
15 fi
16 }
18 # This function is used after each screen to continue or abort install.
19 check_retval()
20 {
21 case $retval in
22 1)
23 rm -f /tmp/floppybox.grub.menu
24 echo -e "\nVoluntary exit.\n" && exit 0 ;;
25 255)
26 rm -f /tmp/floppybox.grub.menu
27 echo -e "ESC pressed.\n" && exit 0 ;;
28 esac
29 }
31 # Trigger floppy driver to update /sys/devices/platform/
32 dd if=/dev/fd0 bs=1k count=1 > /dev/null 2>&1
34 # check or list floppy devices.
35 list_floppy()
36 {
37 local list
38 list=""
39 for i in /sys/devices/platform/floppy.*/block/*; do
40 [ -d $i ] || continue
41 list="$list $(basename $i)"
42 done
43 [ -n "$1" ] || echo $list
44 [ -n "$list" ]
45 }
47 # dialog to select the floppy device
48 select_floppy()
49 {
50 DEVICE="$DIALOG --title \" Floppy device \" --backtitle \"Boot Floppy Creation\" --clear --extra-button --extra-label \"Format\" --colors --radiolist \"
51 Select boot device
52 \" 18 70 50"
53 on=on
54 for i in $(list_floppy); do
55 DEVICE="$DEVICE /dev/$i 'Floppy in $i' $on"
56 on=off
57 done
58 DEVICE="$DEVICE floppy \"floppy image file boot.fd\" $on"
59 DEVICE="$DEVICE cdrom \"cdrom image file boot.iso\" off 2>&1 1>&3"
60 exec 3>&1
61 DEVICE=`eval $DEVICE`
62 retval=$?
63 exec 3>&-
64 check_retval
65 if [ "$retval" = "3" ]; then
66 case "$DEVICE" in
67 /dev/*) fdformat -n $DEVICE;;
68 esac
69 fi
70 }
72 # Build menu for grub or grub4dos
73 mkmenu()
74 {
75 if [ "$1" = "grub4dos" ]; then
76 SAVEDEFAULT="save default"
77 cat > /tmp/floppybox.grub.menu <<EOT
78 # grub4dos menu
79 default /default
80 EOT
81 else
82 SAVEDEFAULT="savedefault"
83 cat > /tmp/floppybox.grub.menu <<EOT
84 # grub menu
85 default saved
86 EOT
87 fi
88 cat >> /tmp/floppybox.grub.menu <<EOT
89 timeout 8
90 color yellow/brown light-green/black
92 EOT
93 entry=0
94 [ -f /boot/gpxe ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
95 title gPXE (Boot from the Web, PXE/iSCSI/AoE support)
96 kernel /boot/gpxe $(dd if=/boot/gpxe bs=1 skip=519 count=255 2>/dev/null | strings)
98 EOT
99 [ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ] \
100 && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
101 title Smart Boot Manager (text - boot floppy, hard disk or CD/DVD)
102 kernel /boot/memdisk floppy c=80 h=2 s=18
103 initrd /boot/btmgr.gz
105 EOT
106 http://mirror.slitaz.org/boot/plpbt.bin
107 [ -f /usr/share/boot/plpbt.bin ] \
108 && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
109 title Plop Boot Manager (graphic - boot floppy, hard disk, CD/DVD or USB)
110 kernel /boot/plpbt.bin
112 EOT
113 [ -f /usr/share/boot/etherboot ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
114 title Etherboot (LAN boot, PXE or NBI)
115 kernel /boot/etherboot
117 EOT
118 [ -f /usr/share/boot/memtest.lzma -a -f /usr/share/boot/memdisk.lzma ] \
119 && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
120 title Memtest86+ (Test system memory)
121 kernel /boot/memdisk floppy c=80 h=2 s=18
122 initrd /boot/memtest.gz
124 EOT
125 [ "$1" = "grub4dos" ] && entry=$(($entry + 3)) && cat >> /tmp/floppybox.grub.menu <<EOT
126 title Windows (scan ntldr)
127 fallback $(($entry -3 + 1))
128 find --set-root /ntldr
129 chainloader /ntldr
130 $SAVEDEFAULT --wait=2
132 title Windows (scan cmldr)
133 fallback $(($entry -3 + 2))
134 find --set-root /cmldr
135 chainloader /cmldr
136 $SAVEDEFAULT --wait=2
138 title Windows (scan io.sys)
139 fallback $(($entry -3 + 3))
140 find --set-root /io.sys
141 chainloader /io.sys
142 $SAVEDEFAULT --wait=2
144 EOT
145 entry=$(($entry + 3)) && cat >> /tmp/floppybox.grub.menu <<EOT
146 title Windows (example on /dev/hda1)
147 rootnoverify (hd0,0)
148 chainloader +1
149 $SAVEDEFAULT
151 title Slitaz Frugal (example on /dev/hda1)
152 root (hd0,0)
153 kernel /boot/bzImage rw root=/dev/null vga=normal
154 initrd /boot/rootfs.gz
155 $SAVEDEFAULT
157 title Slitaz Installed (example on /dev/hda2)
158 root (hd0,1)
159 kernel /boot/bzImage ro root=/dev/hda2 vga=normal
160 $SAVEDEFAULT
162 EOT
163 [ "$1" = "grub4dos" ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
164 title Slitaz cdrom image (example on /dev/hda1, DEFRAGMENTED)
165 map (hd0,0)/boot/slitaz-cooking.iso (hd1)
166 map --hook
167 kernel (hd1)/boot/bzImage rw root=/dev/null vga=normal
168 initrd (hd1)/boot/rootfs.gz
169 $SAVEDEFAULT
171 EOT
172 false && [ -f /usr/share/boot/grub.exe.lzma ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
173 title Grub4Dos
174 kernel /boot/grub/grub.exe --config-file="configfile (fd0)/boot/grub/menu4dos.lst"
176 EOT
177 }
179 # Install grub or grub4dos on floppy
180 install_grub()
181 {
182 LOOP=""
183 GRUB_DEV=${DEVICE#/dev/}
184 GRUB_DEV=${GRUB_DEV%% *}
185 case "$DEVICE" in
186 floppy*)
187 LOOP="-o loop"
188 GRUB_DEV=fd0
189 DEVICE=boot.fd
190 dd if=/dev/zero of=$DEVICE bs=18k count=80;;
191 esac
192 grep -qs "^# $2 menu" /tmp/floppybox.grub.menu || mkmenu $2
193 case "$DEVICE" in
194 /dev/*|boot.fd)
195 yes y | mke2fs $DEVICE
196 mkdir /media/floppy
197 mount $LOOP $DEVICE /media/floppy
198 if [ "$2" = "grub4dos" ]; then
199 mkdir -p /media/floppy/boot
200 unlzma -c /usr/share/boot/grldr.lzma > /media/floppy/grldr
201 cp $1/boot/* /media/floppy/boot 2> /dev/null
202 cp /tmp/floppybox.grub.menu /media/floppy/menu.lst
203 umount -d /media/floppy
204 bootlace --floppy --sectors-per-track=18 --heads=2 \
205 --chs --ext2 $DEVICE
206 else
207 mkdir -p /media/floppy/boot/grub
208 cp /usr/lib/grub/i386-pc/stage? /media/floppy/boot/grub
209 cp -a $1/boot /media/floppy
210 cp /tmp/floppybox.grub.menu /media/floppy/boot/grub/menu.lst
211 grub-set-default --root-directory=/media/floppy 0
212 echo "($GRUB_DEV) $(losetup | grep $DEVICE | cut -d: -f1)" > $1/device.map
213 [ -n "$LOOP" ] && LOOP="--device-map=$1/device.map"
214 grub $LOOP --batch <<EOT
215 root ($GRUB_DEV)
216 setup ($GRUB_DEV)
217 quit
218 EOT
219 umount -d /media/floppy
220 fi ;;
221 cdrom*)
222 mkdir -p $1/boot/grub 2> /dev/null
223 cp /tmp/floppybox.grub.menu $1/boot/grub/menu.lst
224 if [ "$2" = "grub4dos" ]; then
225 unlzma -c /usr/share/boot/grldr.lzma > $1/boot/grub/grldr
226 genisoimage -R -o boot.iso -b boot/grub/grldr \
227 -c boot/boot.cat -no-emul-boot -boot-load-seg 0x1000 \
228 -hide boot/boot.cat -input-charset iso8859-1 $1
229 else
230 cp /usr/lib/grub/i386-pc/stage2_eltorito $1/boot/grub
231 genisoimage -R -o boot.iso -b boot/grub/stage2_eltorito \
232 -c boot/boot.cat -no-emul-boot -boot-load-size 4 \
233 -hide boot/boot.cat -input-charset iso8859-1 \
234 -boot-info-table $1
235 fi ;;
236 esac
237 }
239 # Build /init for floppies from iso image
240 buildinit()
241 {
242 mv $1/init $1/init.org
243 cat > $1/init <<EOTEOT
244 #!/bin/sh
246 mount -t proc proc /proc
247 total=\$(grep MemTotal /proc/meminfo | sed 's/[^0-9]//g')
248 # the floppy driver may not be included in kernel
249 insmod /lib/modules/*/kernel/drivers/block/floppy.ko.gz 2> /dev/null
250 # loram may put floppy.ko.gz module in /lib
251 insmod /lib/floppy.ko.gz 2> /dev/null
252 umount /proc
253 while read name min num count file md5; do
254 [ -e \$file ] && continue
255 [ \$total -lt \$min ] && break
256 while [ \$count -ne 0 ]; do
257 tmp="\$(dd if=/dev/fd0 count=1 2> /dev/null | md5sum)"
258 echo -n "Insert floppy \$num for \$name and press Enter or Q to skip"
259 while true; do
260 echo -n ":"
261 read -t 10 answer < /dev/tty0
262 case "\$answer" in
263 Q*|q*|A*|a*) break 3;;
264 esac
265 dd if=/dev/fd0 count=1 > /tmp/bs.\$\$ 2> /dev/null
266 [ -s /tmp/bs.\$\$ ] || continue
267 [ "\$(md5sum < /tmp/bs.\$\$)" != "\$tmp" ] || continue
268 rm -f /tmp/bs.\$\$
269 break
270 done
271 dd if=/dev/fd0 of=/tmp/rootfs.\$num 2> /dev/null || continue
272 cat /tmp/rootfs.\$num >> /tmp/rootfs
273 rm -f /tmp/rootfs.\$num
274 num=\$((\$num+1))
275 count=\$((\$count-1))
276 done
277 echo "\$md5 /tmp/rootfs" | md5sum -c || break
278 cpio -idmu < /tmp/rootfs > /dev/null 2>&1 ||
279 ( zcat /tmp/rootfs 2> /dev/null || unlzma -c /tmp/rootfs ) | cpio -idmu
280 rm -f /tmp/rootfs*
281 done <<EOT
282 $(while read line; do echo $line; done)
283 EOT
284 mv -f /init.org /init || sh
285 exec /init
286 EOTEOT
287 chmod +x $1/init
288 }
290 # write a 32 bits data
291 # usage: storelong offset data32 file
292 storelong()
293 {
294 printf "00000 %02X %02X %02X %02X \n" \
295 $(( $2 & 255 )) $(( ($2>>8) & 255 )) \
296 $(( ($2>>16) & 255 )) $(( ($2>>24) & 255 )) | \
297 hexdump -R | dd bs=1 conv=notrunc of=$3 seek=$(( $1 )) 2> /dev/null
298 }
300 # read a 32 bits data
301 # usage: getlong offset file
302 getlong()
303 {
304 dd if=$2 bs=1 skip=$(( $1 )) count=4 2> /dev/null | \
305 hexdump -e '"" 1/4 "%d" "\n"'
306 }
308 # output floppy images set
309 floppysetcat()
310 {
311 KERNEL="$1"
312 INITRD="$2"
313 shift 2
314 CMDLINE="$@"
316 # bzImage offsets
317 SetupSzOfs=497
318 SyssizeOfs=500
319 CodeAdrOfs=0x214
320 RamfsAdrOfs=0x218
321 RamfsLenOfs=0x21C
322 ArgPtrOfs=0x228
324 # boot+setup address
325 SetupBase=0x90000
327 stacktop=0x9E00
329 bs=/tmp/bs$$
331 # Get and patch boot sector
332 dd if=$KERNEL bs=512 count=1 of=$bs 2> /dev/null
333 uudecode <<EOT | dd of=$bs conv=notrunc 2> /dev/null
334 begin-base64 644 -
335 /L+6nWgAkAcGF4n8McC5HQDzq1sfD6mg8X1ABlfFd3ixBvOlZWaPR3gGH8ZF
336 +D/6l1hB6DQBvgACA3QO6HYBWwseKAJ0LFNH6AoBXuhmAbAgzRCwCM0QTuhl
337 ATwIdAOIBK05NigCdPDoPgE8CnXgiHz+ieb/TBD/TBi/9AGBTRz/gMdFMACc
338 sBCxBUi0k4lEHLABiUQUmGaY0+BIZgMFZtPoaAAQB7+AACn4nHMCAccx21BW
339 6J4AXrkAgLSH/kQczRVYnXfcoRoCvxwCsQk4RBxyuJPNE+oAACCQsEYoyL7b
340 AejSAF3rI4D5E3IEOMF3a4D+AnIEOOZ3bGCB/QAGdCoGUlFTlrQCULEGtQTB
341 xQSwDyHoBJAnFEAn6IwA/s117LAgzRDitOiWAJjNE2FSUCjIdwKwAZg5+HIC
342 ifhQtALNE5VeWFpyoJVBjuGAxwJPdFFOdfSM4ZU4wXVFiMj+xrEBOOZ1O4j0
343 /sW2AID9UHIwOi7wAXIqtQBgvt4B/kQMU+gxAFvoOAB1FlKYzRO4AQLNE1rQ
344 1Dpk/nXqRgjkdeVh64sWB7AxLAO0DrsHAM0QPA1088OwDejv/6wIwHX4w79s
345 BLFbZQINuA0BZToNdArNFnT0mM0Wju9Hw1g6AEluc2VydCBkaXNrIDEuBw0A
346 AA==
347 ====
348 EOT
350 # Get setup
351 setupsz=$(getlong $SetupSzOfs $bs)
352 setupszb=$(( $setupsz & 255 ))
353 dd if=$KERNEL bs=512 skip=1 count=$setupszb 2> /dev/null >> $bs
355 # Store cmdline after setup
356 if [ -n "$CMDLINE" ]; then
357 echo -n "$CMDLINE" | dd bs=512 count=1 conv=sync 2> /dev/null >> $bs
358 storelong ArgPtrOfs $(( $SetupBase + $stacktop )) $bs
359 fi
361 # Compute initramfs size
362 initrdlen=0
363 padding=0
364 for i in $( echo $INITRD | sed 's/,/ /' ); do
365 [ -s "$i" ] || continue
366 initrdlen=$(( $initrdlen + $padding ))
367 padding=$(stat -c %s $i)
368 initrdlen=$(( $initrdlen + $padding ))
369 padding=$(( 4096 - ($padding & 4095) ))
370 [ $padding -eq 4096 ] && padding=0
371 done
372 Ksize=$(( $(getlong $SyssizeOfs $bs)*16 ))
373 Kpad=$(( (($Ksize+4095)/4096)*4096 - Ksize ))
374 if [ $initrdlen -ne 0 ]; then
375 Kbase=$(getlong $CodeAdrOfs $bs)
376 storelong $RamfsAdrOfs \
377 $(( (0x1000000 - $initrdlen) & 0xFFFF0000 )) $bs
378 storelong $RamfsLenOfs $initrdlen $bs
379 fi
381 # Output boot sector + setup + cmdline
382 dd if=$bs 2> /dev/null
384 # Output kernel code
385 dd if=$KERNEL bs=512 skip=$(( $setupszb + 1 )) 2> /dev/null
387 # Pad to next sector
388 Kpad=$(( 512 - ($(stat -c %s $KERNEL) & 511) ))
389 [ $Kpad -eq 512 ] || dd if=/dev/zero bs=1 count=$Kpad 2> /dev/null
391 # Output initramfs
392 padding=0
393 for i in $( echo $INITRD | sed 's/,/ /' ); do
394 [ -s "$i" ] || continue
395 [ $padding -ne 0 ] && dd if=/dev/zero bs=1 count=$padding
396 dd if=$i 2> /dev/null
397 padding=$(( 4096 - ($(stat -c %s $i) & 4095) ))
398 [ $padding -eq 4096 ] && padding=0
399 done
401 # Cleanup
402 rm -f $bs
403 }
405 # Create boot floppy set from kernel, initrd & cmdline
406 floppyset()
407 {
408 floppysetcat "$@" | split -b 1440k /dev/stdin floppy$$
409 i=1
410 ls floppy$$* | while read file ; do
411 output=$(printf "fd%03d.img" $i)
412 cat $file /dev/zero | dd bs=1k count=1440 of=$output conv=sync 2> /dev/null
413 rm -f $file
414 i=$(( $i + 1 ))
415 done
416 }
418 # Create boot floppy set from a SliTaz ISO image
419 floppysetfromiso()
420 {
421 mkdir /tmp/iso$$
422 mount -o loop,ro $1 /tmp/iso$$
423 rootfs="$(ls /tmp/iso$$/boot/rootfs*z 2> /dev/null | tail -1)"
424 bzimage=/tmp/iso$$/boot/bzImage
425 if [ -z "$rootfs" -o ! -s $bzimage ]; then
426 umount -d /tmp/iso$$
427 rm -rf /tmp/iso$$
428 echo "Not a SliTaz ISO image !"
429 return 1
430 fi
431 mkdir -p /tmp/rootfs$$/fs
432 n=1
433 for i in $(ls /tmp/iso$$/boot/rootfs*z | sort -r); do
434 mkdir /tmp/rootfs$$/$n
435 ln -s $i /tmp/rootfs$$/$n
436 n=$(($n + 1))
437 done
438 echo "Unpack rootfs..."
439 ( zcat $rootfs 2> /dev/null | unlzma -c $rootfs ) | \
440 ( cd /tmp/rootfs$$/fs ; cpio -idm > /dev/null )
441 if [ $(unlzma -c $rootfs 2> /dev/null| wc -c) -gt $(stat -c %s $rootfs) ]; then
442 if [ $(du -ck $rootfs $bzimage | awk 'END { print $1 }') -gt 15296 ]; then
443 # The rootfs.gz file is too big, extract a minimum bootfs with busybox stuff
444 echo "Extract bootfs..."
445 mv /tmp/rootfs$$/fs /tmp/rootfs$$/fs0
446 for i in lib bin sbin usr/bin usr/sbin ; do
447 mkdir -p /tmp/rootfs$$/fs/$i
448 done
449 cd /tmp/rootfs$$/fs0
450 dir=$(echo lib/modules/*/kernel/drivers/block)
451 [ -d $dir ] && mkdir -p ../fs/$dir
452 [ -f $dir/floppy.ko.gz ] && mv $dir/floppy.ko.gz ../fs/$dir
453 for i in dev init mnt proc sys tmp ; do
454 mv $i ../fs
455 done
456 mv lib/ld-* ../fs/lib
457 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so bin/busybox | \
458 awk '/\/lib\/lib/ { print $3 }' | while read lib ; do
459 while [ -L .$lib ]; do
460 local target
461 target="$(readlink ".$lib")"
462 case "$target" in
463 /*) ;;
464 *) target="$(dirname $lib)/$target" ;;
465 esac
466 mv ".$lib" ../fs/lib
467 lib="$target"
468 done
469 mv ".$lib" ../fs/lib
470 done
471 for i in $(bin/busybox | awk '{ if (s) printf "%s",$0 }
472 /Currently/ { s=1 }' | sed 's/,//g'); do
473 for j in bin sbin usr/bin usr/sbin ; do
474 [ -e $j/$i ] && mv $j/$i ../fs/$j/$i
475 done
476 done
477 mv bin/busybox ../fs/bin
478 [ -e ../fs/bin/cpio ] || mv bin/cpio ../fs/bin
479 rm -f ../1/*
480 find | cpio -o -H newc | lzma e ../1/rootfs.gz -si
481 cd - > /dev/null
482 rm -rf /tmp/rootfs$$/fs0
483 else
484 # The rootfs.gz file fits in 15MB, no need to split it.
485 rm -rf /tmp/rootfs$$/1
486 fi
487 else
488 # This is a loram rootfs.gz, extract loram bootstrap
489 echo "Split loram rootfs..."
490 offset=$(awk '/07070100/ { o+=index($0,"07070100"); print o/4 ; exit } { o+=1+length() }' < $rootfs)
491 dd if=$rootfs skip=$(($offset / 1024)) bs=4k count=1 2> /dev/null | \
492 dd skip=$(($offset % 1024)) bs=4 of=/tmp/rootfs$$/1/root 2> /dev/null
493 dd if=$rootfs skip=$((1 + ($offset / 1024) )) bs=4k \
494 >> /tmp/rootfs$$/1/root 2> /dev/null
495 rm -f /tmp/rootfs$$/1/rootfs*
496 fi
497 # Create extra rootfs floppies
498 for i in /tmp/rootfs$$/[1-9]*/root* ; do
499 [ -f $i ] || continue
500 echo "Create floppies for rootfs $(basename $(dirname $i) )..."
501 case "$(dd if=$i bs=1 count=4 2> /dev/null)" in
502 0707) cat $i ;;
503 *) zcat $i 2> /dev/null || unlzma -c $i ;;
504 esac | cpio -t > $(dirname $i)/files.list
505 sed -i '/ blocks$/d' $(dirname $i)/files.list
506 x=$(readlink $i)
507 [ -n "$x" ] || x=$i
508 pad=$(( $(stat -c %s $x ) % 1474560 ))
509 [ $pad -ne 0 ] && pad=$(( 1474560 - $pad ))
510 dd if=/dev/zero bs=1 count=$pad 2> /dev/null | cat $i - | \
511 split -b 1440k /dev/stdin $(dirname $i)/floppy
512 done
513 selection="$(grep -s append /tmp/iso$$/boot/isolinux/common.cfg | sed 's/.*append //')"
514 [ -n "$selection" ] || selection="0 slitaz"
515 set -- $selection
516 selection=""
517 while [ -n "$2" ]; do
518 [ ! -d /tmp/rootfs$$/1 -a -z "$4" ] && break
519 case "$1" in
520 *G) selection="$2 $(( ${1%G} * 1024 * 1024 )) $selection" ;;
521 *M) selection="$2 $(( ${1%M} * 1024 )) $selection" ;;
522 *) selection="$2 $1 $selection" ;;
523 esac
524 shift 2
525 done
526 echo "Create /init ..."
527 base=100
528 set -- $selection
529 for i in /tmp/rootfs$$/[1-9]* ; do
530 [ -d $i ] || continue
531 while read file; do
532 [ -e $i/../fs/$file ] && continue
533 [ $(grep -- "$file" $i/../*/files.list | wc -l) -eq 1 ] &&
534 break
535 done < $i/files.list
536 printf "%s %s %03d %d %s %s\n" \
537 $1 $2 $base $(ls $i/floppy* | wc -l) $file \
538 $(cat $i/floppy* | md5sum - | awk '{print $1}')
539 base=$(($base + 100))
540 shift 2
541 done | buildinit /tmp/rootfs$$/fs
542 cmdline="$(grep append /tmp/iso$$/boot/isolinux/isolinux.cfg | tail -n 1 | sed 's/.*gz //')"
543 ( cd /tmp/rootfs$$/fs ; find | cpio -o -H newc ) | lzma e /tmp/rootfs$$/rootfs -si
544 echo "Create first stage boot floppies..."
545 floppyset $bzimage /tmp/rootfs$$/rootfs "$cmdline"
546 base=100
547 for i in /tmp/rootfs$$/[1-9]* ; do
548 [ -d $i ] || continue
549 j=0
550 for f in $i/floppy* ; do
551 mv $f $(printf "fd%03d.img" $(( $base + $j )) )
552 j=$(($j + 1))
553 done
554 base=$(($base + 100))
555 done
556 rm -rf /tmp/rootfs$$
557 umount -d /tmp/iso$$
558 rm -rf /tmp/iso$$
559 }
561 # Show new boot floppy set
562 dialogwritefloppyset()
563 {
564 if ! list_floppy check; then
565 du -h fd???.img
566 return
567 fi
568 while true; do
569 exec 3>&1
570 IMAGE=`$DIALOG --title " Write floppy image " \
571 --backtitle "Boot floppy set creation on $DEVICE" --clear \
572 --colors --radiolist "
573 Insert a blank floppy in drive and
574 select the floppy image you want to write.
575 " 18 46 46 \
576 $(on="on"; for i in fd???.img; do echo "$i $(du -h $i | cut -f1) $on "; on="off"; done) 2>&1 1>&3`
577 retval=$?
578 exec 3>&-
579 check_retval
580 dd if=$IMAGE of=$DEVICE
581 done
582 }
584 dialognofloppyset()
585 {
586 cat << EOT
587 The boot loader can't load the kernel and the initramfs in the first 16MB
588 of RAM. The total size exceeds 15MB. No floppy image is created.
589 EOT
590 }
592 # Check for iso 9660 image
593 isiso()
594 {
595 mkdir /tmp/iso$$
596 mount -o loop,ro $1 /tmp/iso$$ 2> /dev/null
597 status=$?
598 umount -d /tmp/iso$$ 2> /dev/null
599 rm -rf /tmp/iso$$
600 return $status
601 }
603 dialogfloppyset()
604 {
605 : ${DIALOG=dialog}
606 while true; do
607 exec 3>&1
608 KERNEL=`$DIALOG --title " Select a Linux kernel or a SliTaz iso " \
609 --backtitle "Boot floppy set creation on $DEVICE" --clear \
610 --colors --fselect "$PWD" 10 70 \
611 2>&1 1>&3`
612 retval=$?
613 exec 3>&-
614 check_retval
615 [ -f $KERNEL ] && break
616 done
617 if isiso $KERNEL ; then
618 bootfloppybox call mkisofloppies $KERNEL
619 dialogwritefloppyset
620 return
621 fi
622 exec 3>&1
623 INITRD=`$DIALOG --title " Select an Initramfs " \
624 --backtitle "Boot floppy set creation on $DEVICE" --clear \
625 --colors --fselect "$PWD" 10 70 \
626 2>&1 1>&3`
627 retval=$?
628 exec 3>&-
629 check_retval
630 [ -f "$INITRD" ] || INITRD=""
631 exec 3>&1
632 CMDLINE=`$DIALOG --title " Enter boot command line " \
633 --backtitle "Boot floppy set creation on $DEVICE" --clear \
634 --colors --inputbox "Kernel command line" 10 70 "rw root=/dev/null autologin" \
635 2>&1 1>&3`
636 retval=$?
637 exec 3>&-
638 check_retval
639 bootfloppybox call mkfloppies "$KERNEL" "$INITRD" "$CMDLINE" &&
640 dialogwritefloppyset ||
641 dialognofloppyset
642 }
644 #
645 # Create floppy image set
646 #
647 export IMAGE_SET='
648 <window title="Image set generator" icon-name="gtk-floppy">
649 <vbox>
650 <text use-markup="true">
651 <label>
652 "
653 <b>Create a boot floppy set</b>
654 "
655 </label>
656 </text>
657 <notebook labels="Slitaz only|Any Linux">
658 <frame Slitaz only (no size limit)>
659 <vbox>
660 <text wrap="false" width-chars="44" use-markup="true">
661 <label>
662 "
663 Slitaz uses a floppy boot flavor as a first
664 stage boot to break the tiny loader 15MB limit.
665 "
666 </label>
667 </text>
668 <hbox>
669 <text use-markup="true">
670 <label>"<b>Slitaz ISO : </b>"</label>
671 </text>
672 <entry accept="filename">
673 <label>Select a Slitaz ISO image</label>
674 <variable>ISO</variable>
675 </entry>
676 <button>
677 <input file stock="gtk-open"></input>
678 <action type="fileselect">ISO</action>
679 </button>
680 </hbox>
681 <hbox>
682 <text use-markup="true">
683 <label>"<b>Output directory : </b>"</label>
684 </text>
685 <entry accept="directory">
686 <label>Select output directory</label>
687 <variable>FILE_DIRECTORY</variable>
688 <default>/tmp</default>
689 </entry>
690 <button>
691 <input file stock="gtk-open"></input>
692 <action type="fileselect">FILE_DIRECTORY</action>
693 </button>
694 </hbox>
695 <hbox>
696 <button>
697 <input file icon="forward"></input>
698 <label>Create image set from ISO boot</label>
699 <action>cd $FILE_DIRECTORY; bootfloppybox call mkisofloppiesxterm $ISO</action>
700 <action type="closewindow">IMAGE_SET</action>
701 </button>
702 </hbox>
703 </vbox>
704 </frame>
705 <frame Any Linux distribution (max total size 14-15MB)>
706 <vbox>
707 <text wrap="false" width-chars="44" use-markup="true">
708 <label>
709 "
710 The total size of the kernel and the initramfs must be
711 lower than 14-15MB due to the tiny boot loader design.
712 "
713 </label>
714 </text>
715 <hbox>
716 <text use-markup="true">
717 <label>"<b>Kernel : </b>"</label>
718 </text>
719 <entry accept="filename">
720 <label>Select a linux kernel</label>
721 <variable>KERNEL</variable>
722 </entry>
723 <button>
724 <input file stock="gtk-open"></input>
725 <action type="fileselect">KERNEL</action>
726 </button>
727 </hbox>
728 <hbox>
729 <text use-markup="true">
730 <label>"<b>Initramfs : </b>"</label>
731 </text>
732 <entry accept="filename">
733 <label>Select an initramfs/initrd file</label>
734 <variable>INITRD</variable>
735 </entry>
736 <button>
737 <input file stock="gtk-open"></input>
738 <action type="fileselect">INITRD</action>
739 </button>
740 </hbox>
741 <hbox>
742 <text use-markup="true">
743 <label>"<b>Cmdline : </b>"</label>
744 </text>
745 <entry>
746 <label>Enter kernel arguments</label>
747 <variable>CMDLINE</variable>
748 <default>rw root=/dev/null autologin</default>
749 </entry>
750 </hbox>
751 <hbox>
752 <text use-markup="true">
753 <label>"<b>Output directory : </b>"</label>
754 </text>
755 <entry accept="directory">
756 <label>Select output directory</label>
757 <variable>OUTPUT_DIRECTORY</variable>
758 <default>/tmp</default>
759 </entry>
760 <button>
761 <input file stock="gtk-open"></input>
762 <action type="fileselect">OUTPUT_DIRECTORY</action>
763 </button>
764 </hbox>
765 <hbox>
766 <button>
767 <input file icon="forward"></input>
768 <label>Create image set</label>
769 <action>cd $OUTPUT_DIRECTORY; bootfloppybox call mkfloppies "$KERNEL" "$INITRD" "$CMDLINE"</action>
770 <action type="closewindow">IMAGE_SET</action>
771 </button>
772 </hbox>
773 </vbox>
774 </frame>
775 </notebook>
776 <hbox>
777 <button>
778 <input file icon="gtk-close"></input>
779 <action type="closewindow">IMAGE_SET</action>
780 </button>
781 </hbox>
782 </vbox>
783 </window>
784 '
786 #
787 # Read/write floppy images
788 #
789 export FLOPPY_IMAGE='
790 <window title="Floppy image manager" icon-name="gtk-floppy">
791 <vbox>
792 <frame Floppy disk drive>
793 <hbox>
794 <text use-markup="true">
795 <label>"<b>Device : </b>"</label>
796 </text>
797 <combobox>
798 <variable>DEVICE</variable>'
799 FLOPPY_DEV=""
800 for i in $(list_floppy); do
801 FLOPPY_DEV="$FLOPPY_DEV
802 <item>/dev/$i</item>"
803 done
804 FLOPPY_IMAGE="$FLOPPY_IMAGE$FLOPPY_DEV
805 </combobox>
806 <button>
807 <label>Format floppy</label>
808 <input file icon=\"media-floppy\"></input>
809 <action>fdformat -n $DEVICE</action>
810 </button>
811 </hbox>
812 </frame>
813 <frame Floppy image file>
814 <hbox>
815 <text use-markup=\"true\">
816 <label>\"<b>File : </b>\"</label>
817 </text>
818 <entry accept=\"filename\">
819 <label>Select a floppy image</label>
820 <variable>IMAGE</variable>
821 </entry>
822 <button>
823 <input file stock=\"gtk-open\"></input>
824 <action type=\"fileselect\">IMAGE</action>
825 </button>
826 </hbox>
827 </frame>
828 <hbox>
829 <button>
830 <input file icon=\"reload\"></input>
831 <label>Create image set</label>
832 <action type=\"launch\">IMAGE_SET</action>
833 </button>
834 <button>
835 <input file icon=\"go-jump\"></input>
836 <label>Write image to floppy</label>
837 <action>dd if=\$IMAGE of=\$DEVICE</action>
838 </button>
839 <button>
840 <input file icon=\"undo\"></input>
841 <label>Get floppy image</label>
842 <action>dd if=\$DEVICE of=\$IMAGE</action>
843 </button>
844 <button>
845 <input file icon=\"gtk-close\"></input>
846 <action type=\"closewindow\">FLOPPY_IMAGE</action>
847 </button>
848 </hbox>
849 </vbox>
850 </window>
851 "
853 gtkdialogshowfloppyset()
854 {
855 #
856 # Show floppy image set
857 #
858 IMAGE_SHOW='
859 <window title="Image set" icon-name="gtk-floppy">
860 <vbox>
861 <text use-markup="true">
862 <label>
863 "
864 <b>Boot floppy images</b>
865 "
866 </label>
867 </text>
868 <tree>
869 <width>50</width><height>140</height>
870 <label>Size|File</label>
871 <input>du -h fd???.img | sed "s/\t/|/" </input>
872 </tree>
873 <hbox>
874 '
875 [ 0$1 -gt $((15 * 1024 * 1024)) ] && IMAGE_SHOW="$IMAGE_SHOW
876 <frame WARNING>
877 <text>
878 <label>
879 \"This floppy set breaks the 15MB limit ($1 bytes).
880 It may not be able to complete the boot process.\"
881 </label>
882 </text>
883 </frame>
884 </hbox>
885 <hbox>
886 "
887 list_floppy check && IMAGE_SHOW="$IMAGE_SHOW
888 <button>
889 <input file icon=\"media-floppy\"></input>
890 <label>Manage images</label>
891 <action type=\"launch\">FLOPPY_IMAGE</action>
892 </button>
893 "
894 IMAGE_SHOW="$IMAGE_SHOW
895 <button>
896 <input file icon=\"gtk-close\"></input>
897 <action type=\"closewindow\">IMAGE_SET</action>
898 </button>
899 </hbox>
900 </vbox>
901 </window>
902 "
903 export IMAGE_SHOW
904 gtkdialog --program=IMAGE_SHOW
905 }
907 while true; do
909 if [ "$1" == "call" ]; then
910 case "$2" in
911 mkmenu) mkmenu $3;;
912 mkisofloppiesxterm)
913 shift 2
914 xterm -geometry 80x16 -title "Build boot floppies from ISO" \
915 -e "$0 call mkisofloppies $@ ; echo -e \"----\nENTER to continue...\" && read close"
916 gtkdialogshowfloppyset
917 ;;
918 mkisofloppies)
919 shift 2
920 floppysetfromiso $@
921 ;;
922 mkfloppies)
923 shift 2
924 floppyset "$@"
925 sz=$(cat fd???.img | wc -c)
926 if [ -n "$XAUTHORITY" ]; then
927 gtkdialogshowfloppyset $sz
928 else
929 if [ $sz -gt $((15 * 1024 * 1024)) ]; then
930 cat <<EOT
931 This floppy set breaks the 15MB limit ($sz bytes).
932 It may not be able to complete the boot process.
933 EOT
934 fi
935 fi
936 ;;
937 install)
938 DIR=/tmp/mkbootfloppy$$
939 mkdir -p $DIR
940 DEVICE=$4
941 file=$5
942 case "$3" in
943 dialog*)
944 shift 2
945 $@
946 ;;
947 grub*)
948 mkdir -p $DIR/boot/grub
949 [ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ] \
950 && cat /usr/share/boot/btmgr /dev/zero | \
951 dd bs=18k count=80 | gzip -9 > \
952 $DIR/boot/btmgr.gz \
953 && unlzma -c /usr/share/boot/memdisk.lzma > \
954 $DIR/boot/memdisk
955 [ -f /usr/share/boot/plpbt.bin ] \
956 && cp /usr/share/boot/plpbt.bin $DIR/boot
957 [ -f /usr/share/boot/etherboot ] \
958 && cp /usr/share/boot/etherboot $DIR/boot
959 [ -f /boot/gpxe ]\
960 && cp /boot/gpxe $DIR/boot
961 [ -f /usr/share/boot/memtest.lzma -a \
962 -f /usr/share/boot/memdisk.lzma ] \
963 && unlzma -c /usr/share/boot/memtest.lzma | \
964 cat - /dev/zero | dd bs=18k count=80 | \
965 gzip -9 > $DIR/boot/memtest.gz \
966 && unlzma -c /usr/share/boot/memdisk.lzma > \
967 $DIR/boot/memdisk
968 install_grub $DIR $3
969 ;;
970 *)
971 case "$file" in
972 *.lzma) action="unlzma -c";;
973 *.gz) action="zcat";;
974 *) action="cat";;
975 esac
976 case "$DEVICE" in
977 /dev/*) $action $file > $DEVICE;;
978 flopp*) $action $file | cat - /dev/zero | \
979 dd bs=18k count=80 > boot.fd;;
980 cdrom*)
981 mkdir -p $DIR/boot/grub
982 case "$3" in
983 btmgr|memtest)
984 $action $file | cat - /dev/zero | \
985 dd bs=18k count=80 | \
986 gzip -9 > $DIR/boot/$3.gz
987 unlzma -c /usr/share/boot/memdisk.lzma \
988 > $DIR/boot/memdisk
989 cat > /tmp/floppybox.grub.menu << EOT
990 # grub menu
991 timeout 0
992 title $3
993 kernel /boot/memdisk floppy c=80 h=2 s=18
994 initrd /boot/$3.gz
995 EOT
996 ;;
997 *) $action $file > $DIR/boot/$3
998 cat > /tmp/floppybox.grub.menu << EOT
999 # grub menu
1000 timeout 0
1001 title $3
1002 kernel /boot/$3
1003 EOT
1004 ;;
1005 esac
1006 install_grub $DIR grub
1007 ;;
1008 esac
1009 ;;
1010 esac
1011 rm -rf $DIR
1012 ;;
1013 get-plop)
1014 mkdir -p /tmp/get-plop$$
1015 PLOP_URL=http://mirror.slitaz.org/boot/plpbt.bin
1016 wget -O - $PLOP_URL > /tmp/get-plop$$/plpbt.bin
1017 VERSION="$(strings /tmp/get-plop$$/plpbt.bin \
1018 | grep 'Boot Manager v' | sed 's/.* v\([0-9\.]*\) .*/\1/')"
1019 mkdir -p $(dirname /tmp/get-plop$$/plop-$VERSION/fs/$3)
1020 mv /tmp/get-plop$$/plpbt.bin \
1021 /tmp/get-plop$$/plop-$VERSION/fs/$3
1022 if [ -s /tmp/get-plop$$/plop-$VERSION/fs/$3 ]; then
1023 cat > /tmp/get-plop$$/plop-$VERSION/receipt <<EOT
1024 PACKAGE="plop"
1025 VERSION="$VERSION"
1026 CATEGORY="non-free"
1027 SHORT_DESC="Plop boot manager."
1028 WEB_SITE="http://www.plop.at/en/bootmanager.html"
1029 EOT
1030 ( cd /tmp/get-plop$$ ; tazpkg pack plop-$VERSION )
1031 tazpkg install /tmp/get-plop$$/plop-$VERSION.tazpkg
1032 fi
1033 rm -rf /tmp/get-plop$$
1034 ;;
1035 *) echo "Invalid command $0 $@" 1>&2
1036 exit 1;;
1037 esac
1038 exit 0
1039 fi
1041 if [ -z "$XAUTHORITY" ]; then
1043 : ${DIALOG=dialog}
1045 DEVICE=/dev/fd0
1046 list_floppy check || DEVICE="floppy"
1047 while true; do
1048 exec 3>&1
1049 ID_SOURCE=`$DIALOG --title " Choose a boot floppy " \
1050 --backtitle "Boot Floppy Creation on $DEVICE" --clear \
1051 --extra-button --extra-label "Change floppy" \
1052 --colors --radiolist "
1053 Create a floppy or a cdrom to boot a LiveCD in a PXE network...
1054 May need a floppy disk in drive. Erase the whole floppy disk.
1055 " 18 70 50\
1056 FloppySet "Boot Slitaz with floppies only." on \
1057 SmartBtmgr "Boot any partition or ATAPI CD-ROM." off \
1058 Plop "Boot USB harddisk floppy or CD/DVD." off \
1059 Etherboot "Replacement for proprietary PXE ROMs." off \
1060 gPXE "Boot from http://boot.slitaz.org/" off \
1061 Memtest86+ "Memory failures detection tool." off \
1062 Grub4DOS "Enhanced grub version supporting NTFS." off \
1063 Grub "Boot loader with command shell." off \
1064 2>&1 1>&3`
1065 retval=$?
1066 exec 3>&-
1067 check_retval
1068 if [ "$retval" = "3" ]; then
1069 select_floppy
1070 continue;
1071 fi
1072 while read key file pkg; do
1073 [ "$key" = "$ID_SOURCE" ] || continue
1074 if [ ! -f "$file" ]; then
1075 $DIALOG --title " Install package " --colors \
1076 --backtitle "Boot Floppy Creation" --clear \
1077 --yes-label "Install" \
1078 --no-label "Quit" \
1079 --yesno "The package $pkg is not yet installed. Install it ?" 18 70
1080 retval=$?
1081 if [ "$pkg" = "plop" ]; then
1082 bootfloppybox call get-plop $file
1083 else
1084 tazpkg get-install $pkg
1085 fi
1086 fi
1087 bootfloppybox call install "$pkg" "$DEVICE" "$file"
1088 exit 0
1089 done <<EOT
1090 FloppySet /bin/dd dialogfloppyset
1091 SmartBtmgr /usr/share/boot/btmgr btmgr
1092 Plop /usr/share/boot/plpbt.bin plop
1093 Etherboot /usr/share/boot/etherboot etherboot
1094 gPXE /boot/gpxe gpxe
1095 Memtest86+ /usr/share/boot/memtest.lzma memtest
1096 Grub4DOS /usr/share/boot/grldr.lzma grub4dos
1097 Grub /usr/sbin/grub grub
1098 EOT
1099 done
1100 fi
1102 # Describe gPXE arguments.
1104 export HELP='
1105 <window title="gPXE forced url" icon-name="gtk-floppy">
1106 <vbox>
1107 <text use-markup="true">
1108 <label>"
1109 <b>Web boot parameters</b>"
1110 </label>
1111 </text>
1112 <frame>
1113 <text wrap="true" width-chars="58" use-markup="true">
1114 <label>
1115 "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.
1117 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>.
1119 You can override 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>
1121 The <i>nodhcp</i> keyword avoids dhcp timeouts and the <i>url=</i> keyword is optional when the url is the only one argument.
1123 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.
1125 </label>
1126 </text>
1127 </frame>
1128 </vbox>
1129 </window>
1132 # Write bootfloppy image to floppy device.
1134 BOOT_DIALOG='
1135 <window title="bootfloppybox" icon-name="gtk-floppy">
1136 <vbox>
1138 <text use-markup="true">
1139 <label>
1141 <b>SliTaz - Bootfloppybox</b>"
1142 </label>
1143 </text>
1144 <text wrap="false" width-chars="44" use-markup="true">
1145 <label>
1147 Create a floppy or a cdrom to boot a LiveCD in a PXE network or the WEB...
1148 May need a floppy disk in drive. Erase the whole floppy disk.
1150 </label>
1151 </text>
1153 <frame Floppy disk drive>
1154 <hbox>
1155 <text use-markup="true">
1156 <label>"<b>Device : </b>"</label>
1157 </text>
1158 <combobox>
1159 <variable>DEVICE</variable>'
1160 FLOPPY_DEV=""
1161 for i in $(list_floppy); do
1162 FLOPPY_DEV="$FLOPPY_DEV
1163 <item>/dev/$i</item>"
1164 done
1165 BOOT_DIALOG="$BOOT_DIALOG$FLOPPY_DEV
1166 <item>floppy image (boot.fd)</item>
1167 <item>cdrom image (boot.iso)</item>
1168 </combobox>"
1169 if [ -n "$FLOPPY_DEV" ]; then
1170 tmp='
1171 <button>
1172 <label>Format floppy</label>
1173 <input file icon="media-floppy"></input>
1174 <action>case "$DEVICE" in /dev/*) fdformat -n $DEVICE;; esac</action>
1175 </button>'
1176 BOOT_DIALOG="$BOOT_DIALOG$tmp"
1177 fi
1178 tmp='
1179 </hbox>
1180 </frame>
1181 <notebook labels="Set|LiveCD|USB|PXE Network|WEB Network|Memory Test|Windows|Expert">
1182 <frame Boot floppy set (many floppies)>
1183 <vbox>
1184 <hbox>
1185 <text wrap="true" width-chars="58" use-markup="true">
1186 <label>
1188 Only people without a CD-ROM, USB and Network should use a floppy set.
1189 The images are built from an ISO boot or from a Linux kernel, an initramfs
1190 and a boot command line. Non Slitaz boot floppy sets are limited to 15MB.
1192 </label>
1193 </text>
1194 </hbox>
1195 <hbox>
1196 <button>
1197 <label>Create image set</label>
1198 <input file icon="forward"></input>
1199 <action type="launch">IMAGE_SET</action>
1200 </button>
1201 </hbox>
1202 </vbox>
1203 </frame>
1205 BOOT_DIALOG="$BOOT_DIALOG$tmp"
1206 while read name file pkg desc; do
1207 tmp="<frame $name (single floppy)>
1208 <hbox>
1209 <text wrap=\"true\" width-chars=\"58\" use-markup=\"true\">
1210 <label>
1211 \"
1212 $(echo -e $desc)
1213 \"
1214 </label>
1215 </text>
1216 </hbox>
1217 <hbox>
1219 if [ -f $file ]; then
1220 if [ "$pkg" = "grub" -o "$pkg" = "grub4dos" ]; then
1221 tmp="$tmp
1222 <button>
1223 <label>Grub menu</label>
1224 <input file icon=\"accessories-text-editor\"></input>
1225 <action>bootfloppybox call mkmenu $pkg</action>
1226 <action type=\"lauch\">leafpad /tmp/floppybox.grub.menu</action>
1227 </button>
1229 elif [ "$pkg" = "etherboot" ]; then
1230 tmp="$tmp
1231 <button>
1232 <input file icon=\"browser\"></input>
1233 <label>Wiki</label>
1234 <action>browser http://doc.slitaz.org/en:guides:pxe &</action>
1235 </button>
1237 elif [ "$pkg" = "gpxe" ]; then
1238 tmp="$tmp
1239 <text wrap=\"true\" use-markup=\"true\">
1240 <label> \"<b>Boot URL:</b>\" </label>
1241 </text>
1242 <entry>
1243 <default>$(dd if=$file bs=1 skip=519 count=255 2>/dev/null | strings)</default>
1244 <variable>URL</variable>
1245 </entry>
1246 </hbox>
1247 <hbox>
1248 <button>
1249 <input file icon=\"browser\"></input>
1250 <label>Wiki</label>
1251 <action>browser http://doc.slitaz.org/en:guides:pxe &</action>
1252 </button>
1253 <button help>
1254 <action type=\"launch\">HELP</action>
1255 </button>
1256 <button>
1257 <label>Update</label>
1258 <input file icon=\"reload\"></input>
1259 <action>echo -n \"\$URL\" | cat - /dev/zero | dd conv=notrunc bs=1 count=255 seek=519 of=$file 2>/dev/null</action>
1260 </button>
1262 fi
1263 receipt=/var/lib/tazpkg/installed/$pkg/receipt
1264 if [ -f $receipt ]; then
1265 . $receipt
1266 tmp="$tmp
1267 <button>
1268 <input file icon=\"browser\"></input>
1269 <label>Web</label>
1270 <action>browser $WEB_SITE &</action>
1271 </button>
1273 fi
1274 tmp="$tmp
1275 <button>
1276 <label>Write floppy</label>
1277 <input file icon=\"forward\"></input>
1278 <action>bootfloppybox call install \"$pkg\" \"\$DEVICE\" \"$file\"</action>
1279 </button>
1280 </hbox>
1281 </frame>
1283 else
1284 tmp2="tazpkg get-install $pkg --forced"
1285 [ "$pkg" = "plop" ] && tmp2="bootfloppybox call get-plop $file"
1286 tmp="$tmp
1287 <text wrap=\"true\" width-chars=\"34\" use-markup=\"true\">
1288 <label>
1289 \"<i>The package <b>$pkg</b> is not yet installed</i>\"
1290 </label>
1291 </text>
1292 <button>
1293 <input file icon=\"go-jump\"></input>
1294 <label>Install</label>
1295 <action>[ -f /var/lib/tazpkg/packages.list ] || tazpkg recharge</action>
1296 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title \"$pkg install\" -e \"$tmp2 ; sleep 2\"</action>
1297 <action type=\"exit\">restart</action>
1298 </button>
1299 </hbox>
1300 </frame>
1302 fi
1303 BOOT_DIALOG="$BOOT_DIALOG$tmp"
1304 done <<EOT
1305 SmartBtmgr /usr/share/boot/btmgr btmgr This OS independent Smart Boot Manager can boot \\\\nany partition or ATAPI CD-ROM.
1306 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.
1307 Etherboot /usr/share/boot/etherboot etherboot This network bootloader provides a replacement \\\\nfor proprietary PXE or NBI ROMs.
1308 gPXE /boot/gpxe gpxe PXE / iSCSI / AoE network bootloader.
1309 Memtest86+ /usr/share/boot/memtest.lzma memtest Memory failures detection tool.
1310 Grub4DOS /usr/share/boot/grldr.lzma grub4dos Enhanced grub version supporting NTFS.
1311 Grub /usr/sbin/grub grub General purpose boot loader with command shell.
1312 EOT
1313 tmp='
1314 </notebook>
1315 <hbox>
1317 BOOT_DIALOG="$BOOT_DIALOG$tmp"
1318 if [ -e /dev/cdrom ]; then
1319 tmp='
1320 <button>
1321 <input file icon="media-cdrom"></input>
1322 <label>Burn cdrom image</label>
1323 <action>burnbox</action>
1324 </button>
1326 BOOT_DIALOG="$BOOT_DIALOG$tmp"
1327 fi
1328 if list_floppy check; then
1329 tmp='
1330 <button>
1331 <input file icon="media-floppy"></input>
1332 <label>Manage floppy image</label>
1333 <action type="launch">FLOPPY_IMAGE</action>
1334 </button>
1336 BOOT_DIALOG="$BOOT_DIALOG$tmp"
1337 fi
1338 tmp='
1339 <button>
1340 <input file icon="exit"></input>
1341 <label>Exit</label>
1342 <action type="exit">Exit</action>
1343 </button>
1344 </hbox>
1346 </vbox>
1347 </window>
1349 BOOT_DIALOG="$BOOT_DIALOG$tmp"
1350 export BOOT_DIALOG
1352 # Only root can create floppy.
1353 check_root
1354 gtkdialog --program=BOOT_DIALOG | grep -q 'EXIT="restart"' && continue
1355 rm -f /tmp/floppybox.grub.menu
1356 exit 0
1357 done