wok view syslinux/stuff/iso2exe/init @ rev 21801

linld/iso2exe: remove non slitaz dos boot
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Aug 10 18:47:30 2019 +0200 (4 months ago)
parents 04ffefac5707
children 2ca609c01117
line source
1 #!/bin/sh
3 DIALOG=dialog
5 ddq()
6 {
7 dd $@ 2>/dev/null
8 }
10 get()
11 {
12 od -v -j $1 -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An $2 2>/dev/null ||
13 hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %u\n\"" $2
14 }
16 getarg()
17 {
18 sed "/$1=/!d;s/.*$1=\\([^ ]*\\).*/\\1/" /proc/cmdline
19 }
21 clear()
22 {
23 echo -e "\x1B[1;1H\x1B[J"
24 }
26 xless()
27 {
28 [ $(wc -l < "$1") -gt 22 ] &&
29 sed 's/..3.;4.m/===/g;$s/.*/&\n---\nPress q to continue/' "$1" | less ||
30 { cat "$1"
31 [ "$2" ] || return
32 echo -e "$2"
33 read n
34 }
35 }
37 tinydialog()
38 {
39 clear
40 label=""
41 while [ "$1" ]; do
42 case "$1" in
43 --title) title=" \x1B[30;47m$2\x1B[37;40m\n"
44 echo -e $title; shift;;
45 --yes-label) label="$2"; shift;;
46 --textbox)
47 xless "$2" "\nPress RETURN to continue."
48 break;;
49 --gauge)
50 t=" "
51 echo -e "$t$2\n"
52 while read pct; do
53 s=" "
54 s="$s$pct%$s"
55 pct=$((($pct*63)/100))
56 echo -en "\r$t\x1B[30;47m$(echo "$s" | cut -c-$pct)\x1B[37;40m$(echo "$s" | cut -c$(($pct+1))-)"
57 done
58 break;;
59 --yesno)
60 while true; do
61 clear
62 echo "$2" | sed 's/\\n\\n/\\n/g;s/\\n/\n/g'
63 echo -en " <- 1:${label:-Yes} 2:Cancel\r"
64 read x
65 case "$x" in
66 ''|Y*|y*|1) return 0;;
67 N*|n*|2|0) return 1;;
68 esac
69 done;;
70 --menu|--radiolist)
71 [ "$1" = "--menu" ] && shft=2 || shft=3
72 label=""
73 [ "$2" ] && label="\n$2"
74 shift 5
75 echo -e "$title$label\n0 Cancel" > /tmp/data
76 n=1
77 while [ "$1" ]; do
78 eval key_$n='$1'
79 echo "$((n++)) $2"
80 shift $shft
81 done >> /tmp/data
82 while ! grep -q "^$n " /tmp/data; do
83 clear
84 xless /tmp/data
85 echo -en "\n <- Enter the selection number\r"
86 read n
87 done 2>/dev/null
88 rm -f /tmp/data
89 [ $n -eq 0 ] && return 1
90 eval echo -n \$key_$n 1>&2
91 return 0;;
92 esac
93 shift
94 done
95 }
97 mount_proc()
98 {
99 mount -t proc /proc /proc
100 mount -t sysfs /sys /sys
101 udevd --daemon 2>/dev/null && udevadm trigger && sleep 5
102 }
104 umount_proc()
105 {
106 killall udevd 2>/dev/null
107 umount /sys/fs/fuse/connections 2>/dev/null
108 umount /sys
109 umount /proc
110 }
112 bytes2bin()
113 {
114 for i in $@; do
115 printf '\\\\x%02X' $(($i&255))
116 done | xargs echo -en
117 }
119 words2bin()
120 {
121 for i in $@; do
122 printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255))
123 done | xargs echo -en
124 }
126 gettazboot()
127 {
128 echo -e "\nCreating $(basename $1) ..."
129 X=$(($(get 20 /mnt/$ISO) - 0xC0))
130 [ $X -lt 30000 ] && X=$((0x7FF0))
131 O=$(($(get 64 /mnt/$ISO) - 0xC0))
132 L=$(($X - $(get 24 /mnt/$ISO) - $O))
133 S=$((32+$L))
134 P=$((($S+511)/512))
135 E=$((4096-(32*$P)))
136 words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) \
137 -2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1
138 ddq bs=1 count=$(echo $L) skip=$(echo $O) if=/mnt/$ISO >> $1
139 }
141 checkmagic()
142 {
143 [ -s $1 ] && [ $(getarg magic) = $(get 18 $1 2) ]
144 }
146 getiso()
147 {
148 mkdir -p /media/cdrom
149 for dev in /sys/block/?d?/?d??*; do
150 mount /dev/$(basename $dev) /mnt
151 if checkmagic /mnt/$ISO; then
152 mount -o loop,ro /mnt/$ISO /media/cdrom
153 echo "Found $ISO on $(basename $dev)"
154 return 0
155 fi
156 umount /mnt
157 done 2>/dev/null
158 return 1
159 }
161 uncpio()
162 {
163 i=$1
164 grep -q ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64
165 [ -s "$i" ] || return
166 echo -en "\n Extracting $(basename $i) ..."
167 case $(get 0 $i) in
168 *35615) ( zcat || gunzip );;
169 *14333) unxz;;
170 *\ 93) unlzma;;
171 *) cat;;
172 esac < $i | ( cd ${2:-/}; cpio -idmu > /dev/null 2>&1 )
173 }
175 dotwait()
176 {
177 echo -n "${1:-Install filesystem}.."
178 echo -n > /tmp/wait
179 while [ -e /tmp/wait ]; do
180 echo -n "." > /dev/tty0
181 sleep 1
182 done &
183 }
185 getuuid()
186 {
187 dev=$(mount | sed '/ \/mnt /!d;s/ .*//;s|/dev/||;q')
188 blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/"
189 }
191 tazusbinitfs()
192 {
193 PAD=$(($(stat -c %s $1) % 4))
194 [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1
195 mkdir -p /tmp/fs/etc /tmp/fs/lib /tmp/fs/home
196 cp /etc/keymap.conf /etc/locale.conf /tmp/fs/etc 2>/dev/null
197 cat > /tmp/fs/init1 <<EOT
198 #!/bin/sh
199 sed -i 's|sbin/init|init2|' /init
200 exec /init
201 EOT
202 cat > /tmp/fs/init2 <<EOT
203 #!/bin/sh
205 mount -t proc /proc /proc
206 for i in /lib/modules/*.ko*; do insmod \$i 2>/dev/null; done; sleep 2
207 v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2>/dev/null)
208 mount / -o remount,rw
209 mkdir /mnt/dos
210 rm -f /cmdline 2>/dev/null
211 mount / -o remount,ro
212 mnt=/mnt/dos/\${v#*/}
213 dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q')
214 echo "Mount \$dev in /mnt/dos for \$v..." | tee -a /run/boot.log
215 mount \$dev /mnt/dos
216 mount.posixovl -F \$mnt -- -oallow_other -odefault_permissions -osuid
217 mount --bind \$mnt /home
218 mount -o size=0,ro -t tmpfs tmpfs \$mnt
219 umount /proc
220 exec /sbin/init
221 EOT
222 chmod 755 /tmp/fs/init?
223 cp -a /tmp/fs/* /
224 ln -s /sqfs/bin/gzip /bin 2>/dev/null
225 ( cd /tmp/fs; find * | cpio -o -H newc ) | gzip -9 >> $1
226 }
228 mkinitrd()
229 {
230 echo
231 dotwait "Creating $(basename $1) "
232 for i in bin lib dev proc tmp mnt etc; do
233 mkdir -p /tmp/fs/$i
234 done
235 for i in /dev/console /dev/null /dev/tty /dev/tty[012] /dev/fuse /dev/[hs]d*; do
236 cp -a $i /tmp/fs$i
237 done
238 for i in /bin/busybox $(which mount.posixovl) $(which blkid); do
239 cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \
240 sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') /tmp/fs/lib
241 cp $i /tmp/fs/bin
242 done
243 cp -a /sqfs/lib/ld-* /tmp/fs/lib 2>/dev/null ||
244 cp -a /lib/ld-* /tmp/fs/lib
245 for i in $(busybox | sed '/Current/,$!d'); do
246 [ -e /tmp/fs/bin/${i%,} ] || ln -s busybox /tmp/fs/bin/${i%,}
247 done
248 ln -s /proc/mounts /tmp/fs/etc/mtab
249 sed 's/ .*//' /proc/modules | while read mod; do
250 find /lib/modules/ | grep $mod.ko | \
251 sed 's|.*|cp & /tmp/fs/lib|' | sh
252 done
253 cat > /tmp/fs/init <<EOT
254 #!/bin/sh
256 arg()
257 {
258 grep -q \$1 /proc/cmdline &&
259 val="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" < /proc/cmdline)" &&
260 echo "\$2 \$val"
261 }
263 mount -t proc /proc /proc
264 for i in /lib/*.ko*; do insmod \$i 2>/dev/null; done; sleep 2
265 arg mount "Mount device"
266 mount \$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q') /mnt
267 arg subroot "Change root to directory"
268 mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid
269 mount --bind /mnt /mnt/\$val/mnt/dos
270 mount -o size=0,ro -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val
271 LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q)
272 export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib
273 umount /proc
274 exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init
275 EOT
276 chmod +x /tmp/fs/init
277 ( cd /tmp/fs; find * | cpio -o -H newc ) | lzma e $1 -si 2>/dev/null
278 rm -rf /tmp/fs /tmp/wait
279 }
281 is_loram()
282 {
283 [ -s /lib/modules/squashfs.ko* ]
284 }
286 ls_r()
287 {
288 ls -r $@ 2>/dev/null || ls $@
289 }
291 doinstall()
292 {
293 mkdir -p /mnt/slitaz/boot /mnt/slitaz/mnt/dos
294 if ! mount.posixovl -F /mnt/slitaz -- \
295 -oallow_other -odefault_permissions -osuid; then
296 echo "Can't install SliTaz. Abort."
297 sleep 5
298 return 1
299 fi
300 dotwait "Install root filesystem in /slitaz.."
301 if [ "$1" ]; then
302 if [ -d /media/cdrom/fs ]; then
303 ( cd /mnt/slitaz/fs; find | cpio -o -H newc ) | gzip -9
304 else
305 ls_r /media/cdrom/boot/rootfs* | xargs cat
306 fi > /mnt/slitaz/boot/rootfs.gz
307 tazusbinitfs /mnt/slitaz/boot/rootfs.gz
308 initrd=rootfs.gz
309 extraargs="/home=$(getuuid)/slitaz rdinit=/init1"
310 else
311 if [ -d /media/cdrom/fs ]; then
312 cp -a /media/cdrom/fs/. /mnt/slitaz
313 elif is_loram; then
314 for i in $(ls_r /media/cdrom/boot/rootfs*); do
315 losetup -o 124 /dev/loop7 $i
316 mount -t squashfs -o ro /dev/loop7 /sqfs/mnt
317 cp -a /sqfs/mnt/. /mnt/slitaz
318 umount /sqfs/mnt
319 losetup -d /dev/loop7
320 done
321 else
322 for i in $(ls_r /media/cdrom/boot/rootfs*); do
323 uncpio $i /mnt/slitaz
324 done
325 fi
326 mkinitrd /mnt/slitaz/boot/initrd
327 initrd=initrd
328 extraargs="mount=$(getuuid) subroot=slitaz"
329 fi
330 echo -en "\nInstall boot files..."
331 for i in /media/cdrom/boot/bzImage /media/cdrom/boot/*pxe* \
332 /media/cdrom/boot/isolinux/he* /media/cdrom/boot/isolinux/opt* \
333 /media/cdrom/README /media/cdrom/boot/memtest*; do
334 [ -s $i ] && cp $i /mnt/slitaz/boot
335 done
336 for i in /mnt/slitaz/boot/memtest /mnt/slitaz/boot/*pxe; do
337 [ $(get 0 $i 2>/dev/null || echo 0) -eq 23117 ] &&
338 mv $i $i.exe
339 done
340 cp /etc/keymap.conf /etc/locale.conf /mnt/slitaz/etc 2>/dev/null
341 gettazboot /mnt/slitaz/boot/tazboot.exe
342 unix2dos > /mnt/slitaz/boot/tazboot.cmd <<EOT
343 kernel=/slitaz/boot/bzimage
344 initrd=/slitaz/boot/$initrd
345 rw root=/dev/null $extraargs autologin
346 EOT
347 uudecode - <<EOT | gunzip > /mnt/slitaz/boot/slitaz.pif
348 begin-base64 644 -
349 H4sIAAAAAAACA8XPxUHGMBTA8X9ecb/glgFwv+FO23zeI+7ucMFhCjZgEEZh
350 Ctzd4Rf3PFbtQHGLG9BmfmZqdlE/tSmw2LfePzOzWDK0OsQXpPHvFGfZBmL5
351 f3Zns98NuG1BbTrbWj0OFMypSKfT4kYCurKuRleWlBEth2qUTYFBKjg746pI
352 2nZaIT/v9vWwbeuqi9fPznLlSPFLLuK22/0lLT09/BDhXgWKO1f9aLKxOObE
353 EhLuVvO4FksSwaH5qbHpvkle0TyzND82NK+doRVeZgGGbIw0XD2QwV9SnAN/
354 ACxDxwMAAA==
355 ====
356 EOT
357 unix2dos /mnt/slitaz/boot/he* /mnt/slitaz/boot/opt* \
358 /mnt/slitaz/boot/README
359 [ -d /mnt/slitaz/usr/sbin -a ! -x /mnt/slitaz/usr/sbin/mount.posixovl ] &&
360 cp $(which mount.posixovl) /mnt/slitaz/usr/sbin
361 rm -f /tmp/wait
362 false &&
363 [ -s /mnt/boot.ini ] && ! grep -qs tazboot /mnt/boot.ini &&
364 echo "Update boot.ini ..." && unix2dos >> /mnt/boot.ini <<EOT
365 C:\\slitaz\\boot\\tazboot.exe="SliTaz"
366 EOT
367 false &&
368 grep -qis menuitem /mnt/config.sys && ! grep -qi tazboot /mnt/config.sys &&
369 echo "Update config.sys ..." &&
370 sed -i 's/menudefault/menuitem SLITAZ, SliTaz\r\n&/' /mnt/config.sys &&
371 unix2dos >> /mnt/config.sys <<EOT
372 [SLITAZ]
373 install=\\slitaz\\boot\\tazboot.exe
374 EOT
375 return 0
376 }
378 install()
379 {
380 $DIALOG --clear --title " SliTaz UMSDOS way installation " \
381 --yes-label "Install" --yesno \
382 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
383 DOS/Windows partition. You will see your files from /mnt/dos.\n\n
384 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
385 To uninstall SliTaz, you have only to remove this directory.
386 The file \\boot.ini or \\config.sys may be modified too.\n\n
387 SliTaz may run slowly on the 'UMSDOS way' installation due to the
388 posixovl filesystem. The 'TAZUSB way' installation runs faster.\n\n
389 To do a traditional installation with disk partitioning,
390 start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
391 [ $? -eq 0 ] || return
392 doinstall || return
393 [ -x /mnt/slitaz/sbin/init ] || return
394 umount -d /media/cdrom
395 umount_proc
396 exec chroot /mnt/slitaz /sbin/init
397 }
399 installtaz()
400 {
401 $DIALOG --clear --title " SliTaz TAZUSB way installation " \
402 --yes-label "Install" --yesno \
403 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
404 DOS/Windows partition. You will see your files from /mnt/dos.\n\n
405 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
406 To uninstall SliTaz, you have only to remove this directory.
407 The file \\boot.ini or \\config.sys may be modified too.\n\n
408 The filesystem is loaded entirely into memory upon boot to
409 increase responsiveness. Only /home lands on the hard disk.\n\n
410 To do a traditional installation with disk partitioning,
411 start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
412 [ $? -eq 0 ] || return
413 doinstall tazusblike || return
414 dotwait
415 if [ -d /media/cdrom/fs ]; then
416 cp -a /media/cdrom/fs/. /
417 else
418 for i in $(ls_r /media/cdrom/boot/rootfs*); do
419 uncpio $i
420 done
421 fi
422 cp /tmp/fs/etc/* /etc 2>/dev/null
423 echo "/home=$(getuuid)/slitaz" > /cmdline
424 rm -f /tmp/wait
425 [ -x /init1 ] || return
426 umount -d /media/cdrom
427 umount /mnt/slitaz
428 rm -f /dev/cdrom
429 umount /mnt
430 mkdir /mnt/dos
431 umount_proc
432 exec /init1
433 }
435 tazboot()
436 {
437 $DIALOG --clear --title " SliTaz bootloader for DOS " \
438 --yes-label "Install" --yesno \
439 "\nThe file TAZBOOT.EXE will be created in the top directory. It supports
440 any linux kernel, multiple initramfs, a kernel command line and
441 an ISO image file loopback (retrieves files from an ISO file).\n\n
442 Usage: tazboot.exe [[@commands]|[kernel=<bzimage>]
443 [initrd=<rootfs>[,<rootfs2>...]] [bootfrom=<isofile>] cmdline args ...]\n\n
444 Defaults: tazboot @tazboot.cmd or tazboot kernel=bzImage auto\n\n\
445 Examples for tazboot.cmd:\n\n\
446 bootfrom=\\isos\\slitaz-4.0.iso\n\
447 kernel=boot/bzImage\n\
448 initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\
449 rw root=/dev/null autologin\n\n\
450 kernel=\\slitaz\\vmlinuz root=/dev/sda5 ro\n\n
451 Unlike GRUB4DOS, it doesn't require unfragmented ISO image files.\n" 24 78
452 [ $? -eq 0 ] || return
453 gettazboot /mnt/tazboot.exe
454 }
456 md5()
457 {
458 dotwait "Checking files"
459 ( cd /media/cdrom; ${1:-md5sum -c md5sum*} | sort ) > /tmp/data
460 rm -f /tmp/wait
461 $DIALOG --clear --title " Checked files " --textbox /tmp/data 24 78
462 rm -f /tmp/data
463 }
465 gotcdfile()
466 {
467 for i in "/media/cdrom/$1" "/media/cdrom/*/$1" \
468 "/media/cdrom/*/isolinux/$1"; do
469 file=$(ls $i 2>/dev/null | sed q)
470 [ -s "$file" ] && break
471 done
472 }
474 sha()
475 {
476 gotcdfile "sha*sum*"
477 sha=$(basename $file)
478 md5 "${sha%sum*}sum -c ${file#/media/cdrom/}"
479 }
481 readme()
482 {
483 gotcdfile "README*"
484 $DIALOG --clear --title " Readme " --textbox $file 24 78
485 }
487 bootlog()
488 {
489 $DIALOG --clear --title " Linux boot messages " \
490 --textbox /tmp/dmesg 24 78
491 }
493 bzimage()
494 {
495 $DIALOG --clear --title " Create linux.exe ? " \
496 --yes-label "Install" --yesno \
497 "\nLinux.exe launches the linux kernel under DOS (in real mode only).
498 The cmdline arguments are supported except initrd=,
499 vga= (you can try 'rdev -v') and mem= (partially).
500 \nExample:\nC:\\> linux.exe root=/dev/hda2 ro panic=60\n
501 " 12 70
502 [ $? -eq 0 ] || return
503 cp /media/cdrom/boot/bzImage /mnt/linux.exe
504 }
506 memtest()
507 {
508 $DIALOG --clear --title " Create memtest.exe ? " \
509 --yes-label "Install" --yesno \
510 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
511 computers. BIOS based memory tests are a quick, cursory check and often
512 miss many of the failures that are detected by Memtest86.\n" 12 70
513 [ $? -eq 0 ] && gotcdfile "memtest*" && cp $file /mnt/memtest.exe
514 }
516 mkfat12()
517 {
518 [ $(($(get 0 $1) - 0x5A4D)) -eq 0 ] || return
519 J=$(($(get 3 $1 1) + 0x02))
520 R=$((1 + $(get 497 $1 1) + 1 + ($(get 500 $1)-1)/32))
521 [ $R -lt 2500 ] || return
522 [ $((($(get 500 $1)-1) & 31)) -lt 30 ] &&
523 ddq if=$file bs=32 count=1 seek=$(($R*16 - 1)) of=/dev/fd0
524 G="18 0 2 0 0 0 0 0"
525 [ $J -gt 25 ] || G=""
526 F=0
527 for i in 1 2 3; do
528 F=$((((2880-$R-$F-$F)*3+1023)/1024))
529 done
530 bytes2bin 0xEB $J 0x90 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 \
531 0 2 2 $(($R%256)) $(($R/256)) 2 64 0 64 11 0xF0 $F 0 \
532 $G | ddq bs=1 of=/dev/fd0
533 ddq if=/dev/zero bs=512 count=$((4+$F+$F)) seek=$R of=/dev/fd0
534 for i in $R $(($R+$F)); do
535 bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0
536 done
537 echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0
538 }
540 mkfloppy()
541 {
542 dotwait "Create a $(basename $1 .exe) boot floppy"
543 ddq if=$1 of=/dev/fd0
544 mkfat12 $1
545 rm -f /tmp/wait
546 }
548 fdmemtest()
549 {
550 $DIALOG --clear --title " Create a Memtest86 boot floppy " \
551 --yes-label "Create floppy" --yesno \
552 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
553 computers. BIOS based memory tests are a quick, cursory check and often
554 miss many of the failures that are detected by Memtest86.\n\n
555 Please insert a blank disk in floppy drive.\n" 12 70
556 [ $? -eq 0 ] && gotcdfile "memtest*" && mkfloppy $file
557 }
559 pxe()
560 {
561 gotcdfile "?pxe*"
562 $DIALOG --clear --title " Create $(basename $file .exe).exe ? " \
563 --yes-label "Install" --yesno \
564 "\nBoot your operating system from the internet and enjoy a full system
565 working entirely in RAM with speed and stability in mind. The Linux Kernel
566 and the complete SliTaz compressed root filesystem will be loaded into RAM
567 from the Web using PXE and HTTP protocols.\n" 12 70
568 [ $? -eq 0 ] || return
569 cp $file /mnt/$(basename $file .exe).exe
570 }
572 fdpxe()
573 {
574 $DIALOG --clear --title " Create a SliTaz Web boot floppy " \
575 --yes-label "Create floppy" --yesno \
576 "\nBoot your operating system from the internet and enjoy a full system
577 working entirely in RAM with speed and stability in mind. The Linux Kernel
578 and the complete SliTaz compressed root filesystem will be loaded into RAM
579 from the Web using PXE and HTTP protocols.\n\n
580 Please insert a blank disk in floppy drive.\n" 12 70
581 [ $? -eq 0 ] && gotcdfile "?pxe*" && mkfloppy $file
582 }
584 gotposixovl()
585 {
586 mount.posixovl 2>&1 | grep -qi usage &&
587 echo -en "\"$1\" \"$2\""
588 }
590 xfile()
591 {
592 [ "$(which $1)" ] && echo -en "\"$2\" \"$3\""
593 }
595 cdfile()
596 {
597 gotcdfile "$1" && echo -en "\"$2\" \"$3\""
598 }
600 isbzImage()
601 {
602 [ $(get 514 $file 4) -eq 1400005704 ] &&
603 [ $(($(get 529 $file 1) & 1)) -eq 1 ]
604 }
606 cdfilex()
607 {
608 gotcdfile "$1" &&
609 [ "$(which kexec)" ] &&
610 isbzImage &&
611 echo -en "\"$2\" \"$3\""
612 }
614 cdfilef()
615 {
616 [ -e /sys/block/fd0 ] && cdfile "$@"
617 }
619 cdexe()
620 {
621 gotcdfile "$1" &&
622 [ $(get 0 $file 2>/dev/null || echo 0) -eq 23117 ] &&
623 echo -en "\"$2\" \"$3\""
624 }
626 fddata()
627 {
628 [ -e /sys/block/fd0 ] &&
629 [ $(get 26 /mnt/$ISO 1 2>/dev/null || echo 0) -ne 0 ] &&
630 echo -en "\"$1\" \"$2\""
631 }
633 ishybrid()
634 {
635 [ $(get 510 $ISO 2>/dev/null || echo 0) -eq 43605 ] || return
636 C=$((2048*$(get $(((17*2048) + 71)) /mnt/$ISO 4)))
637 [ $(get $C /mnt/$ISO 4) -eq 1 ] || return
638 [ $(get $(($C+30)) /mnt/$ISO 4) -eq $((0x88AA55)) ] || return
639 C=$((2048*$(get $(($C+40)) /mnt/$ISO 4)))
640 [ $(get $(($C+64)) /mnt/$ISO 4) -eq 1886961915 ] &&
641 echo -en "\"$1\" \"$2\""
642 }
644 burnable()
645 {
646 [ "$(sed '/Can wr.*1$/!d' /proc/sys/dev/cdrom/info 2>/dev/null)" ] &&
647 [ "$(which wodim)" ] && echo -en "\"$1\" \"$2\""
648 }
650 blankable()
651 {
652 [ "$(sed '/Can wr.*RW.*1$/!d' /proc/sys/dev/cdrom/info 2>/dev/null)" ] &&
653 [ "$(which wodim)" ] && echo -en "\"$1\" \"$2\""
654 }
656 burniso()
657 {
658 wodim -v speed=$(fgrep "drive speed" /proc/sys/dev/cdrom/info | cut -f3) \
659 -eject -multi "$ISO"
660 }
662 blankcd()
663 {
664 wodim -v -blank=fast
665 }
667 customsector()
668 {
669 echo $(get 32848 "/mnt/$ISO" 4)
670 }
672 hascustomconf()
673 {
674 [ "$(ddq bs=2k skip=$(customsector) if="/mnt/$ISO" | ddq bs=1 count=6)" \
675 = "#!boot" ]
676 }
678 gotcustomconf()
679 {
680 hascustomconf && echo -en "\"$1\" \"$2\""
681 }
683 getcustomconf()
684 {
685 cd ${1:-/mnt}
686 ddq bs=2k skip=$(customsector) if="/mnt/$ISO" | while read line; do
687 case "$line" in
688 \#!boot*);;
689 append=*) echo ${line#append=} > cmdline && ls -l cmdline;;
690 initrd:*) cnt=${line#initrd:}
691 { ddq bs=512 count=$(($cnt / 512));
692 ddq bs=1 count=$(($cnt % 512)); } > initrd &&
693 ls -l initrd
694 break;;
695 *) break;;
696 esac
697 done
698 cd - > /dev/null
699 [ -z "$1" ] && echo -e "\rPress RETURN to continue." && read n
700 }
702 gotisomd5()
703 {
704 [ "$(which md5sum 2>/dev/null)" ] &&
705 [ $(get 0 /mnt/$ISO) -eq 23117 ] &&
706 [ $(get 18 /mnt/$ISO) -ne 0 ] && echo -en "\"$1\" \"$2\""
707 }
709 isomd5()
710 {
711 dotwait "Checking iso image"
712 [ "$(ddq if=/mnt/$ISO bs=2k skip=16 \
713 count=$(($(get 32848 /mnt/$ISO 4)-16)) | md5sum)" = \
714 "$(ddq if=/mnt/$ISO bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \
715 sed 's/ //g') -" ] && echo "OK" || echo "ERROR"
716 echo -en "\rChecking iso hybrid boot..."
717 n=$(($(get 2 /mnt/$ISO)-1+($(get 4 /mnt/$ISO)-1)*512))
718 if [ $n -lt 40000 -a $n -gt 32768 ]; then
719 s=$(get 0 /mnt/$ISO 2 $n | awk '{ i+= $0 } END { print i }')
720 [ $(((1+$s+$(get $(($n+1)) /mnt/$ISO 1)) % 65536)) -eq 0 ] &&
721 echo "OK" || echo "ERROR"
722 fi
723 if hascustomconf; then
724 echo -en "\rChecking iso custom config..."
725 TMP=/tmp/$(basename $0)$$md5
726 md5="$(ddq bs=2k skip=$(customsector) if=/mnt/$ISO | while read line; do
727 case "$line" in
728 \#!boot*) echo ${line#*boot } > $TMP;;
729 append=*) echo $line;;
730 initrd:*) echo $line
731 cnt=${line#initrd:}
732 ddq bs=512 count=$((cnt / 512))
733 ddq bs=1 count=$((cnt % 512))
734 break;;
735 *) break;;
736 esac
737 done | md5sum | cut -c1-32)"
738 [ "$md5" = "$(cat $TMP)" ] && echo "OK" || echo "ERROR"
739 rm -f $TMP
740 fi
741 rm -f /tmp/wait
742 echo -e "\rPress RETURN to continue."
743 read n
744 }
746 if [ "$1" = "--build" ]; then #install-begin
747 cp $0 $0.tmp
748 uuencode -m - < ifmem.bin | sed -e 's|^[ \t]*||;s|[ \t]*###.*||' \
749 -e 's| *;;|;;|;s|\t\t*|\t|g' \
750 -e '/^ifmemcode$/r/dev/stdin' -e '/^ifmemcode$/d' -i $0.tmp
751 uuencode -m - < bootloader.bin | sed -e '/^bootloader$/r/dev/stdin' \
752 -e '/^bootloader$/d' -e '/install-begin$/,/install-end$/d' -i $0.tmp
753 mv -f $0.tmp $0; exit
754 fi #install-end
755 parse_isolinux()
756 {
757 awk 'BEGIN { IGNORECASE=1 }
758 function multi(n)
759 {
760 auto=$n
761 for (--n; n < NF; n+=2) {
762 s=$n
763 if (s ~ /M$/) s = substr(s,0,length(s)-1)
764 else s /= 1024
765 sizes=int(s) " " sizes
766 }
767 next
768 }
769 {
770 if ($1 == "LABEL") {
771 label=$2
772 if (auto == "") auto=label
773 }
774 if ($1 == "KERNEL" || $1 == "COM32") kernel[label]=$2
775 if ($1 == "INITRD") initrd[label]=$2
776 if ($1 == "APPEND") {
777 i=2
778 if (kernel[label] ~ "ifmem.c32") multi(3)
779 if (kernel[label] ~ "c32box.c32") {
780 if ($2 == "linux") { kernel[label]=$3; i=4 }
781 if ($2 == "ifmem") multi(4)
782 }
783 if (kernel[label] ~ "ifcpu64.c32") { auto=$4; next }
784 while (i <= NF) {
785 if ($i ~ "^initrd=") initrd[label]=substr($i,8)
786 else cmdline[label]=cmdline[label] " " $i
787 i++
788 }
789 }
790 }
791 END {
792 print "KERNEL=\"" kernel[auto] "\""
793 print "INITRD=\"" initrd[auto] "\""
794 print "CMDLINE=\"" substr(cmdline[auto],2) "\""
795 print "SIZES=\"" sizes "\""
796 }'
797 }
799 locase()
800 {
801 echo "$1" | tr [A-Z] [a-z]
802 }
804 ifmemcode()
805 {
806 uudecode <<EOT
807 ifmemcode
808 EOT
809 }
811 floppyset()
812 {
813 gotcdfile isolinux.cfg
814 parse_isolinux < $file > /tmp/var$$
815 . /tmp/var$$
816 for i in /media/cdrom/$KERNEL $(dirname $file)/$KERNEL /media/cdrom/$(locase $KERNEL) \
817 $(dirname $file)/$(locase $KERNEL); do
818 [ -s $i ] && KERNEL=$i && break
819 done
820 rm -f /tmp/var$$
821 [ $(get 514 $KERNEL 4) -eq 1400005704 ] || return
822 n=$(($(get 497 $KERNEL 1)+1))
823 ddq bs=512 count=$n if=$KERNEL of=/tmp/fd$$
824 uudecode <<EOT | ddq of=/tmp/fd$$ conv=notrunc
825 bootloader
826 EOT
827 pos=$(($n*512))
828 if [ -n "$CMDLINE" ]; then
829 echo -n "$CMDLINE" | ddq bs=512 count=1 conv=sync >> /tmp/fd$$
830 bytes2bin $n | ddq conv=notrunc \
831 bs=1 seek=497 count=1 of=/tmp/fd$$
832 words2bin $pos | ddq conv=notrunc \
833 bs=1 seek=34 count=2 of=/tmp/fd$$
834 [ $(get 518 $KERNEL 4) -ge 514 ] &&
835 words2bin 32768 9 | ddq conv=notrunc \
836 bs=1 seek=552 count=4 of=/tmp/fd$$
837 fi
838 syssize=$(echo $(get 500 /tmp/fd$$ 4))
839 ddq bs=512 skip=$n if=$KERNEL | cat - /dev/zero | \
840 ddq bs=512 count=$((($syssize+31)/32)) conv=sync >> /tmp/fd$$
841 base=$(stat -c %s /tmp/fd$$)
842 len=
843 if [ "$INITRD" ]; then
844 l=0
845 for i in ${INITRD//,/ }; do
846 for j in /media/cdrom/$i $(dirname $KERNEL)/$i /media/cdrom/$(locase $i) \
847 $(dirname $KERNEL)/$(locase $i); do
848 [ -s $j ] && i=$j && break
849 done
850 ddq if=$i >> /tmp/fd$$
851 l=$(($l+$(stat -c %s $i)))
852 r=$((4 - ($l % 4)))
853 if [ $r -ne 4 ]; then
854 ddq if=/dev/zero bs=1 count=$r >> /tmp/fd$$
855 l=$(($l + $r))
856 fi
857 case "$i:$INITRD" in
858 *rootfs.gz:*rootfs.gz,*) continue ### loram
859 esac
860 len="$len $l"; l=0
861 done
862 rdadrs=${RDADRS:-$(((($syssize*16)+0x1F0000) & -4096))}
863 words2bin $(($rdadrs & 0xFFFF)) $(($rdadrs >> 16)) | ddq \
864 conv=notrunc bs=1 seek=536 count=4 of=/tmp/fd$$
865 fi
866 n=$(echo $len | wc -w)
867 if [ $((494 - $(get 494 /tmp/fd$$))) -ge $(($n * 4)) ]; then
868 i=$(($(get 494 /tmp/fd$$)))
869 bytes2bin $(($i + ($n*4) - 256)) | ddq bs=1 conv=notrunc \
870 seek=496 count=1 of=/tmp/fd$$
871 else
872 i=$(($pos + 0x1FC - ($n*4)))
873 bytes2bin $(($i % 256)) $((i / 256)) 252 | ddq bs=1 \
874 conv=notrunc seek=494 count=3 of=/tmp/fd$$
875 s=$(($i - 2*$(echo "$SIZES" | wc -w)))
876 p=$(($s - $(ifmemcode | wc -c)))
877 ifmemcode | ddq bs=1 conv=notrunc seek=$p of=/tmp/fd$$
878 words2bin $SIZES | ddq bs=1 conv=notrunc seek=$s of=/tmp/fd$$
879 bytes2bin 154 $(($p%256)) $(($p/256)) 0 144 | \
880 ddq bs=1 conv=notrunc seek=60 of=/tmp/fd$$
881 fi
882 for r in $len; do
883 words2bin $(($r & 0xFFFF)) $(($r >> 16)) | ddq conv=notrunc \
884 bs=1 seek=$i count=4 of=/tmp/fd$$
885 i=$(($i + 4))
886 done
887 split -b 1440k /tmp/fd$$ fd$$
888 rm -f /tmp/fd$$
889 n=1; i=0; r=0
890 set -- $len
891 ls fd$$* | while read file; do
892 if [ $i -gt $(($1+$base)) ]; then
893 shift
894 r=$(($r+100)); n=0; i=0; base=0
895 fi
896 ddq of=$file bs=18k seek=80 count=0
897 i=$(($i+1474560))
898 printf "mv %s fd%03d.img\n" $file $(($r+$n))
899 n=$(($n+1))
900 done | sh
901 ls fd???.img
902 mv fd???.img /mnt
903 }
905 fdbootstrap()
906 {
907 sz=$((512 * $(echo $(get 26 /mnt/$ISO 1))))
908 $DIALOG --clear --title " Create a floppy bootstrap " \
909 --yes-label "Continue" --yesno \
910 "\nThe floppy will install a driver to access the ISO file
911 on your hard disk and will emulate a CD-ROM during the boot process.\n\n
912 Please insert a floppy in drive now.\n" 10 70
913 [ $? -eq 0 ] || return
914 ddq if=/mnt/$ISO of=/tmp/bootiso bs=1 count=512 \
915 skip=$(( $(get 64 /mnt/$ISO) - $sz ))
916 echo "$ISO" | ddq of=/tmp/bootiso bs=512 seek=1 count=1
917 ddq if=/mnt/$ISO of=/tmp/bootiso bs=1 count=$sz seek=2 \
918 skip=$(( $(get 64 /mnt/$ISO) - $sz + 512 ))
919 mkfloppy /tmp/bootiso
920 rm -f /tmp/bootiso
921 }
923 usbdev()
924 {
925 dotwait "Wait 5 seconds for USB devices"
926 sleep 5
927 rm -f /tmp/wait
928 DEV="$(grep -l 1 /sys/block/*/removable | \
929 sed 's|/sys/block/\(.*\)/removable|\1|')"
930 grep -qs 1 /sys/block/$DEV/ro && return
931 [ "$DEV" ] || return
932 cat > /tmp/dialog <<EOT
933 $DIALOG --clear --title " Select your USB key " \
934 --menu "\nPlease select the USB key according to its known size.\n\n" \
935 14 70 4 \
936 $(for i in $DEV; do
937 echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2>/dev/null)\" "
938 done)
939 EOT
940 exec 3>&1
941 device=$(. /tmp/dialog 2>&1 1>&3)
942 retval=$?
943 exec 3>&-
944 [ $retval -eq 0 ]
945 }
947 tazusbmsg()
948 {
949 [ "$(which tazusb 2>/dev/null)" ] || return
950 echo "You should choose 'USB key read/write installation' to be
951 able to save the package updates or your own configuration and data files.\n\n"
952 }
954 usbbootkey()
955 {
956 $DIALOG --clear --title " Create a USB boot key " \
957 --yes-label "Continue" --yesno \
958 "\nThe USB key will be used like a CD-ROM. You will not be able to write
959 any data on the boot partition.\n\n
960 An extra FAT32 partition will be created with the remaining free space.\n\n
961 $(tazusbmsg)Please plug your USB stick in now.\n" 16 70
962 [ $? -eq 0 ] || return
963 usbdev || return
965 ### perform dd in progress bar
966 max=$(($(cat /sys/block/loop0/size)/2048))
967 i=0; ddq if=/mnt/$ISO bs=1024k | (
968 while ddq bs=1024k count=1; do
969 i=$(($i + 1))
970 [ $i -gt $max ] && break
971 echo $((($i*100)/$max)) | dialog --gauge \
972 " The ISO image transfer can be long. Please wait..." \
973 6 70 0 > /dev/tty0 2>&1
974 done ) > $device
976 ### partition + fat32 format for the remaining space
977 for p in 0 16; do
978 get $((450+$p)) $device 2 12 | xargs echo | {
979 read dx cx ol oh ll lh
980 [ $dx -eq $((0x3F17)) ] || continue
981 cx=$(($cx & 0xFF00))
982 ofs=$(($ll+($lh<<16)))
983 n=$(($(cat /sys/block/${device#/dev/}/size)-$ofs))
984 m=$(($cx+($n/8)))
985 [ $m -gt $((0x3FF00)) ] && m=$((0x3FF00))
986 m=$((($m & 0xFF00)+(($m>>16)<<6)))
987 words2bin 0 $((0x101+$cx)) 0x3F0B $((32+$m)) \
988 $ll $lh $(($n & 0xFFFF)) $(($n >> 16)) | \
989 ddq bs=1 seek=$((462-$p)) of=$device
990 if [ "$(which mkdosfs 2>/dev/null)" ]; then
991 losetup -o $((512*$ofs)) /dev/loop2 $device
992 mkdosfs -n "SLITAZ BOOT" /dev/loop2
993 words2bin $(($ofs & 0xFFFF)) $(($ofs >> 16)) | \
994 ddq bs=1 seek=28 of=/dev/loop2
995 sync
996 losetup -d /dev/loop2
997 fi
998 }
999 done
1002 usbkey()
1004 $DIALOG --clear --title " Create a SliTaz USB key " \
1005 --yes-label "Continue" --yesno \
1006 "\nUnlike a hard drive install, the filesystem is kept in a compressed
1007 rootfs.gz. The filesystem is loaded entirely into memory upon boot.
1008 This should increase responsiveness, protect the filesystem against
1009 accidental corruption and reduce read/writes to the USB drive.
1010 Once setup, the tazusb utility can rewrite the root filesystem
1011 with any changes you have made since booting up,
1012 giving the effective benefits of a hard drive install.\n\n
1013 /home is mounted on boot using the UUID of your particular flash drive.
1014 Unlike a device name, the UUID has the benefit of never changing from machine
1015 to machine.\n\n
1016 Please plug your USB stick in now.\n" 19 70
1017 [ $? -eq 0 ] || return
1018 usbdev || return
1019 exec 3>&1
1020 format=`$DIALOG --clear --title " Select the filesystem " \
1021 --radiolist "\nPlease select the filesystem type to create.\n\n\
1022 The filesystem creation will erase all the data \
1023 in the USB key." 14 70 4 \
1024 "none" "Do not erase the USB key" on \
1025 "ext3" "Ext3 journaling filesystem" off \
1026 "ext2" "Ext2 filesystem" off \
1027 "fat32" "Windows FAT32 filesystem" off \
1028 2>&1 1>&3`
1029 retval=$?
1030 exec 3>&-
1031 [ $retval -eq 0 ] || return
1032 [ "$format" != "none" ] && tazusb format $device "SliTaz" $format
1033 tazusb gen-iso2usb /mnt/$ISO $device
1036 mount_loram()
1038 is_loram || return
1039 insmod /lib/modules/squashfs.ko* 2>/dev/null
1040 if [ -d /media/cdrom/fs ]; then
1041 ln -s /media/cdrom/fs /sqfs
1042 else
1043 mkdir /sqfs
1044 losetup -o 124 /dev/loop6 $(ls_r /media/cdrom/boot/rootfs?*.* | sed q)
1045 mount -r /dev/loop6 /sqfs
1046 fi
1047 cp -a /sqfs/dev/fuse /sqfs/dev/tty[12] /sqfs/dev/[hs]d* /dev
1048 ln -s /sqfs/lib/* lib 2>/dev/null
1049 ln -fs /sqfs/usr /sqfs/var /
1050 mkdir /etc && cp /sqfs/etc/dialogrc /etc 2>/dev/null
1053 umount_loram()
1055 is_loram || return
1056 rm /var /usr
1057 umount -d /sqfs
1058 rmdir /sqfs 2>/dev/null || rm -f /sqfs
1059 rm -rf /etc
1062 dosync()
1064 sync
1065 umount_loram
1066 umount -d /media/cdrom
1067 rm -f /dev/cdrom
1068 umount /mnt
1069 umount_proc
1072 text()
1074 uncpio $(ls_r /media/cdrom/boot/rootfs?*.* | sed q)
1075 init=
1076 cmdline="$(cat /proc/cmdline)"
1077 if hascustomconf; then
1078 getcustomconf /tmp > /dev/null
1079 [ -s /tmp/cmdline ] &&
1080 cmdline="$cmdline $(cat /tmp/cmdline)" &&
1081 init="$(sed '/rdinit=/!d;s/.*rdinit=\([^ ]*\).*/\1/' < /tmp/cmdline)"
1082 [ -s /tmp/initrd ] && uncpio /tmp/initrd
1083 fi
1084 dosync
1085 sed -i 's/ || exit//' /init
1086 exec ${init:-/init} $cmdline
1089 live()
1091 n=0
1092 dotwait "Extract filesystem..."
1093 for i in $(ls_r /media/cdrom/boot/rootfs*); do
1094 [ $((n++)) -eq 0 ] || uncpio $i
1095 done
1096 rm -f /tmp/wait
1097 text
1100 restart()
1102 dosync
1103 reboot -f
1106 stop()
1108 dosync
1109 poweroff -f
1112 dokexec()
1114 kexec -l $file || return
1115 dosync
1116 kexec -e
1119 runmemtest()
1121 gotcdfile "memtest*" && dokexec
1124 runpxe()
1126 gotcdfile "?pxe*" && dokexec
1129 flavdata()
1131 [ $(get 1024 /mnt/$ISO) -eq 35615 ] && n=2 ||
1132 n=$((1+$(get 417 /mnt/$ISO 1)))
1133 [ $n -eq 4 ] && n=20
1134 [ $(get $(($n*512)) /mnt/$ISO) -eq 35615 ] || n=13
1135 ddq if=/mnt/$ISO bs=512 skip=$n count=20 | zcat 2>/dev/null
1138 hasflavinfo()
1140 [ "$(flavdata | ddq bs=1 count=7)" = "0707010" ] &&
1141 echo -en "\"$1\" \"$2\""
1144 showfavinfo()
1146 mkdir -p /tmp/data
1147 flavdata | ( cd /tmp/data; cpio -i )
1148 file=/tmp/data/info
1149 cat /tmp/data/*desc > $file
1150 for i in /tmp/data/*list*; do
1151 echo "=== extra ${i#*list} files"
1152 cat $i
1153 done >> $file
1154 $DIALOG --clear --title " Flavor info " --textbox $file 24 78
1155 rm -rf /tmp/data
1158 flavor()
1160 cd /mnt
1161 name="$(flavdata | cpio -t 2>/dev/null | sed 's/.[a-z]*$//;q')"
1162 echo "Create ${name:=flavor}.flavor..."
1163 tazlito iso2flavor "/mnt/$ISO" $name
1164 ls -l $name.flavor 2>/dev/null || sleep 5
1165 cd - > /dev/null
1168 shell()
1170 trap text 2
1171 getty -n -l /bin/ash 38400 tty1 2>/dev/null || sh
1174 BIN=bin/mount.posixovl
1175 [ -x /usr/s$BIN ] || mv /bin/mount.posixovl.iso2exe \
1176 /usr/s$BIN 2>/dev/null || mv /bin/mount.posixovl.iso2exe /$BIN 2>/dev/null
1177 mount_proc
1178 for i in /sys/block/*/dev /sys/block/*/*/dev; do
1179 [ -s "$i" ] || continue
1180 n=${i%/dev}
1181 n=/dev/${n##*/}
1182 [ -e $n ] && continue
1183 mknod $n b $(sed 's/:/ /' < $i)
1184 done 2>/dev/null
1185 ISO="$(getarg bootfrom | sed 's/.://;s|\\|/|g')"
1186 getiso 2>/dev/null || text
1187 mount_loram
1188 case "${ISO##*/}$(getarg mode)" in
1189 *install*|*INSTALL*) install;;
1190 *live*|*LIVE*) live;;
1191 *text*|*TEXT*) text;;
1192 esac
1193 which $DIALOG 2>/dev/null || DIALOG=tinydialog
1194 dmesg > /tmp/dmesg
1196 isotitle="$(blkid /mnt/$ISO | sed 's/.*LABEL="\([^"]*\).*/\1/') $(stat \
1197 -c %y /media/cdrom | sed 's/ .*//') $(basename $ISO)"
1198 while true; do
1199 trap shell 2
1200 keymap="$(cat /etc/keymap.conf 2>/dev/null)"
1201 locale="$(sed '/^LANG=/!d;s/.*=//' /etc/locale.conf 2>/dev/null)"
1202 cat > /tmp/dialog <<EOT
1203 $DIALOG --clear --title " ${isotitle:-Welcome to Linux} " \
1204 --menu "" 23 70 17 \
1205 $(xfile tazkeymap "tazkeymap" "Select keyboard (${keymap:-none})") \
1206 $(xfile tazlocale "tazlocale" "Select locale (${locale:-none})") \
1207 $(cdfile boot/bzImage "live" "Linux RAM boot (full desktop)") \
1208 "text" "Linux RAM boot" \
1209 $(cdfile "README*" "readme" "Show the README file") \
1210 $(gotcustomconf "getcustomconf" "Get custom config") \
1211 $(gotisomd5 "isomd5" "Check the ISO image") \
1212 $(cdfile "md5sum*" "md5" "Check the ISO files") \
1213 $(cdfile "sha*sum*" "sha" "Check the ISO files") \
1214 $(burnable "burniso" "Burn the ISO image") \
1215 $(blankable "blankcd" "Blank the CD/DVD") \
1216 $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \
1217 $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \
1218 $(xfile tazusb "usbkey" "USB key read/write installation") \
1219 $(ishybrid "usbbootkey" "USB boot key (read only)") \
1220 $(hasflavinfo "showfavinfo" "Show flavor extra info") \
1221 $(xfile tazlito "flavor" "Get flavor file") \
1222 $(fddata "fdbootstrap" "Create a floppy bootstrap") \
1223 $(cdfile isolinux.cfg "floppyset" "Boot floppy set") \
1224 "tazboot" "Get tazboot.exe Linux loader" \
1225 $(cdexe boot/bzImage "bzimage" "Get linux DOS/EXE file") \
1226 $(cdexe "memtest*" "memtest" "Get Memtest86 DOS/EXE file") \
1227 $(cdfilef "memtest*" "fdmemtest" "Create a Memtest86 boot floppy") \
1228 $(:||cdfilex "memtest*" "runmemtest" "Start Memtest86") \
1229 $(cdexe "?pxe*" "pxe" "Get SliTaz Web boot DOS/EXE utility") \
1230 $(cdfilef "?pxe*" "fdpxe" "Create a SliTaz Web boot floppy") \
1231 $(:||cdfilex "?pxe*" "runpxe" "Start the SliTaz Web boot utility") \
1232 $(xfile reboot "restart" "Restart the computer") \
1233 $(xfile poweroff "stop" "Power off") \
1234 "bootlog" "Linux boot messages" \
1235 "shell" "Shell prompt"
1236 EOT
1237 exec 3>&1
1238 value=$(. /tmp/dialog 2>&1 1>&3)
1239 retval=$?
1240 exec 3>&-
1241 [ $retval -eq 0 ] || continue
1242 $value
1243 done