slitaz-tools view oldstuff/gtkdialog/bootfloppybox @ rev 917

Update fr.po (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Nov 05 23:27:35 2014 +0100 (2014-11-05)
parents 0a831f1f1b51
children 5cb52dd57d7a
line source
1 #! /bin/sh
2 #
3 # Gtkdialog box for the mount command. Part of SliTaz tools.
4 #
5 VERSION=20120412
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 for i in /dev/tty0 /dev/[sh]d[ab]? ; do
244 [ -e $1$i ] || cp -a $i $1/dev
245 done
246 cat > $1/init <<EOTEOT
247 #!/bin/sh
249 cat_floppy()
250 {
251 tmp="\$(dd if=/dev/fd0 count=1 2> /dev/null | md5sum)"
252 echo -n "Insert floppy \$num for \$name and press Enter or Q to skip"
253 while true; do
254 echo -n ":"
255 read -t 10 answer < /dev/tty0
256 case "\$answer" in
257 Q*|q*|A*|a*) break 3;;
258 esac
259 dd if=/dev/fd0 count=1 > /tmp/bs.\$\$ 2> /dev/null
260 [ -s /tmp/bs.\$\$ ] || continue
261 [ "\$(md5sum < /tmp/bs.\$\$)" != "\$tmp" ] || continue
262 rm -f /tmp/bs.\$\$
263 break
264 done
265 dd if=/dev/fd0 of=/tmp/rootfs.\$num 2> /dev/null || continue
266 cat /tmp/rootfs.\$num >> \$1
267 rm -f /tmp/rootfs.\$num
268 num=\$((\$num+1))
269 }
271 mount -t proc proc /proc
272 total=\$(grep MemTotal /proc/meminfo | sed 's/[^0-9]//g')
273 # the floppy driver may not be included in kernel
274 insmod /lib/modules/*/kernel/drivers/block/floppy.ko.gz 2> /dev/null
275 # loram may put floppy.ko.gz module in /lib
276 insmod /lib/floppy.ko.gz 2> /dev/null
277 case "\$(/sbin/blkid 2>&1)" in
278 *not\ found*)
279 cat <<EOT
281 You can preinstall SliTaz in an ext3 partition with this floppy set.
283 Simply enter the device name (/dev/XXXX) to create the slitaz/install.sh or
284 leave it blank to skip :
285 EOT
286 read -t 60 device < /dev/tty0
287 [ -n "\$device" ] && mount \$device /mnt && mkdir /mnt/slitaz ;;
288 *TYPE=\"ext*)
289 cat <<EOT
291 You can preinstall SliTaz in one of these ext3 partitions:
292 \$(blkid | grep 'TYPE="ext')
294 Simply enter the device name (/dev/XXXX) to create the slitaz/install.sh or
295 leave it blank to skip :
296 EOT
297 read -t 60 device < /dev/tty0
298 [ -n "\$device" ] && mount \$device /mnt && mkdir /mnt/slitaz ;;
299 *)
300 cat <<EOT
302 You can preinstall SliTaz in an ext3 partition with this floppy set.
303 After the boot process is completed, create a partition with 'fdisk',
304 format it with 'mke2fs -j' and reboot from the floppies again.
306 EOT
307 esac
308 umount /proc
309 while read name min num count file md5; do
310 [ -e \$file ] && continue
311 [ \$total -lt \$min ] && break
312 while [ \$count -ne 0 ]; do
313 cat_floppy /tmp/rootfs
314 count=\$((\$count-1))
315 done
316 echo "\$md5 /tmp/rootfs" | md5sum -c || break
317 cpio -idmu < /tmp/rootfs > /dev/null 2>&1 ||
318 ( zcat /tmp/rootfs 2> /dev/null || unlzma -c /tmp/rootfs ) | cpio -idmu
319 if [ -d /mnt/slitaz ]; then
320 cp /tmp/rootfs /mnt/slitaz/rootfs.\$num ||
321 mv -f /mnt/slitaz /mnt/slitaz-aborted
322 fi
323 rootfslist="\$rootfslist \$num"
324 rm -f /tmp/rootfs*
325 mkdir /sbin 2> /dev/null
326 done <<EOT
327 $(while read line; do echo $line; done)
328 EOT
329 if [ -d /mnt/slitaz ]; then
330 cat > /mnt/slitaz/install.sh <<EOT
331 #!/bin/sh
333 if [ -z "\\\$1" ]; then
334 echo "Usage: \\\$0 target-directory"
335 exit 1
336 fi
337 dir=\\\$(cd \\\$(dirname \\\$0); pwd)
338 cd \\\$1
339 for i in 0 \$rootfslist ; do
340 [ -s \\\$dir/rootfs.\\\$i ] || continue
341 cpio -idmu < \\\$dir/rootfs.\\\$i > /dev/null 2>&1 ||
342 ( zcat \\\$dir/rootfs.\\\$i 2> /dev/null || unlzma -c \\\$dir/rootfs.\\\$i ) | cpio -idmu
343 done
344 if ! mv -f init.org init 2> /dev/null; then
345 for i in \\\$(ls rootfs*gz | sed '1!G;h;\\\$!d'); do
346 mount -o loop,ro \\\$i /media/cdrom && rm -f \\\$i
347 cp -a /media/cdrom/. .
348 umount -d /media/cdrom
349 done
350 fi
351 mkdir boot && cp \\\$dir/bzImage boot
352 cp -a /usr/lib/grub/i386-pc boot/grub
353 cat > boot/grub/menu.lst<<EOF
354 # /boot/grub/menu.lst: GRUB boot loader configuration.
355 #
357 # By default, boot the first entry.
358 default 0
360 # Boot automatically after 8 secs.
361 timeout 8
363 # Change the colors.
364 color yellow/brown light-green/black
366 title SliTaz GNU/Linux
367 kernel /boot/bzImage root=\$device
369 EOF
370 grub-install --no-floppy --root-directory=\\\$PWD \${device%[1-9]*}
371 cd -
372 EOT
373 chmod +x /mnt/slitaz/install.sh
374 num=1
375 name="the Linux kernel"
376 dd count=0 of=/mnt/slitaz/bzImage.fd > /dev/null 2>&1
377 fullsize=1
378 while [ \$(stat -c %s /mnt/slitaz/bzImage.fd) -lt \$fullsize ]; do
379 cat_floppy /mnt/slitaz/bzImage.fd
380 setup=\$(dd if=/mnt/slitaz/bzImage.fd skip=497 bs=1 count=1 2> /dev/null | hexdump -e '"" 1/1 "%d" "\n"')
381 syssize=\$(dd if=/mnt/slitaz/bzImage.fd skip=500 bs=1 count=4 2> /dev/null | hexdump -e '"" 1/4 "%d" "\n"')
382 cmdline=\$(dd if=/mnt/slitaz/bzImage.fd skip=552 bs=1 count=4 2> /dev/null | hexdump -e '"" 1/4 "%d" "\n"')
383 initrd=\$(dd if=/mnt/slitaz/bzImage.fd skip=540 bs=1 count=4 2> /dev/null | hexdump -e '"" 1/4 "%d" "\n"')
384 [ \$cmdline -eq 0 ] || cmdline=512
385 size=\$((512 + \$setup * 512 + \$cmdline + \$syssize * 16))
386 [ -s /etc/slitaz-release ] || initrd=0
387 fullsize=\$((\$size + \$initrd + 512))
388 [ \$(stat -c %s /mnt/slitaz/bzImage.fd) -lt \$size ] ||
389 name="the first initramfs"
390 done
391 [ -s /etc/slitaz-release ] &&
392 dd if=/mnt/slitaz/bzImage.fd bs=512 skip=\$((\$setup+1+\$cmdline/512+(31+\$syssize)/32)) > /mnt/slitaz/rootfs.0 &&
393 dd bs=1 seek=\$initrd count=0 of=/mnt/slitaz/rootfs.0
394 dd if=/dev/zero of=/mnt/slitaz/bzImage.fd conv=notrunc bs=1 count=4 seek=552
395 dd if=/dev/zero of=/mnt/slitaz/bzImage.fd conv=notrunc bs=1 count=8 seek=536
396 dd if=/mnt/slitaz/bzImage.fd bs=512 count=\$((\$setup+1)) > /mnt/slitaz/bzImage
397 dd if=/mnt/slitaz/bzImage.fd bs=512 skip=\$((\$setup+1+\$cmdline/512)) >> /mnt/slitaz/bzImage
398 rm -f /mnt/slitaz/bzImage.fd
399 size=\$((512 + \$setup * 512 + \$syssize * 16))
400 dd bs=1 seek=\$size count=0 of=/mnt/slitaz/bzImage > /dev/null 2>&1
401 [ \$(stat -c %s /mnt/slitaz/bzImage) -eq \$size ] ||
402 mv -f /mnt/slitaz /mnt/slitaz-aborted
403 fi
404 [ -d /sbin ] && mv -f /init.org /init && exec /init
405 exec /bin/ash < /dev/tty0 > /dev/tty0 2>&1
406 EOTEOT
407 chmod +x $1/init
408 }
410 # write a 32 bits data
411 # usage: storelong offset data32 file
412 storelong()
413 {
414 printf "00000 %02X %02X %02X %02X \n" \
415 $(( $2 & 255 )) $(( ($2>>8) & 255 )) \
416 $(( ($2>>16) & 255 )) $(( ($2>>24) & 255 )) | \
417 hexdump -R | dd bs=1 conv=notrunc of=$3 seek=$(( $1 )) 2> /dev/null
418 }
420 # read a 32 bits data
421 # usage: getlong offset file
422 getlong()
423 {
424 dd if=$2 bs=1 skip=$(( $1 )) count=4 2> /dev/null | \
425 hexdump -e '"" 1/4 "%d" "\n"'
426 }
428 # output floppy images set
429 floppysetcat()
430 {
431 KERNEL="$1"
432 INITRD="$2"
433 shift 2
434 CMDLINE="$@"
436 # bzImage offsets
437 SetupSzOfs=497
438 SyssizeOfs=500
439 CodeAdrOfs=0x214
440 RamfsAdrOfs=0x218
441 RamfsLenOfs=0x21C
442 ArgPtrOfs=0x228
444 # boot+setup address
445 SetupBase=0x90000
447 stacktop=0x9E00
449 bs=/tmp/bs$$
451 # Get and patch boot sector
452 dd if=$KERNEL bs=512 count=1 of=$bs 2> /dev/null
453 uudecode <<EOT | dd of=$bs conv=notrunc 2> /dev/null
454 begin-base64 644 -
455 /L+6nWgAkAcGF4n8McC5HQDzq1sfD6mg8X1ABlfFd3ixBvOlZWaPR3gGH8ZF
456 +D/6l1hB6DQBvgACA3QO6HYBWwseKAJ0LFNH6AoBXuhmAbAgzRCwCM0QTuhl
457 ATwIdAOIBK05NigCdPDoPgE8CnXgiHz+ieb/TBD/TBi/9AGBTRz/gMdFMACc
458 sBCxBUi0k4lEHLABiUQUmGaY0+BIZgMFZtPoaAAQB7+AACn4nHMCAccx21BW
459 6J4AXrkAgLSH/kQczRVYnXfcoRoCvxwCsQk4RBxyuJPNE+oAACCQsEYoyL7b
460 AejSAF3rI4D5E3IEOMF3a4D+AnIEOOZ3bGCB/QAGdCoGUlFTlrQCULEGtQTB
461 xQSwDyHoBJAnFEAn6IwA/s117LAgzRDitOiWAJjNE2FSUCjIdwKwAZg5+HIC
462 ifhQtALNE5VeWFpyoJVBjuGAxwJPdFFOdfSM4ZU4wXVFiMj+xrEBOOZ1O4j0
463 /sW2AID9UHIwOi7wAXIqtQBgvt4B/kQMU+gxAFvoOAB1FlKYzRO4AQLNE1rQ
464 1Dpk/nXqRgjkdeVh64sWB7AxLAO0DrsHAM0QPA1088OwDejv/6wIwHX4w79s
465 BLFbZQINuA0BZToNdArNFnT0mM0Wju9Hw1g6AEluc2VydCBkaXNrIDEuBw0A
466 AA==
467 ====
468 EOT
470 # Get setup
471 setupsz=$(getlong $SetupSzOfs $bs)
472 setupszb=$(( $setupsz & 255 ))
473 dd if=$KERNEL bs=512 skip=1 count=$setupszb 2> /dev/null >> $bs
475 # Store cmdline after setup
476 if [ -n "$CMDLINE" ]; then
477 echo -n "$CMDLINE" | dd bs=512 count=1 conv=sync 2> /dev/null >> $bs
478 storelong ArgPtrOfs $(( $SetupBase + $stacktop )) $bs
479 fi
481 # Compute initramfs size
482 initrdlen=0
483 padding=0
484 for i in $( echo $INITRD | sed 's/,/ /' ); do
485 [ -s "$i" ] || continue
486 initrdlen=$(( $initrdlen + $padding ))
487 padding=$(stat -c %s $i)
488 initrdlen=$(( $initrdlen + $padding ))
489 padding=$(( 4096 - ($padding & 4095) ))
490 [ $padding -eq 4096 ] && padding=0
491 done
492 Ksize=$(( $(getlong $SyssizeOfs $bs)*16 ))
493 Kpad=$(( (($Ksize+4095)/4096)*4096 - Ksize ))
494 if [ $initrdlen -ne 0 ]; then
495 Kbase=$(getlong $CodeAdrOfs $bs)
496 storelong $RamfsAdrOfs \
497 $(( (0x1000000 - $initrdlen) & 0xFFFF0000 )) $bs
498 storelong $RamfsLenOfs $initrdlen $bs
499 fi
501 # Output boot sector + setup + cmdline
502 dd if=$bs 2> /dev/null
504 # Output kernel code
505 dd if=$KERNEL bs=512 skip=$(( $setupszb + 1 )) 2> /dev/null
507 # Pad to next sector
508 Kpad=$(( 512 - ($(stat -c %s $KERNEL) & 511) ))
509 [ $Kpad -eq 512 ] || dd if=/dev/zero bs=1 count=$Kpad 2> /dev/null
511 # Output initramfs
512 padding=0
513 for i in $( echo $INITRD | sed 's/,/ /' ); do
514 [ -s "$i" ] || continue
515 [ $padding -ne 0 ] && dd if=/dev/zero bs=1 count=$padding
516 dd if=$i 2> /dev/null
517 padding=$(( 4096 - ($(stat -c %s $i) & 4095) ))
518 [ $padding -eq 4096 ] && padding=0
519 done
521 # Cleanup
522 rm -f $bs
523 }
525 # Create boot floppy set from kernel, initrd & cmdline
526 floppyset()
527 {
528 floppysetcat "$@" | split -b 1440k /dev/stdin floppy$$
529 i=1
530 ls floppy$$* | while read file ; do
531 output=$(printf "fd%03d.img" $i)
532 cat $file /dev/zero | dd bs=1k count=1440 of=$output conv=sync 2> /dev/null
533 rm -f $file
534 i=$(( $i + 1 ))
535 done
536 }
538 # Create boot floppy set from a SliTaz ISO image
539 floppysetfromiso()
540 {
541 mkdir /tmp/iso$$
542 mount -o loop,ro $1 /tmp/iso$$
543 rootfs="$(ls /tmp/iso$$/boot/rootfs*z 2> /dev/null | tail -1)"
544 bzimage=/tmp/iso$$/boot/bzImage
545 if [ -z "$rootfs" -o ! -s $bzimage ]; then
546 umount -d /tmp/iso$$
547 rm -rf /tmp/iso$$
548 echo "Not a SliTaz ISO image !"
549 return 1
550 fi
551 mkdir -p /tmp/rootfs$$/fs
552 n=1
553 for i in $(ls /tmp/iso$$/boot/rootfs*z | sort -r); do
554 mkdir /tmp/rootfs$$/$n
555 ln -s $i /tmp/rootfs$$/$n
556 n=$(($n + 1))
557 done
558 echo "Unpacking rootfs..."
559 ( zcat $rootfs 2> /dev/null | unlzma -c $rootfs ) | \
560 ( cd /tmp/rootfs$$/fs ; cpio -idm > /dev/null )
561 if [ $(unlzma -c $rootfs 2> /dev/null| wc -c) -gt $(stat -c %s $rootfs) ]; then
562 if [ $(du -ck $rootfs $bzimage | awk 'END { print $1 }') -gt 15296 ]; then
563 # The rootfs.gz file is too big, extract a minimum bootfs with busybox stuff
564 echo "Extracting bootfs..."
565 mv /tmp/rootfs$$/fs /tmp/rootfs$$/fs0
566 for i in lib bin sbin usr/bin usr/sbin ; do
567 mkdir -p /tmp/rootfs$$/fs/$i
568 done
569 cd /tmp/rootfs$$/fs0
570 dir=$(echo lib/modules/*/kernel/drivers/block)
571 [ -d $dir ] && mkdir -p ../fs/$dir
572 [ -f $dir/floppy.ko.gz ] && mv $dir/floppy.ko.gz ../fs/$dir
573 for i in dev init mnt proc sys tmp ; do
574 mv $i ../fs
575 done
576 mv lib/ld-* ../fs/lib
577 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so bin/busybox | \
578 awk '/\/lib\/lib/ { print $3 }' | while read lib ; do
579 while [ -L .$lib ]; do
580 local target
581 target="$(readlink ".$lib")"
582 case "$target" in
583 /*) ;;
584 *) target="$(dirname $lib)/$target" ;;
585 esac
586 mv ".$lib" ../fs/lib
587 lib="$target"
588 done
589 mv ".$lib" ../fs/lib
590 done
591 for i in $(bin/busybox | awk '{ if (s) printf "%s",$0 }
592 /Currently/ { s=1 }' | sed 's/,//g'); do
593 for j in bin sbin usr/bin usr/sbin ; do
594 [ -e $j/$i ] && mv $j/$i ../fs/$j/$i
595 done
596 done
597 mv bin/busybox ../fs/bin
598 [ -e ../fs/bin/cpio ] || mv bin/cpio ../fs/bin
599 rm -f ../1/*
600 find | cpio -o -H newc | lzma e ../1/rootfs.gz -si
601 cd - > /dev/null
602 rm -rf /tmp/rootfs$$/fs0
603 else
604 # The rootfs.gz file fits in 15MB, no need to split it.
605 rm -rf /tmp/rootfs$$/1
606 fi
607 else
608 # This is a loram rootfs.gz, extract loram bootstrap
609 echo "Splitting loram rootfs..."
610 offset=$(awk '/07070100/ { o+=index($0,"07070100"); print int(o/4) ; exit } { o+=1+length() }' < $rootfs)
611 dd if=$rootfs skip=$(($offset / 1024)) bs=4k count=1 2> /dev/null | \
612 dd skip=$(($offset % 1024)) bs=4 of=/tmp/rootfs$$/1/root 2> /dev/null
613 dd if=$rootfs skip=$((1 + ($offset / 1024) )) bs=4k \
614 >> /tmp/rootfs$$/1/root 2> /dev/null
615 rm -f /tmp/rootfs$$/1/rootfs*
616 fi
617 # Create extra rootfs floppies
618 for i in /tmp/rootfs$$/[1-9]*/root* ; do
619 [ -f $i ] || continue
620 echo "Creating floppies for rootfs $(basename $(dirname $i) )..."
621 case "$(dd if=$i bs=1 count=4 2> /dev/null)" in
622 0707) cat $i ;;
623 *) zcat $i 2> /dev/null || unlzma -c $i ;;
624 esac | cpio -t > $(dirname $i)/files.list
625 sed -i '/ blocks$/d' $(dirname $i)/files.list
626 x=$(readlink $i)
627 [ -n "$x" ] || x=$i
628 pad=$(( $(stat -c %s $x ) % 1474560 ))
629 [ $pad -ne 0 ] && pad=$(( 1474560 - $pad ))
630 dd if=/dev/zero bs=1 count=$pad 2> /dev/null | cat $i - | \
631 split -b 1440k /dev/stdin $(dirname $i)/floppy
632 done
633 selection="$(grep -s append /tmp/iso$$/boot/isolinux/common.cfg | sed 's/.*append //')"
634 [ -n "$selection" ] || selection="0 slitaz"
635 set -- $selection
636 selection=""
637 while [ -n "$2" ]; do
638 [ ! -d /tmp/rootfs$$/1 -a -z "$4" ] && break
639 case "$1" in
640 *G) selection="$2 $(( ${1%G} * 1024 * 1024 )) $selection" ;;
641 *M) selection="$2 $(( ${1%M} * 1024 )) $selection" ;;
642 *) selection="$2 $1 $selection" ;;
643 esac
644 shift 2
645 done
646 echo "Creating /init ..."
647 base=100
648 set -- $selection
649 for i in /tmp/rootfs$$/[1-9]* ; do
650 [ -d $i ] || continue
651 while read file; do
652 [ -e $i/../fs/$file ] && continue
653 [ $(grep -- "$file" $i/../*/files.list | wc -l) -eq 1 ] &&
654 break
655 done < $i/files.list
656 printf "%s %s %03d %d %s %s\n" \
657 $1 $2 $base $(ls $i/floppy* | wc -l) $file \
658 $(cat $i/floppy* | md5sum - | awk '{print $1}')
659 base=$(($base + 100))
660 shift 2
661 done | buildinit /tmp/rootfs$$/fs
662 cmdline="$(grep 'append *initrd' /tmp/iso$$/boot/isolinux/isolinux.cfg | tail -n 1 | sed 's/.*gz //')"
663 ( cd /tmp/rootfs$$/fs ; find | cpio -o -H newc ) | lzma e /tmp/rootfs$$/rootfs -si
664 echo "Creating first stage boot floppies..."
665 floppyset $bzimage /tmp/rootfs$$/rootfs "$cmdline"
666 base=100
667 for i in /tmp/rootfs$$/[1-9]* ; do
668 [ -d $i ] || continue
669 j=0
670 for f in $i/floppy* ; do
671 mv $f $(printf "fd%03d.img" $(( $base + $j )) )
672 j=$(($j + 1))
673 done
674 base=$(($base + 100))
675 done
676 rm -rf /tmp/rootfs$$
677 umount -d /tmp/iso$$
678 rm -rf /tmp/iso$$
679 }
681 # Show new boot floppy set
682 dialogwritefloppyset()
683 {
684 if ! list_floppy check; then
685 du -h fd???.img
686 return
687 fi
688 while true; do
689 exec 3>&1
690 IMAGE=`$DIALOG --title " Write floppy image " \
691 --backtitle "Boot floppy set creation on $DEVICE" --clear \
692 --colors --radiolist "
693 Insert a blank floppy in drive and
694 select the floppy image you want to write.
695 " 18 46 46 \
696 $(on="on"; for i in fd???.img; do echo "$i $(du -h $i | cut -f1) $on "; on="off"; done) 2>&1 1>&3`
697 retval=$?
698 exec 3>&-
699 check_retval
700 dd if=$IMAGE of=$DEVICE
701 done
702 }
704 dialognofloppyset()
705 {
706 cat << EOT
707 The boot loader can't load the kernel and the initramfs in the first 16MB
708 of RAM. The total size exceeds 15MB. No floppy image is created.
709 EOT
710 }
712 # Check for iso 9660 image
713 isiso()
714 {
715 mkdir /tmp/iso$$
716 mount -o loop,ro $1 /tmp/iso$$ 2> /dev/null
717 status=$?
718 umount -d /tmp/iso$$ 2> /dev/null
719 rm -rf /tmp/iso$$
720 return $status
721 }
723 dialogfloppyset()
724 {
725 : ${DIALOG=dialog --timeout 60}
726 while true; do
727 exec 3>&1
728 KERNEL=`$DIALOG --title " Select a Linux kernel or a SliTaz iso " \
729 --backtitle "Boot floppy set creation on $DEVICE" --clear \
730 --colors --fselect "$PWD" 10 70 \
731 2>&1 1>&3`
732 retval=$?
733 exec 3>&-
734 check_retval
735 [ -f $KERNEL ] && break
736 done
737 if isiso $KERNEL ; then
738 bootfloppybox call mkisofloppies $KERNEL
739 dialogwritefloppyset
740 return
741 fi
742 exec 3>&1
743 INITRD=`$DIALOG --title " Select an Initramfs " \
744 --backtitle "Boot floppy set creation on $DEVICE" --clear \
745 --colors --fselect "$PWD" 10 70 \
746 2>&1 1>&3`
747 retval=$?
748 exec 3>&-
749 check_retval
750 [ -f "$INITRD" ] || INITRD=""
751 exec 3>&1
752 CMDLINE=`$DIALOG --title " Enter boot command line " \
753 --backtitle "Boot floppy set creation on $DEVICE" --clear \
754 --colors --inputbox "Kernel command line" 10 70 "rw root=/dev/null autologin" \
755 2>&1 1>&3`
756 retval=$?
757 exec 3>&-
758 check_retval
759 bootfloppybox call mkfloppies "$KERNEL" "$INITRD" "$CMDLINE" &&
760 dialogwritefloppyset ||
761 dialognofloppyset
762 }
764 #
765 # Create floppy image set
766 #
767 export IMAGE_SET='
768 <window title="Image set generator" icon-name="gtk-floppy">
769 <vbox>
770 <text use-markup="true">
771 <label>
772 "
773 <b>Create a boot floppy set</b>
774 "
775 </label>
776 </text>
777 <notebook labels="Slitaz only|Any Linux">
778 <frame Slitaz only (no size limit)>
779 <vbox>
780 <text wrap="false" width-chars="44" use-markup="true">
781 <label>
782 "
783 Slitaz uses a floppy boot flavor as a first
784 stage boot to break the tiny loader 15MB limit.
785 "
786 </label>
787 </text>
788 <hbox>
789 <text use-markup="true">
790 <label>"<b>Slitaz ISO : </b>"</label>
791 </text>
792 <entry accept="filename">
793 <label>Select a Slitaz ISO image</label>
794 <variable>ISO</variable>
795 </entry>
796 <button>
797 <input file stock="gtk-open"></input>
798 <action type="fileselect">ISO</action>
799 </button>
800 </hbox>
801 <hbox>
802 <text use-markup="true">
803 <label>"<b>Output directory : </b>"</label>
804 </text>
805 <entry accept="directory">
806 <label>Select output directory</label>
807 <variable>FILE_DIRECTORY</variable>
808 <default>/tmp</default>
809 </entry>
810 <button>
811 <input file stock="gtk-open"></input>
812 <action type="fileselect">FILE_DIRECTORY</action>
813 </button>
814 </hbox>
815 <hbox>
816 <button>
817 <input file icon="forward"></input>
818 <label>Create image set from ISO boot</label>
819 <action>cd $FILE_DIRECTORY; bootfloppybox call mkisofloppiesxterm $ISO</action>
820 <action type="closewindow">IMAGE_SET</action>
821 </button>
822 </hbox>
823 </vbox>
824 </frame>
825 <frame Any Linux distribution (max total size 14-15MB)>
826 <vbox>
827 <text wrap="false" width-chars="44" use-markup="true">
828 <label>
829 "
830 The total size of the kernel and the initramfs must be
831 lower than 14-15MB due to the tiny boot loader design.
832 "
833 </label>
834 </text>
835 <hbox>
836 <text use-markup="true">
837 <label>"<b>Kernel : </b>"</label>
838 </text>
839 <entry accept="filename">
840 <label>Select a linux kernel</label>
841 <variable>KERNEL</variable>
842 </entry>
843 <button>
844 <input file stock="gtk-open"></input>
845 <action type="fileselect">KERNEL</action>
846 </button>
847 </hbox>
848 <hbox>
849 <text use-markup="true">
850 <label>"<b>Initramfs : </b>"</label>
851 </text>
852 <entry accept="filename">
853 <label>Select an initramfs/initrd file</label>
854 <variable>INITRD</variable>
855 </entry>
856 <button>
857 <input file stock="gtk-open"></input>
858 <action type="fileselect">INITRD</action>
859 </button>
860 </hbox>
861 <hbox>
862 <text use-markup="true">
863 <label>"<b>Cmdline : </b>"</label>
864 </text>
865 <entry>
866 <label>Enter kernel arguments</label>
867 <variable>CMDLINE</variable>
868 <default>rw root=/dev/null autologin</default>
869 </entry>
870 </hbox>
871 <hbox>
872 <text use-markup="true">
873 <label>"<b>Output directory : </b>"</label>
874 </text>
875 <entry accept="directory">
876 <label>Select output directory</label>
877 <variable>OUTPUT_DIRECTORY</variable>
878 <default>/tmp</default>
879 </entry>
880 <button>
881 <input file stock="gtk-open"></input>
882 <action type="fileselect">OUTPUT_DIRECTORY</action>
883 </button>
884 </hbox>
885 <hbox>
886 <button>
887 <input file icon="forward"></input>
888 <label>Create image set</label>
889 <action>cd $OUTPUT_DIRECTORY; bootfloppybox call mkfloppies "$KERNEL" "$INITRD" "$CMDLINE"</action>
890 <action type="closewindow">IMAGE_SET</action>
891 </button>
892 </hbox>
893 </vbox>
894 </frame>
895 </notebook>
896 <hbox>
897 <button>
898 <input file icon="gtk-close"></input>
899 <action type="closewindow">IMAGE_SET</action>
900 </button>
901 </hbox>
902 </vbox>
903 </window>
904 '
906 #
907 # Read/write floppy images
908 #
909 export FLOPPY_IMAGE='
910 <window title="Floppy image manager" icon-name="gtk-floppy">
911 <vbox>
912 <frame Floppy disk drive>
913 <hbox>
914 <text use-markup="true">
915 <label>"<b>Device : </b>"</label>
916 </text>
917 <combobox>
918 <variable>DEVICE</variable>'
919 FLOPPY_DEV=""
920 for i in $(list_floppy); do
921 FLOPPY_DEV="$FLOPPY_DEV
922 <item>/dev/$i</item>"
923 done
924 FLOPPY_IMAGE="$FLOPPY_IMAGE$FLOPPY_DEV
925 </combobox>
926 <button>
927 <label>Format floppy</label>
928 <input file icon=\"media-floppy\"></input>
929 <action>fdformat -n $DEVICE</action>
930 </button>
931 </hbox>
932 </frame>
933 <frame Floppy image file>
934 <hbox>
935 <text use-markup=\"true\">
936 <label>\"<b>File : </b>\"</label>
937 </text>
938 <entry accept=\"filename\">
939 <label>Select a floppy image</label>
940 <variable>IMAGE</variable>
941 </entry>
942 <button>
943 <input file stock=\"gtk-open\"></input>
944 <action type=\"fileselect\">IMAGE</action>
945 </button>
946 </hbox>
947 </frame>
948 <hbox>
949 <button>
950 <input file icon=\"reload\"></input>
951 <label>Create image set</label>
952 <action type=\"launch\">IMAGE_SET</action>
953 </button>
954 <button>
955 <input file icon=\"go-jump\"></input>
956 <label>Write image to floppy</label>
957 <action>dd if=\$IMAGE of=\$DEVICE</action>
958 </button>
959 <button>
960 <input file icon=\"undo\"></input>
961 <label>Get floppy image</label>
962 <action>dd if=\$DEVICE of=\$IMAGE</action>
963 </button>
964 <button>
965 <input file icon=\"gtk-close\"></input>
966 <action type=\"closewindow\">FLOPPY_IMAGE</action>
967 </button>
968 </hbox>
969 </vbox>
970 </window>
971 "
973 gtkdialogshowfloppyset()
974 {
975 #
976 # Show floppy image set
977 #
978 IMAGE_SHOW='
979 <window title="Image set" icon-name="gtk-floppy">
980 <vbox>
981 <text use-markup="true">
982 <label>
983 "
984 <b>Boot floppy images</b>
985 "
986 </label>
987 </text>
988 <tree>
989 <width>50</width><height>140</height>
990 <label>Size|File</label>
991 <input>du -h fd???.img | sed "s/\t/|/" </input>
992 </tree>
993 <hbox>
994 '
995 [ 0$1 -gt $((15 * 1024 * 1024)) ] && IMAGE_SHOW="$IMAGE_SHOW
996 <frame WARNING>
997 <text>
998 <label>
999 \"This floppy set breaks the 15MB limit ($1 bytes).
1000 It may not be able to complete the boot process.\"
1001 </label>
1002 </text>
1003 </frame>
1004 </hbox>
1005 <hbox>
1007 list_floppy check && IMAGE_SHOW="$IMAGE_SHOW
1008 <button>
1009 <input file icon=\"media-floppy\"></input>
1010 <label>Manage images</label>
1011 <action type=\"launch\">FLOPPY_IMAGE</action>
1012 </button>
1014 IMAGE_SHOW="$IMAGE_SHOW
1015 <button>
1016 <input file icon=\"gtk-close\"></input>
1017 <action type=\"closewindow\">IMAGE_SET</action>
1018 </button>
1019 </hbox>
1020 </vbox>
1021 </window>
1023 export IMAGE_SHOW
1024 gtkdialog --program=IMAGE_SHOW
1027 while true; do
1029 if [ "$1" == "call" ]; then
1030 case "$2" in
1031 mkmenu) mkmenu $3;;
1032 mkisofloppiesxterm)
1033 shift 2
1034 xterm -geometry 80x16 -title "Build boot floppies from ISO" \
1035 -e "$0 call mkisofloppies $@ ; echo -e \"----\nENTER to continue...\" && read close"
1036 gtkdialogshowfloppyset
1037 ;;
1038 mkisofloppies)
1039 shift 2
1040 floppysetfromiso $@
1041 ;;
1042 mkfloppies)
1043 shift 2
1044 floppyset "$@"
1045 sz=$(cat fd???.img | wc -c)
1046 if [ -n "$XAUTHORITY" ]; then
1047 gtkdialogshowfloppyset $sz
1048 else
1049 if [ $sz -gt $((15 * 1024 * 1024)) ]; then
1050 cat <<EOT
1051 This floppy set breaks the 15MB limit ($sz bytes).
1052 It may not be able to complete the boot process.
1053 EOT
1054 fi
1055 fi
1056 ;;
1057 install)
1058 DIR=/tmp/mkbootfloppy$$
1059 mkdir -p $DIR
1060 DEVICE=$4
1061 file=$5
1062 case "$3" in
1063 dialog*)
1064 shift 2
1065 $@
1066 ;;
1067 grub*)
1068 mkdir -p $DIR/boot/grub
1069 [ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ] \
1070 && cat /usr/share/boot/btmgr /dev/zero | \
1071 dd bs=18k count=80 | gzip -9 > \
1072 $DIR/boot/btmgr.gz \
1073 && unlzma -c /usr/share/boot/memdisk.lzma > \
1074 $DIR/boot/memdisk
1075 [ -f /usr/share/boot/plpbt.bin ] \
1076 && cp /usr/share/boot/plpbt.bin $DIR/boot
1077 [ -f /usr/share/boot/etherboot ] \
1078 && cp /usr/share/boot/etherboot $DIR/boot
1079 [ -f /boot/gpxe ]\
1080 && cp /boot/gpxe $DIR/boot
1081 [ -f /usr/share/boot/memtest.lzma -a \
1082 -f /usr/share/boot/memdisk.lzma ] \
1083 && unlzma -c /usr/share/boot/memtest.lzma | \
1084 cat - /dev/zero | dd bs=18k count=80 | \
1085 gzip -9 > $DIR/boot/memtest.gz \
1086 && unlzma -c /usr/share/boot/memdisk.lzma > \
1087 $DIR/boot/memdisk
1088 install_grub $DIR $3
1089 ;;
1090 *)
1091 case "$file" in
1092 *.lzma) action="unlzma -c";;
1093 *.gz) action="zcat";;
1094 *) action="cat";;
1095 esac
1096 case "$DEVICE" in
1097 /dev/*) $action $file > $DEVICE;;
1098 flopp*) $action $file | cat - /dev/zero | \
1099 dd bs=18k count=80 > boot.fd;;
1100 cdrom*)
1101 mkdir -p $DIR/boot/grub
1102 case "$3" in
1103 btmgr|memtest)
1104 $action $file | cat - /dev/zero | \
1105 dd bs=18k count=80 | \
1106 gzip -9 > $DIR/boot/$3.gz
1107 unlzma -c /usr/share/boot/memdisk.lzma \
1108 > $DIR/boot/memdisk
1109 cat > /tmp/floppybox.grub.menu << EOT
1110 # grub menu
1111 timeout 0
1112 title $3
1113 kernel /boot/memdisk floppy c=80 h=2 s=18
1114 initrd /boot/$3.gz
1115 EOT
1116 ;;
1117 *) $action $file > $DIR/boot/$3
1118 cat > /tmp/floppybox.grub.menu << EOT
1119 # grub menu
1120 timeout 0
1121 title $3
1122 kernel /boot/$3
1123 EOT
1124 ;;
1125 esac
1126 install_grub $DIR grub
1127 ;;
1128 esac
1129 ;;
1130 esac
1131 rm -rf $DIR
1132 ;;
1133 get-plop)
1134 mkdir -p /tmp/get-plop$$
1135 PLOP_URL=http://mirror.slitaz.org/boot/plpbt.bin
1136 wget -O - $PLOP_URL > /tmp/get-plop$$/plpbt.bin
1137 VERSION="$(strings /tmp/get-plop$$/plpbt.bin \
1138 | grep 'Boot Manager v' | sed 's/.* v\([0-9\.]*\) .*/\1/')"
1139 mkdir -p $(dirname /tmp/get-plop$$/plop-$VERSION/fs/$3)
1140 mv /tmp/get-plop$$/plpbt.bin \
1141 /tmp/get-plop$$/plop-$VERSION/fs/$3
1142 if [ -s /tmp/get-plop$$/plop-$VERSION/fs/$3 ]; then
1143 cat > /tmp/get-plop$$/plop-$VERSION/receipt <<EOT
1144 PACKAGE="plop"
1145 VERSION="$VERSION"
1146 CATEGORY="non-free"
1147 SHORT_DESC="Plop boot manager."
1148 WEB_SITE="http://www.plop.at/en/bootmanager.html"
1149 EOT
1150 ( cd /tmp/get-plop$$ ; tazpkg pack plop-$VERSION )
1151 tazpkg install /tmp/get-plop$$/plop-$VERSION.tazpkg
1152 fi
1153 rm -rf /tmp/get-plop$$
1154 ;;
1155 *) echo "Invalid command $0 $@" 1>&2
1156 exit 1;;
1157 esac
1158 exit 0
1159 fi
1161 if [ -z "$XAUTHORITY" ]; then
1163 : ${DIALOG=dialog --timeout 60}
1165 DEVICE=/dev/fd0
1166 list_floppy check || DEVICE="floppy"
1167 while true; do
1168 exec 3>&1
1169 ID_SOURCE=`$DIALOG --title " Choose a boot floppy " \
1170 --backtitle "Boot Floppy Creation on $DEVICE" --clear \
1171 --extra-button --extra-label "Change floppy" \
1172 --colors --radiolist "
1173 Create a floppy or a cdrom to boot a LiveCD in a PXE network...
1174 May need a floppy disk in drive. Erase the whole floppy disk.
1175 " 18 70 50\
1176 FloppySet "Boot Slitaz with floppies only." on \
1177 SmartBtmgr "Boot any partition or ATAPI CD-ROM." off \
1178 Plop "Boot USB harddisk floppy or CD/DVD." off \
1179 Etherboot "Replacement for proprietary PXE ROMs." off \
1180 gPXE "Boot from http://boot.slitaz.org/" off \
1181 Memtest86+ "Memory failures detection tool." off \
1182 Grub4DOS "Enhanced grub version supporting NTFS." off \
1183 Grub "Boot loader with command shell." off \
1184 2>&1 1>&3`
1185 retval=$?
1186 exec 3>&-
1187 check_retval
1188 if [ "$retval" = "3" ]; then
1189 select_floppy
1190 continue;
1191 fi
1192 while read key file pkg; do
1193 [ "$key" = "$ID_SOURCE" ] || continue
1194 if [ ! -f "$file" ]; then
1195 $DIALOG --title " Install package " --colors \
1196 --backtitle "Boot Floppy Creation" --clear \
1197 --yes-label "Install" \
1198 --no-label "Quit" \
1199 --yesno "The package $pkg is not yet installed. Install it ?" 18 70
1200 retval=$?
1201 if [ "$pkg" = "plop" ]; then
1202 bootfloppybox call get-plop $file
1203 else
1204 tazpkg get-install $pkg
1205 fi
1206 fi
1207 bootfloppybox call install "$pkg" "$DEVICE" "$file"
1208 exit 0
1209 done <<EOT
1210 FloppySet /bin/dd dialogfloppyset
1211 SmartBtmgr /usr/share/boot/btmgr btmgr
1212 Plop /usr/share/boot/plpbt.bin plop
1213 Etherboot /usr/share/boot/etherboot etherboot
1214 gPXE /boot/gpxe gpxe
1215 Memtest86+ /usr/share/boot/memtest.lzma memtest
1216 Grub4DOS /usr/share/boot/grldr.lzma grub4dos
1217 Grub /usr/sbin/grub grub
1218 EOT
1219 done
1220 fi
1222 # Describe gPXE arguments.
1224 export HELP='
1225 <window title="gPXE forced url" icon-name="gtk-floppy">
1226 <vbox>
1227 <text use-markup="true">
1228 <label>"
1229 <b>Web boot parameters</b>"
1230 </label>
1231 </text>
1232 <frame>
1233 <text wrap="true" width-chars="58" use-markup="true">
1234 <label>
1235 "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.
1237 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>.
1239 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>
1241 The <i>nodhcp</i> keyword avoids dhcp timeouts and the <i>url=</i> keyword is optional when the url is the only one argument.
1243 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.
1245 </label>
1246 </text>
1247 </frame>
1248 </vbox>
1249 </window>
1252 # Write bootfloppy image to floppy device.
1254 BOOT_DIALOG='
1255 <window title="bootfloppybox" icon-name="gtk-floppy">
1256 <vbox>
1258 <text use-markup="true">
1259 <label>
1261 <b>SliTaz - Bootfloppybox</b>"
1262 </label>
1263 </text>
1264 <text wrap="false" width-chars="44" use-markup="true">
1265 <label>
1267 Create a floppy or a cdrom to boot a LiveCD in a PXE network or the WEB...
1268 May need a floppy disk in drive. Erase the whole floppy disk.
1270 </label>
1271 </text>
1273 <frame Floppy disk drive>
1274 <hbox>
1275 <text use-markup="true">
1276 <label>"<b>Device : </b>"</label>
1277 </text>
1278 <combobox>
1279 <variable>DEVICE</variable>'
1280 FLOPPY_DEV=""
1281 for i in $(list_floppy); do
1282 FLOPPY_DEV="$FLOPPY_DEV
1283 <item>/dev/$i</item>"
1284 done
1285 BOOT_DIALOG="$BOOT_DIALOG$FLOPPY_DEV
1286 <item>floppy image (boot.fd)</item>
1287 <item>cdrom image (boot.iso)</item>
1288 </combobox>"
1289 if [ -n "$FLOPPY_DEV" ]; then
1290 tmp='
1291 <button>
1292 <label>Format floppy</label>
1293 <input file icon="media-floppy"></input>
1294 <action>case "$DEVICE" in /dev/*) fdformat -n $DEVICE;; esac</action>
1295 </button>'
1296 BOOT_DIALOG="$BOOT_DIALOG$tmp"
1297 fi
1298 tmp='
1299 </hbox>
1300 </frame>
1301 <notebook labels="Set|LiveCD|USB|PXE Network|WEB Network|Memory Test|Windows|Expert">
1302 <frame Boot floppy set (many floppies)>
1303 <vbox>
1304 <hbox>
1305 <text wrap="true" width-chars="58" use-markup="true">
1306 <label>
1308 Only people without a CD-ROM, USB and Network should use a floppy set.
1309 The images are built from an ISO boot or from a Linux kernel, an initramfs
1310 and a boot command line. Non Slitaz boot floppy sets are limited to 15MB.
1312 </label>
1313 </text>
1314 </hbox>
1315 <hbox>
1316 <button>
1317 <label>Create image set</label>
1318 <input file icon="forward"></input>
1319 <action type="launch">IMAGE_SET</action>
1320 </button>
1321 </hbox>
1322 </vbox>
1323 </frame>
1325 BOOT_DIALOG="$BOOT_DIALOG$tmp"
1326 while read name file pkg desc; do
1327 tmp="<frame $name (single floppy)>
1328 <hbox>
1329 <text wrap=\"true\" width-chars=\"58\" use-markup=\"true\">
1330 <label>
1331 \"
1332 $(echo -e $desc)
1333 \"
1334 </label>
1335 </text>
1336 </hbox>
1337 <hbox>
1339 if [ -f $file ]; then
1340 if [ "$pkg" = "grub" -o "$pkg" = "grub4dos" ]; then
1341 tmp="$tmp
1342 <button>
1343 <label>Grub menu</label>
1344 <input file icon=\"accessories-text-editor\"></input>
1345 <action>bootfloppybox call mkmenu $pkg</action>
1346 <action type=\"lauch\">leafpad /tmp/floppybox.grub.menu</action>
1347 </button>
1349 elif [ "$pkg" = "etherboot" ]; then
1350 tmp="$tmp
1351 <button>
1352 <input file icon=\"browser\"></input>
1353 <label>Wiki</label>
1354 <action>browser http://doc.slitaz.org/en:guides:pxe &</action>
1355 </button>
1357 elif [ "$pkg" = "gpxe" ]; then
1358 tmp="$tmp
1359 <text wrap=\"true\" use-markup=\"true\">
1360 <label> \"<b>Boot URL:</b>\" </label>
1361 </text>
1362 <entry>
1363 <default>$(dd if=$file bs=1 skip=519 count=255 2>/dev/null | strings)</default>
1364 <variable>URL</variable>
1365 </entry>
1366 </hbox>
1367 <hbox>
1368 <button>
1369 <input file icon=\"browser\"></input>
1370 <label>Wiki</label>
1371 <action>browser http://doc.slitaz.org/en:guides:pxe &</action>
1372 </button>
1373 <button help>
1374 <action type=\"launch\">HELP</action>
1375 </button>
1376 <button>
1377 <label>Update</label>
1378 <input file icon=\"reload\"></input>
1379 <action>echo -n \"\$URL\" | cat - /dev/zero | dd conv=notrunc bs=1 count=255 seek=519 of=$file 2>/dev/null</action>
1380 </button>
1382 fi
1383 receipt=/var/lib/tazpkg/installed/$pkg/receipt
1384 if [ -f $receipt ]; then
1385 . $receipt
1386 tmp="$tmp
1387 <button>
1388 <input file icon=\"browser\"></input>
1389 <label>Web</label>
1390 <action>browser $WEB_SITE &</action>
1391 </button>
1393 fi
1394 tmp="$tmp
1395 <button>
1396 <label>Write floppy</label>
1397 <input file icon=\"forward\"></input>
1398 <action>bootfloppybox call install \"$pkg\" \"\$DEVICE\" \"$file\"</action>
1399 </button>
1400 </hbox>
1401 </frame>
1403 else
1404 tmp2="tazpkg get-install $pkg --forced"
1405 [ "$pkg" = "plop" ] && tmp2="bootfloppybox call get-plop $file"
1406 tmp="$tmp
1407 <text wrap=\"true\" width-chars=\"34\" use-markup=\"true\">
1408 <label>
1409 \"<i>The package <b>$pkg</b> is not yet installed</i>\"
1410 </label>
1411 </text>
1412 <button>
1413 <input file icon=\"go-jump\"></input>
1414 <label>Install</label>
1415 <action>[ -f /var/lib/tazpkg/packages.list ] || tazpkg recharge</action>
1416 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title \"$pkg install\" -e \"$tmp2 ; sleep 2\"</action>
1417 <action type=\"exit\">restart</action>
1418 </button>
1419 </hbox>
1420 </frame>
1422 fi
1423 BOOT_DIALOG="$BOOT_DIALOG$tmp"
1424 done <<EOT
1425 SmartBtmgr /usr/share/boot/btmgr btmgr This OS independent Smart Boot Manager can boot \\\\nany partition or ATAPI CD-ROM.
1426 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.
1427 Etherboot /usr/share/boot/etherboot etherboot This network bootloader provides a replacement \\\\nfor proprietary PXE or NBI ROMs.
1428 gPXE /boot/gpxe gpxe PXE / iSCSI / AoE network bootloader.
1429 Memtest86+ /usr/share/boot/memtest.lzma memtest Memory failures detection tool.
1430 Grub4DOS /usr/share/boot/grldr.lzma grub4dos Enhanced grub version supporting NTFS.
1431 Grub /usr/sbin/grub grub General purpose boot loader with command shell.
1432 EOT
1433 tmp='
1434 </notebook>
1435 <hbox>
1437 BOOT_DIALOG="$BOOT_DIALOG$tmp"
1438 if [ -e /dev/cdrom ]; then
1439 tmp='
1440 <button>
1441 <input file icon="media-cdrom"></input>
1442 <label>Burn cdrom image</label>
1443 <action>burnbox</action>
1444 </button>
1446 BOOT_DIALOG="$BOOT_DIALOG$tmp"
1447 fi
1448 if list_floppy check; then
1449 tmp='
1450 <button>
1451 <input file icon="media-floppy"></input>
1452 <label>Manage floppy image</label>
1453 <action type="launch">FLOPPY_IMAGE</action>
1454 </button>
1456 BOOT_DIALOG="$BOOT_DIALOG$tmp"
1457 fi
1458 tmp='
1459 <button>
1460 <input file icon="exit"></input>
1461 <label>Exit</label>
1462 <action type="exit">Exit</action>
1463 </button>
1464 </hbox>
1466 </vbox>
1467 </window>
1469 BOOT_DIALOG="$BOOT_DIALOG$tmp"
1470 export BOOT_DIALOG
1472 # Only root can create floppy.
1473 check_root
1474 gtkdialog --program=BOOT_DIALOG | grep -q 'EXIT="restart"' && continue
1475 rm -f /tmp/floppybox.grub.menu
1476 exit 0
1477 done