wok-current view syslinux/stuff/iso2exe/taziso @ rev 23970

Up tazlito (528)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Oct 04 13:29:03 2020 +0000 (2020-10-04)
parents 3a5c9f8a51f4
children a946c1651082
line source
1 #!/bin/sh
3 [ 0$(id -u 2>/dev/null) -eq 0 ] || exec su -c "$0 $@"
5 DIALOG=dialog
7 ddq()
8 {
9 dd $@ 2> /dev/null
10 }
12 ddn()
13 {
14 ddq conv=notrunc $@
15 }
17 get()
18 {
19 hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %u\n\"" "$2"
20 }
22 bytes2bin()
23 {
24 for i in $@ ; do
25 printf '\\\\x%02X' $(($i&255))
26 done | xargs echo -en
27 }
29 words2bin()
30 {
31 for i in $@ ; do
32 printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255))
33 done | xargs echo -en
34 }
36 quads2bin()
37 {
38 for i in $@ ; do
39 printf '\\\\x%02X\\\\x%02X\\\\x%02X\\\\x%02X' $(($i&255)) \
40 $((($i>>8)&255)) $((($i>>16)&255)) $((($i>>24)&255))
41 done | xargs echo -en
42 }
44 gettazboot()
45 {
46 echo -e "\nCreating $(basename $1) ..."
47 S=$((32+HEADERSZ))
48 P=$((($S+511)/512))
49 E=$((4096-(32*$P)))
50 words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 -16 \
51 -2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1
52 uudecode - >> $1 << EOT
53 HEADERCODE
54 EOT
55 gotcdfile linld.com
56 ddq if=$file >> $1
57 }
59 maybe64()
60 {
61 echo -n $1
62 grep -q ' lm ' /proc/cpuinfo && [ -s ${1}64 ] && echo 64
63 }
65 size()
66 {
67 stat -c %s "$1"
68 }
70 sectcnt()
71 {
72 [ ! -b "$1" ] && echo $(($(size "$1")/512)) ||
73 cat /sys/block/${1#/dev/}/size
74 }
76 uncpio()
77 {
78 i=$1
79 [ $0 = /init.exe ] && i=$(maybe64 $i)
80 [ -s "$i" ] || return
81 echo -en "\n Extracting $(basename $i) ..."
82 case $(get 0 $i) in
83 *35615) ( zcat || gunzip ) ;;
84 *14333) unxz ;;
85 *\ 93) unlzma ;;
86 *) cat ;;
87 esac < $i | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
88 }
90 xdotwait=dotwait
91 dotwait()
92 {
93 echo -n "${1:-Install filesystem}.."
94 echo -n > /tmp/wait
95 [ "$REQUEST_URI" ] && return
96 while [ -e /tmp/wait ]; do
97 echo -n "." > /dev/${tty0:-tty}
98 sleep 1
99 done &
100 }
102 getuuid()
103 {
104 dev=$(mount | sed "/ $(echo $mnt | sed 's|/|\\/|g') /!d;s/ .*//;s|/dev/||;q")
105 [ "$dev" ] &&
106 blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/" ||
107 echo "/dev/hda1"
108 }
110 tazusbinitfs()
111 {
112 PAD=$(($(size $1) % 4))
113 [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1
114 mkdir -p /tmp/fs$$/etc /tmp/fs$$/lib /tmp/fs$$/home
115 cp -a /etc/locale.conf /etc/locale.conf /tmp/fs$$/etc 2> /dev/null
116 cat > /tmp/fs$$/init1 <<EOT
117 #!/bin/sh
118 sed -i 's|sbin/init|init2|' /init
119 exec /init
120 EOT
121 cat > /tmp/fs$$/init2 <<EOT
122 #!/bin/sh
124 mount -t proc /proc /proc
125 for i in /lib/modules/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
126 v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2> /dev/null)
127 mount / -o remount,rw
128 mkdir /mnt/dos
129 rm -f /cmdline 2> /dev/null
130 mount / -o remount,ro
131 mnt=/mnt/dos/\${v#*/}
132 dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q')
133 echo "Mount \$dev in /mnt/dos for \$v..." | tee -a /run/boot.log
134 mount \$dev /mnt/dos
135 if [ ! -d /mnt/dos/slitaz ]; then
136 umount /mnt/dos 2> /dev/null
137 (blkid /dev/[sh]d* || blkid) | while read dev line; do
138 case "\$line" in
139 *ntfs*|*vfat*|*msdos*) ;;
140 *) continue ;;
141 esac
142 mount \${dev%:} /mnt/dos
143 [ -d /mnt/dos/slitaz ] && break
144 umount /mnt/dos
145 done
146 fi
147 $([ "$2" ] || echo '# ')mount.posixovl -F \$mnt -- -oallow_other -odefault_permissions -osuid
148 mount --bind \$mnt /home
149 mount -o size=0,ro -t tmpfs tmpfs \$mnt
150 umount /proc
151 exec /sbin/init
152 EOT
153 chmod 755 /tmp/fs$$/init?
154 ln -s /sqfs/bin/gzip /bin 2> /dev/null
155 ( cd /tmp/fs$$ ; find * | cpio -o -H newc ) | gzip -9 >> $1
156 rm -rf /tmp/fs$$
157 }
159 mkinitrd()
160 {
161 echo -en "\nCreating $(basename $1) "
162 fs=/tmp/fs$$
163 for i in bin lib dev proc tmp mnt etc ; do
164 mkdir -p $fs/$i
165 done
166 for i in /dev/null /dev/tty /dev/tty[012] /dev/fuse /dev/[hs]d* \
167 /dev/console ; do
168 cp -a $2$i $fs/dev/
169 done
170 for i in /bin/busybox $(which mount.posixovl) $(which blkid) \
171 $(which ntfs-3g); do
172 cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \
173 sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') $fs/lib
174 cp $i $fs/bin
175 done
176 cp -a /sqfs/lib/ld-* /tmp/fs/lib 2> /dev/null ||
177 cp -a /lib/ld-* $fs/lib
178 for i in $(busybox | sed '/Current/,$!d'); do
179 [ -e $fs/bin/${i%,} ] || ln -s busybox $fs/bin/${i%,}
180 done
181 ln -s /proc/mounts $fs/etc/mtab
182 sed 's/ .*//' /proc/modules | while read mod ; do
183 find /lib/modules/ | grep $mod.ko | \
184 sed 's|.*|cp & $fs/lib|' | sh
185 done
186 cat > $fs/init <<EOT
187 #!/bin/sh
189 arg()
190 {
191 grep -q \$1 /proc/cmdline &&
192 val="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" < /proc/cmdline)" &&
193 echo "\$2 \$val"
194 }
196 mount -t proc /proc /proc
197 arg debug "shell" && debug=true && set -x
198 for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
199 arg mount "Mount device"
200 dsk=\$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q')
201 mount \$dsk /mnt || mount.ntfs \$dsk /mnt
202 arg subroot "Change root to directory"
203 if [ -d /mnt/\$val ]; then
204 umount /mnt 2> /dev/null
205 (blkid /dev/[sh]d* || blkid) | while read dev line; do
206 case "\$line" in
207 *ntfs*|*vfat*|*msdos*) ;;
208 *) continue ;;
209 esac
210 mount \${dev%:} /mnt
211 [ -d /mnt/\$val ] && break
212 umount /mnt
213 done
214 fi
216 $([ "$3" ] || echo -n '# ')mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid
217 mount --bind /mnt /mnt/\$val/mnt/dos
218 mount -o size=0,ro -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val
219 LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q)
220 export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib
221 [ "$debug" = "true" ] && sh
222 umount /proc
223 exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init
224 EOT
225 chmod +x $fs/init
226 ( cd $fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null
227 rm -rf $fs /tmp/wait
228 }
230 ls_r()
231 {
232 ls -r $@ 2> /dev/null || ls $@
233 }
235 is_loram()
236 {
237 [ -s /lib/modules/squashfs.ko* ]
238 }
240 doinstall()
241 {
242 unset useposixovl
243 blkid | grep $(df $mnt | sed '$!d;s/ .*/:/') | \
244 grep -qiE "(msdos|vfat|ntfs)" && useposixovl=YES
245 case "$mnt" in
246 *mkzip*) useposixovl=YES
247 esac
248 mkdir -p $mnt/slitaz/boot $mnt/slitaz/mnt/dos
249 [ "$useposixovl" ] &&
250 if ! mount.posixovl -F $mnt/slitaz -- \
251 -oallow_other -odefault_permissions -osuid; then
252 echo "Can't install SliTaz. Abort."
253 sleep 5
254 return 1
255 fi
256 dotwait "Install root filesystem in /slitaz.."
257 if [ "$1" ]; then
258 ls_r $media/boot/rootfs*gz | \
259 xargs cat > $mnt/slitaz/boot/rootfs.gz
260 tazusbinitfs $mnt/slitaz/boot/rootfs.gz $useposixovl
261 initrd=rootfs.gz
262 extraargs="/home=$(getuuid)/slitaz rdinit=/init1"
263 else
264 if [ -d $media/fs ]; then
265 cp -a $media/fs/. $mnt/slitaz
266 elif is_loram; then
267 for i in $(ls_r $media/boot/rootfs*); do
268 losetup -o 124 /dev/loop7 $i
269 mount -t squashfs -o ro /dev/loop7 /sqfs/mnt
270 cp -a /sqfs/mnt/. $mnt/slitaz
271 umount /sqfs/mnt
272 losetup -d /dev/loop7
273 done
274 else
275 for i in $(ls_r $media/boot/rootfs*gz); do
276 ${uncpio:-uncpio} $i $mnt/slitaz
277 done
278 fi
279 for i in $packages_list; do
280 tazpkg get-install $i --root=$mnt/slitaz
281 done
282 for i in $packages_dir/*.tazpkg; do
283 [ -s "$i" ] &&
284 tazpkg install $i --root=$mnt/slitaz
285 done
286 cp -a /etc/locale.conf $mnt/slitaz/etc 2> /dev/null
287 cp -a /etc/keymap.conf $mnt/slitaz/etc 2> /dev/null
288 mkinitrd $mnt/slitaz/boot/initrd $mnt/slitaz $useposixovl
289 initrd=initrd
290 extraargs="mount=$(getuuid) subroot=slitaz"
291 fi
292 echo -en "\nInstall boot files..."
293 for i in $media/boot/bzImage* $media/boot/*pxe* \
294 $media/boot/plop.exe \
295 $media/boot/isolinux/he* $media/boot/isolinux/opt* \
296 $media/README $media/boot/memtest* ; do
297 [ -s $i ] && cp $i $mnt/slitaz/boot
298 done
299 for i in $mnt/slitaz/boot/memtest $mnt/slitaz/boot/*pxe ; do
300 [ $(get 0 $i 2> /dev/null || echo 0) -eq 23117 ] &&
301 mv $i $i.exe
302 done
303 bzimage=$(cd $mnt/slitaz/boot ; ls bzimage*)
304 cp /etc/keymap.conf /etc/locale.conf $mnt/slitaz/etc 2> /dev/null
305 gettazboot $mnt/slitaz/boot/tazboot.exe # autoappend 64 suffix
306 unix2dos > $mnt/slitaz/boot/tazboot.cmd <<EOT
307 image=/slitaz/boot/bzimage
308 initrd=/slitaz/boot/$initrd
309 root=/dev/null $extraargs autologin
310 EOT
311 uudecode - <<EOT | gunzip > $mnt/slitaz/boot/slitaz.pif
312 begin-base64 644 -
313 H4sIAAAAAAACA8XPxUHGMBTA8X9ecb/glgFwv+FO23zeI+7ucMFhCjZgEEZh
314 Ctzd4Rf3PFbtQHGLG9BmfmZqdlE/tSmw2LfePzOzWDK0OsQXpPHvFGfZBmL5
315 f3Zns98NuG1BbTrbWj0OFMypSKfT4kYCurKuRleWlBEth2qUTYFBKjg746pI
316 2nZaIT/v9vWwbeuqi9fPznLlSPFLLuK22/0lLT09/BDhXgWKO1f9aLKxOObE
317 EhLuVvO4FksSwaH5qbHpvkle0TyzND82NK+doRVeZgGGbIw0XD2QwV9SnAN/
318 ACxDxwMAAA==
319 ====
320 EOT
321 unix2dos $mnt/slitaz/boot/he* $mnt/slitaz/boot/opt* \
322 $mnt/slitaz/boot/README
323 [ -d $mnt/slitaz/usr/sbin -a ! -x $mnt/slitaz/usr/sbin/mount.posixovl ] &&
324 cp $(which mount.posixovl) $mnt/slitaz/usr/sbin
325 if [ "$useposixovl" ] && grep -qs " $mnt " /proc/mounts &&
326 [ ! -d $mnt/boot/grub ]; then
327 mkdir -p $mnt/boot/grub
328 echo -en "\nInstall grub in /boot/grub..."
329 cp -a /usr/lib/grub/*/* $mnt/boot/grub
330 cat > $mnt/boot/grub/menu.lst <<EOT
331 # /boot/grub/menu.lst: GRUB boot loader configuration.
333 # By default, boot the first entry.
334 default 0
336 # Boot automatically after 8 secs.
337 timeout 8
339 title Microsoft Windows
340 chainloader +1
342 EOT
343 dev=$(grep " $mnt " /proc/mounts | awk '{ print $1 }')
344 base=${dev//[0-9]/}
345 dd if=$base bs=32k count=1 of=$mnt/boot/grub/$(basename $base)
346 cat > $mnt/boot/grub/uninstall-grub.sh <<EOT
347 #!/bin/sh
349 [ -s /boot/grub/$(basename $base) ] &&
350 dd if=/boot/grub/$(basename $base) of=$base
351 EOT
352 grub-install --no-floppy --root-directory=$mnt $base
353 fi
354 if [ -s $mnt/boot/grub/menu.lst ] &&
355 ! grep -q /slitaz/boot/$bzimage $mnt/boot/grub/menu.lst; then
356 echo -en "\nUpdate /boot/grub/menu.lst..."
357 cat >> $mnt/boot/grub/menu.lst <<EOT
358 title SliTaz GNU/Linux $(cat $mnt/slitaz/etc/slitaz-release)
359 kernel /slitaz/boot/$bzimage root=/dev/null $extraargs autologin
360 initrd /slitaz/boot/$initrd
362 EOT
363 fi
364 false &&
365 [ -s $mnt/boot.ini ] && ! grep -qs tazboot $mnt/boot.ini &&
366 echo "Update boot.ini ..." && unix2dos >> $mnt/boot.ini <<EOT
367 C:\\slitaz\\boot\\tazboot.exe="SliTaz"
368 EOT
369 false &&
370 grep -qis menuitem $mnt/config.sys && ! grep -qi tazboot $mnt/config.sys &&
371 echo "Update config.sys ..." &&
372 sed -i 's/menudefault/menuitem SLITAZ, SliTaz\r\n&/' $mnt/config.sys &&
373 unix2dos >> $mnt/config.sys <<EOT
374 [SLITAZ]
375 install=\\slitaz\\boot\\tazboot.exe
376 EOT
377 rm -f $tmp/wait
378 [ "$useposixovl" ] && umount $mnt/slitaz
379 return 0
380 }
382 windev()
383 {
384 if [ -b "$1" ]; then
385 device=$1
386 elif [ "$1" ]; then
387 echo "Invalid Linux/Windows partition"
388 return 1
389 else
390 DEV="$(blkid | grep -iE "(msdos|vfat|ntfs|ext[234]|xfs|btrfs)" | sed 's/:.*//;s|/dev/||')"
391 [ "$DEV" ] || return
392 cat > /tmp/dialog$$ <<EOT
393 $DIALOG --clear --title " Select your Linux/Windows partition " \
394 --menu "\nPlease select the Linux/Windows partition according to its known size.
395 The data will be kept untouched.\n" 17 70 8 \
396 $(for i in $DEV ; do
397 label="$(blkid | sed "/$i:/!d;s/.*://;s/[^ ]*UUID=[^ ]* //g;s/LABEL=//")"
398 echo -n "/dev/$i \"$(($(cat /sys/block/*/$i/size)/2048))MB $label\" "
399 done)
400 EOT
401 exec 3>&1
402 [ $? -eq 0 ] || return
403 device=$(. /tmp/dialog$$ 2>&1 1>&3)
404 exec 3>&-
405 rm -f /tmp/dialog$$
406 fi
407 mnt=/tmp/mnt$$
408 mkdir -p $mnt && mount $device $mnt
409 }
411 extra_packages()
412 {
413 packages_list=
414 packages_dir=
415 [ $0 = /init.exe ] && return
416 $DIALOG --clear --title " Extra packages " \
417 --defaultno --yesno \
418 "Do you want to add extra packages ?" 7 70
419 [ $? -eq 0 ] || return
420 [ -s /var/lib/tazpkg/packages.txt ] || tazpkg recharge
421 if [ -s $media/boot/vmlinuz-$(uname -r) ]; then
422 cat > /tmp/dialog$$ <<EOT
423 $DIALOG --clear --title " Select the packages " \
424 --separate-output \
425 --cancel-label "Skip" \
426 --checklist "Please select the packages you want to install. Try with the first letter." \
427 0 0 0 \\
428 EOT
429 awk -F\| '{ printf "%s \"%s\" off ",$1,$3 }' \
430 /var/lib/tazpkg/packages.desc >> /tmp/dialog$$
431 sh /tmp/dialog$$ 2> /tmp/dialog.out$$
432 [ $? -eq 0 ] && packages_list="$(cat /tmp/dialog.out$$)"
433 fi
434 cat > /tmp/dialog$$ <<EOT
435 $DIALOG --clear \
436 --title "Please select the directory with every custom package to install." \
437 --cancel-label "Skip" --dselect $PWD 13 78
438 EOT
439 sh /tmp/dialog$$ 2> /tmp/dialog.out$$
440 [ $? -eq 0 ] && packages_dir="$(cat /tmp/dialog.out$$)"
441 rm -f /tmp/dialog$$ /tmp/dialog.out$$
442 }
444 _install()
445 {
446 extra_packages
447 $DIALOG --clear --title " SliTaz UMSDOS way installation " \
448 --yes-label "Install" --yesno \
449 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
450 Linux/DOS/Windows partition. You can see your files from /mnt/dos.\n\n
451 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
452 To uninstall SliTaz, you have only to remove this directory.
453 The file \\boot.ini or \\config.sys may be modified too.\n\n
454 SliTaz may run slowly on the 'UMSDOS way' installation due to the
455 posixovl filesystem. The 'TAZUSB way' installation runs faster.\n\n
456 To do a traditional installation with disk partitioning,
457 start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
458 [ $? -eq 0 ] || return
459 doinstall
460 [ $0 = /init.exe ] || return
461 [ -x $mnt/slitaz/sbin/init ] || return
462 umount -d $media/cdrom
463 umount_proc
464 exec chroot $mnt/slitaz /sbin/init
465 }
467 readtazbootconf()
468 {
469 kernel="$(sed '/^image=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)"
470 initrd="$(sed '/^initrd=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)"
471 cmdline="$(sed '/^image=/d;/^initrd=/d' $mnt/slitaz/boot/tazboot.cmd)"
472 }
474 bootinstalled()
475 {
476 [ "$(which kexec)" ] || return
477 [ -x $mnt/slitaz$1 ] || return
478 [ -s $mnt/slitaz/boot/tazboot.cmd ] || return
479 readtazbootconf
480 kexec -l $kernel --initrd $initrd --command-line "$cmdline" || return
481 umount $mnt
482 rm -rf $mnt
483 quit "kexec -e"
484 }
486 mkzip()
487 {
488 device=
489 packages_list=
490 packages_dir=
491 mnt=/tmp/mkzipmnt$$
492 mkdir -p $mnt
493 $1 $2 || return
494 for i in bootlace.com grubinst.exe grldr ; do
495 wget -O $mnt/slitaz/boot/$i http://mirror.slitaz.org/boot/$i
496 done
497 readtazbootconf
498 cat > $mnt/slitaz/boot/menu.lst <<EOT
499 title SliTaz
500 kernel $kernel $cmdline
501 initrd $initrd
503 EOT
504 while read file title; do
505 file=$(ls $mnt/slitaz/boot/*$file* 2> /dev/null)
506 [ -s "$file" ] && cat >> $mnt/slitaz/boot/menu.lst <<EOT
507 title $title
508 kernel ${file#$mnt}
510 EOT
511 done <<EOT
512 memtest MemTest
513 plop USB boot
514 pxe Web boot
515 EOT
516 unix2dos $mnt/slitaz/boot/menu.lst
517 unix2dos > $mnt/slitaz/boot/install.txt <<EOT
518 For DOS users (real mode only):
520 Start SliTaz with \\slitaz\\boot\\tazboot.exe
523 For NT/2000/XP users:
525 1- Move the files grldr and menu.lst into the root directory
527 C:\\> copy \\slitaz\\boot\\grldr \\
528 C:\\> copy \\slitaz\\boot\\menu.lst \\
530 2- Remove boot.ini attributes
532 C:\\> attrib -r -h -s boot.ini
534 3- Append the following line to boot.init
536 C:\\grldr="slitaz"
538 4- Restore boot.ini attributes
540 C:\\> attrib +r +h +s boot.ini
542 See http://diddy.boot-land.net/grub4dos/files/README_GRUB4DOS.txt
543 and http://xpt.sourceforge.net/techdocs/nix/disk/boot/boot07-GrubForDosInfo/ar01s03.html
544 EOT
545 ( cd $mnt ; echo 'See \slitaz\boot\install.txt to launch SliTaz.' | \
546 zip -zr9 $(basename "$ISO" .iso).zip slitaz )
547 [ "$(which advzip)" ] &&
548 echo "Recompressing $(basename "$ISO" .iso).zip ..." &&
549 advzip -z4 $mnt/*.zip
550 mv $mnt/*.zip .
551 du -h $PWD/$(basename "$ISO" .iso).zip
552 umount $mnt
553 rm -rf $mnt
554 }
556 install()
557 {
558 windev $1 || return
559 packages_list=
560 packages_dir=
561 if [ "$1" ]; then
562 doinstall
563 else
564 _install && bootinstalled /sbin/init
565 fi
566 umount $mnt
567 rm -rf $mnt
568 }
570 inst2zip()
571 {
572 if [ "$1" ]; then
573 mkzip doinstall
574 else
575 mkzip _install
576 fi
577 }
579 _installtaz()
580 {
581 $DIALOG --clear --title " SliTaz TAZUSB way installation " \
582 --yes-label "Install" --yesno \
583 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
584 Linux/DOS/Windows partition. You can see your files from /mnt/dos.\n\n
585 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
586 To uninstall SliTaz, you have only to remove this directory.
587 The file \\boot.ini or \\config.sys may be modified too.\n\n
588 The filesystem is loaded entirely into memory upon boot to
589 increase responsiveness. Only /home lands on the hard disk.\n\n
590 To do a traditional installation with disk partitioning,
591 start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
592 [ $? -eq 0 ] || return
593 doinstall tazusblike || return
594 [ $0 = /init.exe ] || return
595 dotwait
596 if [ -d /media/cdrom/fs ]; then
597 cp -a /media/cdrom/fs/. /
598 else
599 for i in $(ls_r /media/cdrom/boot/rootfs*); do
600 ${uncpio:-uncipo} $i
601 done
602 fi
603 cp /tmp/fs/etc/* /etc 2>/dev/null
604 echo "/home=$(getuuid)/slitaz" > /cmdline
605 rm -f /tmp/wait
606 [ -x /init1 ] || return
607 umount -d /media/cdrom
608 umount /mnt/slitaz
609 rm -f /dev/cdrom
610 umount /mnt
611 mkdir /mnt/dos
612 umount_proc
613 exec /init1
614 }
616 installtaz()
617 {
618 windev $1 || return
619 packages_list=
620 packages_dir=
621 if [ "$1" ]; then
622 doinstall tazusblike
623 else
624 _installtaz && bootinstalled /boot/bzimage
625 fi
626 umount $mnt
627 rm -rf $mnt
628 }
630 insttaz2zip()
631 {
632 if [ "$1" ]; then
633 mkzip doinstall tazusblike
634 else
635 mkzip _installtaz
636 fi
637 }
639 bootiso()
640 {
641 cd /tmp
642 for i in $(ls_r $media/boot/rootfs*gz); do
643 i=$(maybe64 $i)
644 cat $i
645 n=$((4 - ($(size $i) % 4)))
646 [ $n -eq 4 ] || dd if=/dev/zero bs=1 count=$n
647 done > initrd$$
648 cmdline="root=/dev/null autologin lang=$LANG"
649 [ -s /etc/keymap.conf ] && cmdline="$cmdline kmap=$(cat /etc/keymap.conf)"
650 [ -s /etc/TZ ] && cmdline="$cmdline tz=$(cat /etc/TZ)"
651 rm -f cmdline initrd 2> /dev/null
652 getcustomconf kexec >/dev/null
653 [ -s cmdline ] && cmdline="$cmdline $(cat cmdline)" && rm cmdline
654 [ -s initrd ] && cat initrd >> initrd$$ && rm initrd
655 kernel=$(maybe64 $media/boot/bzImage)
656 . /etc/locale.conf
657 kexec -l $kernel --initrd initrd$$ --command-line "$cmdline" &&
658 rm -f initrd$$
659 quit "kexec -e"
660 }
662 tazboot()
663 {
664 if [ -z "$1" ]; then
665 $DIALOG --clear --title " SliTaz bootloader for DOS " \
666 --yes-label "Install" --yesno \
667 "\nThe file TAZBOOT.EXE will be created in the top directory. It supports
668 any linux kernel, multiple initramfs and a kernel command line.\n\n
669 Usage: tazboot.exe [[@commands]|[image=<bzimage>]
670 [initrd=<rootfs>[,<rootfs2>...]] cmdline args ...]\n\n
671 Defaults: tazboot @tazboot.cmd or tazboot image=bzImage auto\n\n\
672 Examples for tazboot.cmd:\n\n\
673 image=boot/bzImage\n\
674 initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\
675 root=/dev/null autologin\n\n\
676 image=\\slitaz\\vmlinuz root=/dev/sda5 ro\n" 0 0
677 [ $? -eq 0 ] || return
678 fi
679 gettazboot tazboot.exe
680 du -h $PWD/tazboot.exe
681 }
683 md5()
684 {
685 dotwait "Checking files"
686 ( cd $media ; ${md5sum:-md5sum -c md5sum*} 2>&1 | sort ) > /tmp/data
687 unset md5sum
688 rm -f /tmp/wait
689 if [ "$1" ]; then
690 cat /tmp/data
691 else
692 $DIALOG --clear --title " Checked files " \
693 --textbox /tmp/data 0 0
694 fi
695 rm -f /tmp/data
696 }
698 gotcdfile()
699 {
700 for i in "$media/$1" "$media/*/$1" "$media/*/isolinux/$1" ; do
701 file=$(ls $i 2> /dev/null | sed q)
702 [ -s "$file" ] && break
703 done
704 }
706 sha()
707 {
708 gotcdfile 'sha*sum*'
709 sha=$(basename $file)
710 md5sum="${sha%sum*}sum -c ${file#$media/}"
711 md5 $@
712 }
714 readme()
715 {
716 gotcdfile 'README*'
717 if [ "$1" ]; then
718 cat $file
719 else
720 $DIALOG --clear --title " Readme " --textbox $file 0 0
721 fi
722 }
724 bzimage()
725 {
726 if [ -z "$1" ]; then
727 $DIALOG --clear --title " Create linux.exe ? " \
728 --yes-label "Install" --yesno \
729 "\nLinux.exe launches the linux kernel under DOS (in real mode only).
730 The cmdline arguments are supported except initrd=,
731 vga= (you can try 'rdev -v') and mem= (partially).
732 \nExample:\nC:\\> linux.exe root=/dev/hda2 ro panic=60\n" 12 70
733 [ $? -eq 0 ] || return
734 fi
735 cp $(maybe64 $media/boot/bzImage) linux.exe
736 du -h $PWD/linux.exe
737 }
739 memtest()
740 {
741 if [ -z "$1" ]; then
742 $DIALOG --clear --title " Create memtest.exe ? " \
743 --yes-label "Install" --yesno \
744 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
745 computers. BIOS based memory tests are a quick, cursory check and often
746 miss many of the failures that are detected by Memtest86.\n" 0 0
747 [ $? -eq 0 ] || return
748 fi
749 gotcdfile 'memtest*' && cp $file memtest.exe
750 du -h $PWD/memtest.exe
751 }
753 mkfat12()
754 {
755 [ $(($(get 0 $1) - 0x5A4D)) -eq 0 ] || return
756 J=$(($(get 3 $1 1) + 0x02))
757 R=$((1 + $(get 497 $1 1) + 1 + ($(get 500 $1)-1)/32))
758 [ $R -lt 2500 ] || return
759 [ $((($(get 500 $1)-1) & 31)) -lt 30 ] &&
760 ddq if=$file bs=32 count=1 seek=$(($R*16 - 1)) of=/dev/fd0
761 G="18 0 2 0 0 0 0 0"
762 [ $J -gt 25 ] || G=""
763 F=0
764 for i in 1 2 3; do
765 F=$((((2880-$R-$F-$F)*3+1023)/1024))
766 done
767 bytes2bin 0xEB $J 0x90 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 \
768 0 2 2 $(($R%256)) $(($R/256)) 2 64 0 64 11 0xF0 $F 0 \
769 $G | ddq bs=1 of=/dev/fd0
770 ddq if=/dev/zero bs=512 count=$((4+$F+$F)) seek=$R of=/dev/fd0
771 for i in $R $(($R+$F)) ; do
772 bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0
773 done
774 echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0
775 }
777 mkfloppy()
778 {
779 dotwait "Create a $(basename $1 .exe) boot floppy"
780 ddq if=$1 of=/dev/fd0
781 mkfat12 $1
782 rm -f /tmp/wait
783 }
785 fdmemtest()
786 {
787 if [ -z "$1" ]; then
788 $DIALOG --clear --title " Create a Memtest86 boot floppy " \
789 --yes-label "Create floppy" --yesno \
790 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
791 computers. BIOS based memory tests are a quick, cursory check and often
792 miss many of the failures that are detected by Memtest86.\n\n
793 Please insert a blank disk in floppy drive.\n" 0 0
794 [ $? -eq 0 ] || return
795 fi
796 gotcdfile 'memtest*' && mkfloppy $file
797 }
799 pxe()
800 {
801 gotcdfile '?pxe*'
802 if [ -z "$1" ]; then
803 $DIALOG --clear --title " Create $(basename $file .exe).exe ? " \
804 --yes-label "Install" --yesno \
805 "\nBoot your operating system from the internet and enjoy a full system
806 working entirely in RAM with speed and stability in mind. The Linux Kernel
807 and the complete SliTaz compressed root filesystem will be loaded into RAM
808 from the Web using PXE and HTTP protocols.\n" 0 0
809 [ $? -eq 0 ] || return
810 fi
811 cp $file $(basename $file .exe).exe
812 du -h $PWD/$(basename $file .exe).exe
813 }
815 fdpxe()
816 {
817 if [ -z "$1" ]; then
818 $DIALOG --clear --title " Create a SliTaz Web boot floppy " \
819 --yes-label "Create floppy" --yesno \
820 "\nBoot your operating system from the internet and enjoy a full system
821 working entirely in RAM with speed and stability in mind. The Linux Kernel
822 and the complete SliTaz compressed root filesystem will be loaded into RAM
823 from the Web using PXE and HTTP protocols.\n\n
824 Please insert a blank disk in floppy drive.\n" 0 0
825 [ $? -eq 0 ] || return
826 fi
827 gotcdfile '?pxe*' && mkfloppy $file
828 }
830 plop()
831 {
832 gotcdfile 'plop.exe'
833 if [ -z "$1" ]; then
834 $DIALOG --clear --title " Create $(basename $file .exe).exe ? " \
835 --yes-label "Install" --yesno \
836 "\nBoot your operating system from a USB disk without BIOS support.\n" 0 0
837 [ $? -eq 0 ] || return
838 fi
839 cp $file $(basename $file .exe).exe
840 du -h $PWD/$(basename $file .exe).exe
841 }
843 fdplop()
844 {
845 if [ -z "$1" ]; then
846 $DIALOG --clear --title " Create a Plop boot floppy " \
847 --yes-label "Create floppy" --yesno \
848 "\nBoot your operating system from a USB disk without BIOS support.\n\n
849 Please insert a blank disk in floppy drive.\n" 0 0
850 [ $? -eq 0 ] || return
851 fi
852 gotcdfile 'plop.exe' && mkfloppy $file
853 }
855 menuitem()
856 {
857 [ "$3" ] && shift
858 echo -en "\"$1\" \"$2\""
859 }
861 gotposixovl()
862 {
863 mount.posixovl 2>&1 | grep -qi usage && gotcdfile 'rootfs*.gz' &&
864 menuitem "$@"
865 }
867 gotposixovlzip()
868 {
869 [ "$(which zip)" ] && gotposixovl "$1" "$2"
870 }
872 noinit()
873 {
874 [ $0 = /init.exe ] || menuitem "$@"
875 }
877 initx()
878 {
879 [ $0 = /init.exe ] && menuitem "$@"
880 }
882 xfile()
883 {
884 [ "$(which $1)" ] && menuitem "$@"
885 }
887 initxfile()
888 {
889 [ $0 = /init.exe ] && xfile "$@"
890 }
892 cdfile()
893 {
894 gotcdfile "$1" && menuitem "$@"
895 }
897 gottazusb()
898 {
899 gotcdfile 'rootfs*.gz' && xfile tazusb "$@"
900 }
902 isbzImage()
903 {
904 [ $(get 514 $file 4) -eq 1400005704 ] &&
905 [ $(($(get 529 $file 1) & 1)) -eq 1 ]
906 }
908 cdfilex()
909 {
910 gotcdfile "$1" && [ "$(which kexec)" ] && isbzImage && menuitem "$@"
911 }
913 cdfilef()
914 {
915 [ -e /sys/block/fd0 ] && cdfile "$@"
916 }
918 cdexe()
919 {
920 gotcdfile "$1" &&
921 [ $(get 0 $file 2>/dev/null || echo 0) -eq 23117 ] &&
922 [ $(get 128 $file 2>/dev/null || echo 0) -ne 10 ] &&
923 menuitem "$@"
924 }
926 misspkg()
927 {
928 for i in zip kexec-tools posixovl cdrkit cdrkit-isoinfo ; do
929 [ -d /var/lib/tazpkg/installed/$i/ ] && continue
930 [ "$1" != "install" ] && menuitem "$@" && return
931 tazpkg get-install $i
932 done
933 }
935 noinitmisspkg()
936 {
937 [ $0 = /init.exe ] || misspkg "$@"
938 }
940 missing()
941 {
942 misspkg install
943 }
945 ishybrid()
946 {
947 [ $(get 510 "$ISO") -eq 43605 ] || return
948 C=$((2048*$(get $(((17*2048) + 71)) "$ISO" 4)))
949 [ $(get $C "$ISO" 4) -eq 1 ] || return
950 [ $(get $(($C+30)) "$ISO" 4) -eq $((0x88AA55)) ] || return
951 C=$((2048*$(get $(($C+40)) "$ISO" 4)))
952 [ $(get $(($C+64)) "$ISO" 4) -eq 1886961915 ] && menuitem "$@"
953 }
955 isiso()
956 {
957 [ $(get 32769 "$ISO" 4) -eq 808469571 ] && menuitem "$@"
958 }
960 burnable()
961 {
962 [ "$(sed '/Can wr.*1$/!d' /proc/sys/dev/cdrom/info 2> /dev/null)" ] &&
963 menuitem "$@"
964 }
966 blankable()
967 {
968 [ "$(sed '/Can wr.*RW.*1$/!d' /proc/sys/dev/cdrom/info 2> /dev/null)" ] &&
969 menuitem "$@"
970 }
972 burniso()
973 {
974 wodim -v speed=$(fgrep "drive speed" /proc/sys/dev/cdrom/info | cut -f3) \
975 -eject -multi "$ISO"
976 }
978 blankcd()
979 {
980 wodim -v -blank=fast
981 }
983 customsector()
984 {
985 local c=$(echo $(get 32848 "$ISO" 4))
986 hascustomconf $(($c+16)) && echo $(($c+16)) || echo $c
987 }
989 xhascustomconf=hascustomconf
990 hascustomconf()
991 {
992 [ "$(ddq bs=2k skip=${1:-$(customsector)} if="$ISO" | ddq bs=1 count=6)" \
993 = "#!boot" ]
994 }
996 gotcustomconf()
997 {
998 hascustomconf && menuitem "$@"
999 }
1001 hasflavor()
1003 [ -x /usr/bin/tazlito ] && [ -s $(maybe64 $media/boot/bzImage) ] && menuitem "$@"
1006 gotisomd5()
1008 [ "$(which md5sum 2> /dev/null)" ] &&
1009 [ $(get 0 "$ISO") -eq 23117 ] &&
1010 [ $(get 18 "$ISO") -ne 0 ] && menuitem "$@"
1013 read_return()
1015 echo -e "\rPress RETURN to continue."
1016 read n
1019 getcustomconf()
1021 ddq bs=2k skip=$(customsector) if="$ISO" | while read line; do
1022 case "$line" in
1023 \#!boot*) ;;
1024 append=*) echo ${line#append=} > cmdline && ls -l $PWD/cmdline ;;
1025 initrd:*) cnt=${line#initrd:}
1026 { ddq bs=512 count=$(($cnt / 512));
1027 ddq bs=1 count=$(($cnt % 512)); } > initrd &&
1028 ls -l $PWD/initrd
1029 break ;;
1030 *) break ;;
1031 esac
1032 done
1033 [ "$1" ] || read_return
1036 setcustomconf()
1038 msg="$(stat -c '%12s %.16z %n' $PWD/cmdline $PWD/initrd 2>/dev/null|sed 'N;s|\n|\\n|')"
1039 [ "$msg" ] || msg="These files are not found. Your configuration will be cleared.\\n"
1040 msg="\nUpdate the custom configuration with the files cmdline and initrd\n
1041 in the current directory $PWD. Any missing file is assumed empty.\n\n$msg"
1042 [ "$1" ] && echo -e "$msg" ||
1043 $DIALOG --clear --title " Update custom configuration " \
1044 --yes-label "Update config" --yesno "$msg\n
1045 \nAre you sure to do the update ?\n" 0 0
1046 [ $? -eq 0 ] || return
1047 ddq bs=2k seek=$(customsector) of="$ISO" count=0
1048 if [ "$(ls $PWD/cmdline $PWD/inird 2> /dev/null)" ]; then
1049 rm -f /tmp/custom$$ 2>/dev/null
1050 [ -s $PWD/cmdline ] &&
1051 echo "append=$(cat $PWD/cmdline)" >>/tmp/custom$$
1052 [ -s $PWD/initrd ] &&
1053 echo "initrd:$(size $PWD/initrd)" >>/tmp/custom$$ &&
1054 cat $PWD/initrd >>/tmp/custom$$
1055 echo "#!boot $(md5sum /tmp/custom$$ | sed 's| .*||')" >>"$ISO"
1056 cat /tmp/custom$$ >>"$ISO"
1057 dd if=/dev/zero bs=4k count=1 >>"$ISO"
1058 rm -f /tmp/custom$$
1059 fi
1062 isomd5()
1064 dotwait "Checking iso image"
1065 [ "$(ddq if="$ISO" bs=2k skip=16 \
1066 count=$(($(get 32848 "$ISO" 4)-16)) | md5sum)" = \
1067 "$(ddq if="$ISO" bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \
1068 sed 's/ //g') -" ] && echo "OK" || echo "ERROR"
1069 echo -en "\rChecking iso hybrid boot..."
1070 n=$(($(get 2 "$ISO")-1+($(get 4 "$ISO")-1)*512))
1071 if [ $n -lt 40000 -a $n -gt 32768 ]; then
1072 s=$(get 0 "$ISO" 2 $n | awk '{ i+= $0 } END { print i }')
1073 [ $(((1+$s+$(get $(($n+1)) "$ISO" 1)) % 65536)) -eq 0 ] &&
1074 echo "OK" || echo "ERROR"
1075 fi
1076 if hascustomconf; then
1077 echo -en "\rChecking iso custom config..."
1078 TMP=/tmp/$(basename $0)$$md5
1079 md5="$(ddq bs=2k skip=$(customsector) if="$ISO" | while read line; do
1080 case "$line" in
1081 \#!boot*) echo ${line#*boot } > $TMP ;;
1082 append=*) echo $line ;;
1083 initrd:*) echo $line
1084 cnt=${line#initrd:}
1085 ddq bs=512 count=$((cnt / 512))
1086 ddq bs=1 count=$((cnt % 512))
1087 break ;;
1088 *) break ;;
1089 esac
1090 done | md5sum | cut -c1-32)"
1091 [ "$md5" = "$(cat $TMP)" ] && echo "OK" || echo "ERROR"
1092 rm -f $TMP
1093 fi
1094 rm -f /tmp/wait
1095 [ "$1" ] || read_return
1098 usbdev()
1100 dotwait "Wait 5 seconds for USB devices"
1101 sleep 5
1102 rm -f /tmp/wait
1103 DEV="$(grep -l 1 /sys/block/*/removable | \
1104 sed 's|/sys/block/\(.*\)/removable|\1|')"
1105 [ "$DEV" ] || return
1106 cat > /tmp/dialog$$ <<EOT
1107 $DIALOG --clear --title " Select your USB key " \
1108 --menu "\nPlease select the USB key according to its known size.\n\n" \
1109 0 0 0 \
1110 $(for i in $DEV ; do
1111 grep -qs 1 /sys/block/$i/ro ||
1112 echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2> /dev/null)\" "
1113 done) \
1115 EOT
1116 exec 3>&1
1117 device=$(. /tmp/dialog$$ 2>&1 1>&3)
1118 rm -f /tmp/dialog$$
1119 retval=$?
1120 exec 3>&-
1121 rm -f /tmp/dialog$$
1122 [ $retval -eq 0 ]
1125 tazusbmsg()
1127 [ "$(which tazusb 2> /dev/null)" ] || return
1128 echo "You should choose 'USB key read/write installation' to be
1129 able to save the package updates or your own configuration and data files.\n\n"
1132 gpt_crc32()
1134 t0=00000000; t1=77073096; t2=EE0E612C; t3=990951BA;
1135 t4=076DC419; t5=706AF48F; t6=E963A535; t7=9E6495A3;
1136 t8=0EDB8832; t9=79DCB8A4; t10=E0D5E91E; t11=97D2D988;
1137 t12=09B64C2B; t13=7EB17CBD; t14=E7B82D07; t15=90BF1D91;
1138 t16=1DB71064; t17=6AB020F2; t18=F3B97148; t19=84BE41DE;
1139 t20=1ADAD47D; t21=6DDDE4EB; t22=F4D4B551; t23=83D385C7;
1140 t24=136C9856; t25=646BA8C0; t26=FD62F97A; t27=8A65C9EC;
1141 t28=14015C4F; t29=63066CD9; t30=FA0F3D63; t31=8D080DF5;
1142 t32=3B6E20C8; t33=4C69105E; t34=D56041E4; t35=A2677172;
1143 t36=3C03E4D1; t37=4B04D447; t38=D20D85FD; t39=A50AB56B;
1144 t40=35B5A8FA; t41=42B2986C; t42=DBBBC9D6; t43=ACBCF940;
1145 t44=32D86CE3; t45=45DF5C75; t46=DCD60DCF; t47=ABD13D59;
1146 t48=26D930AC; t49=51DE003A; t50=C8D75180; t51=BFD06116;
1147 t52=21B4F4B5; t53=56B3C423; t54=CFBA9599; t55=B8BDA50F;
1148 t56=2802B89E; t57=5F058808; t58=C60CD9B2; t59=B10BE924;
1149 t60=2F6F7C87; t61=58684C11; t62=C1611DAB; t63=B6662D3D;
1150 t64=76DC4190; t65=01DB7106; t66=98D220BC; t67=EFD5102A;
1151 t68=71B18589; t69=06B6B51F; t70=9FBFE4A5; t71=E8B8D433;
1152 t72=7807C9A2; t73=0F00F934; t74=9609A88E; t75=E10E9818;
1153 t76=7F6A0DBB; t77=086D3D2D; t78=91646C97; t79=E6635C01;
1154 t80=6B6B51F4; t81=1C6C6162; t82=856530D8; t83=F262004E;
1155 t84=6C0695ED; t85=1B01A57B; t86=8208F4C1; t87=F50FC457;
1156 t88=65B0D9C6; t89=12B7E950; t90=8BBEB8EA; t91=FCB9887C;
1157 t92=62DD1DDF; t93=15DA2D49; t94=8CD37CF3; t95=FBD44C65;
1158 t96=4DB26158; t97=3AB551CE; t98=A3BC0074; t99=D4BB30E2;
1159 t100=4ADFA541; t101=3DD895D7; t102=A4D1C46D; t103=D3D6F4FB;
1160 t104=4369E96A; t105=346ED9FC; t106=AD678846; t107=DA60B8D0;
1161 t108=44042D73; t109=33031DE5; t110=AA0A4C5F; t111=DD0D7CC9;
1162 t112=5005713C; t113=270241AA; t114=BE0B1010; t115=C90C2086;
1163 t116=5768B525; t117=206F85B3; t118=B966D409; t119=CE61E49F;
1164 t120=5EDEF90E; t121=29D9C998; t122=B0D09822; t123=C7D7A8B4;
1165 t124=59B33D17; t125=2EB40D81; t126=B7BD5C3B; t127=C0BA6CAD;
1166 t128=EDB88320; t129=9ABFB3B6; t130=03B6E20C; t131=74B1D29A;
1167 t132=EAD54739; t133=9DD277AF; t134=04DB2615; t135=73DC1683;
1168 t136=E3630B12; t137=94643B84; t138=0D6D6A3E; t139=7A6A5AA8;
1169 t140=E40ECF0B; t141=9309FF9D; t142=0A00AE27; t143=7D079EB1;
1170 t144=F00F9344; t145=8708A3D2; t146=1E01F268; t147=6906C2FE;
1171 t148=F762575D; t149=806567CB; t150=196C3671; t151=6E6B06E7;
1172 t152=FED41B76; t153=89D32BE0; t154=10DA7A5A; t155=67DD4ACC;
1173 t156=F9B9DF6F; t157=8EBEEFF9; t158=17B7BE43; t159=60B08ED5;
1174 t160=D6D6A3E8; t161=A1D1937E; t162=38D8C2C4; t163=4FDFF252;
1175 t164=D1BB67F1; t165=A6BC5767; t166=3FB506DD; t167=48B2364B;
1176 t168=D80D2BDA; t169=AF0A1B4C; t170=36034AF6; t171=41047A60;
1177 t172=DF60EFC3; t173=A867DF55; t174=316E8EEF; t175=4669BE79;
1178 t176=CB61B38C; t177=BC66831A; t178=256FD2A0; t179=5268E236;
1179 t180=CC0C7795; t181=BB0B4703; t182=220216B9; t183=5505262F;
1180 t184=C5BA3BBE; t185=B2BD0B28; t186=2BB45A92; t187=5CB36A04;
1181 t188=C2D7FFA7; t189=B5D0CF31; t190=2CD99E8B; t191=5BDEAE1D;
1182 t192=9B64C2B0; t193=EC63F226; t194=756AA39C; t195=026D930A;
1183 t196=9C0906A9; t197=EB0E363F; t198=72076785; t199=05005713;
1184 t200=95BF4A82; t201=E2B87A14; t202=7BB12BAE; t203=0CB61B38;
1185 t204=92D28E9B; t205=E5D5BE0D; t206=7CDCEFB7; t207=0BDBDF21;
1186 t208=86D3D2D4; t209=F1D4E242; t210=68DDB3F8; t211=1FDA836E;
1187 t212=81BE16CD; t213=F6B9265B; t214=6FB077E1; t215=18B74777;
1188 t216=88085AE6; t217=FF0F6A70; t218=66063BCA; t219=11010B5C;
1189 t220=8F659EFF; t221=F862AE69; t222=616BFFD3; t223=166CCF45;
1190 t224=A00AE278; t225=D70DD2EE; t226=4E048354; t227=3903B3C2;
1191 t228=A7672661; t229=D06016F7; t230=4969474D; t231=3E6E77DB;
1192 t232=AED16A4A; t233=D9D65ADC; t234=40DF0B66; t235=37D83BF0;
1193 t236=A9BCAE53; t237=DEBB9EC5; t238=47B2CF7F; t239=30B5FFE9;
1194 t240=BDBDF21C; t241=CABAC28A; t242=53B39330; t243=24B4A3A6;
1195 t244=BAD03605; t245=CDD70693; t246=54DE5729; t247=23D967BF;
1196 t248=B3667A2E; t249=C4614AB8; t250=5D681B02; t251=2A6F2B94;
1197 t252=B40BBE37; t253=C30C8EA1; t254=5A05DF1B; t255=2D02EF8D;
1198 crc=$((0xFFFFFFFF))
1199 dd if=$device bs=1 skip=$(($1)) count=$(($2)) 2> /dev/null | \
1200 od -v -w1 -t u1 -An | {
1201 while read n; do
1202 local x=$((($crc ^ $n) & 255))
1203 eval x=0x\$t$x
1204 crc=$(((($crc >> 8) & 0x00FFFFFF) ^ $x))
1205 done
1206 echo $(($crc ^ 0xFFFFFFFF))
1210 usbbootkey()
1212 if [ -b "$1" ]; then
1213 device=$1
1214 elif [ "$1" ]; then
1215 echo "Invalid USB key device"
1216 return 1
1217 else
1218 $DIALOG --clear --title " Create a USB boot key " \
1219 --yes-label "Continue" --yesno \
1220 "\nThe USB key will be used like a CD-ROM. You will not be able to write
1221 any data on the boot partition.\n\n
1222 An extra FAT32 partition will be created with the remaining free space.\n\n
1223 $(tazusbmsg)Please plug your USB stick in now.\n" 16 70
1224 [ $? -eq 0 ] || return
1225 usbdev || return
1226 fi
1228 # perform dd in progress bar
1229 max=$(($(sectcnt "$ISO")/2048))
1230 i=0; while [ $i -le $max ]; do
1231 ddq if="$ISO" bs=1024k count=1 skip=$i seek=$i of=$device
1232 echo $((($i*100)/$max))
1233 i=$(($i+1))
1234 done | { [ "$1" ] || dialog --gauge \
1235 " The ISO image transfer can be long. Please wait..." \
1236 6 70 0 > /dev/tty 2>&1; }
1238 # GPT partition + fat32 format for the remaining space
1239 sectors=$(($(sectcnt $device)-1))
1240 quads2bin $sectors | ddq bs=1 seek=458 of=$device # pmbr
1241 quads2bin 0 | ddq bs=1 seek=$((512+16)) of=$device
1242 quads2bin $(($sectors-2)) 0 | ddq bs=1 seek=$((512+48)) of=$device
1243 uudecode - <<EOT | gunzip | ddn bs=128 seek=9 of=$device # partiton fat32
1244 begin-base64 644 -
1245 H4sIAAAAAAACA1u04MLrpzuNXdoPZGzbrjbz+C/fHwyfEro9Z7E93Fi5/8sH
1246 BhzAiSGRoZghkyGZQYEhBcguAWIFhgIgWQRkZ4JxPkMeAyEAAOuEo7uAAAAA
1247 ====
1248 EOT
1249 last=$(sectcnt "$ISO")
1250 custom=$((4*$(get 32848 $device 4)))
1251 [ $custom -gt $(($last-4)) ] && last=$(($custom+4)) # room for cmdline
1252 quads2bin $last 0 | ddq bs=1 seek=$((1024+128+32)) of=$device # vfat first address
1253 quads2bin $(($sectors-2)) 0 | ddq bs=1 seek=$((1024+128+40)) of=$device # vfat last address
1254 quads2bin $(gpt_crc32 1024 $(($(get 596 $device 4)*$(get 592 $device 4)))) | \
1255 ddq bs=1 seek=$((512+88)) of=$device # CRC32 partitions
1256 ddn of=$device if=$device bs=512 skip=1 seek=$sectors count=1
1257 ddn of=$device if=$device bs=512 skip=2 seek=$(($sectors-1)) count=1
1258 quads2bin $sectors 0 1 0 | ddq bs=1 seek=$(($sectors*512+24)) of=$device # my gpt, alt gpt
1259 quads2bin 1 0 $sectors 0 | ddq bs=1 seek=$((512+24)) of=$device # my gpt, alt gpt
1260 quads2bin $(($sectors-1)) 0 | ddq bs=1 seek=$(($sectors*512+72)) of=$device
1261 i=$(get 524 $device 4)
1262 quads2bin $(gpt_crc32 $(($sectors*512)) $i) | \
1263 ddq bs=1 seek=$(($sectors*512+16)) of=$device # CRC32 header
1264 quads2bin $(gpt_crc32 512 $i) | ddq bs=1 seek=$((512+16)) of=$device # CRC32 header
1265 partprobe $device
1266 homedev=/dev/$(basename /sys/block/${device#/dev/}/${device#/dev/}*2)
1267 mkdosfs -n 'SLITAZ HOME' $homedev
1269 # update boot/exe crc16
1270 words2bin 0 | ddq bs=1 seek=18 of=$device
1271 i=$(($(get 2 $device) - 1 + ($(get 4 $device) - 1)*512))
1272 i=$(($(od -v -N $i -t u2 -w2 -An $device | \
1273 awk '{ i+= $0 } END { print (i % 65536) }') \
1274 + $(get $(($i+1)) $device 1)))
1275 words2bin $(( (-$i -1) % 65536 )) | ddq bs=1 seek=18 of=$device
1277 [ "$1" ] || $DIALOG --clear --title " Set /home persistent " \
1278 --yes-label "Continue" --yesno \
1279 "\nThe USB key will run fully in ram. The datas will be lost after each reboot.\n\n
1280 This option will mount /home on the USB key vfat during the boot process.\n\n
1281 Your own data will be saved, but the system stay not upgradable.\n" 16 70
1282 if [ $? -eq 0 ]; then
1283 data="append=home=$(blkid $homedev | sed 's|.* UUID="||;s|".*||') kmap=$(cat /etc/keymap.conf) lang=${LANG%.UTF*} tz=$(cat /etc/TZ) loadfs"
1284 cat <<EOT | ddn bs=512 seek=$custom of=$device
1285 #!boot $(echo "$data" | md5sum | sed 's/ .*//')
1286 $data
1287 --
1288 EOT
1289 fi
1292 usbkey()
1294 $DIALOG --clear --title " Create a SliTaz USB key " \
1295 --yes-label "Continue" --yesno \
1296 "\nUnlike a hard drive install, the filesystem is kept in a compressed
1297 rootfs.gz. The filesystem is loaded entirely into memory upon boot.
1298 This should increase responsiveness, protect the filesystem against
1299 accidental corruption and reduce read/writes to the USB drive.
1300 Once setup, the tazusb utility can rewrite the root filesystem
1301 with any changes you have made since booting up,
1302 giving the effective benefits of a hard drive install.\n\n
1303 /home is mounted on boot using the UUID of your particular flash drive.
1304 Unlike a device name, the UUID has the benefit of never changing from machine
1305 to machine.\n\n
1306 Please plug your USB stick in now.\n" 19 70
1307 [ $? -eq 0 ] || return
1308 usbdev || return
1309 exec 3>&1
1310 format=`$DIALOG --clear \
1311 --title " Select the filesystem " \
1312 --radiolist "\nPlease select the filesystem type to create.\n\n\
1313 The filesystem creation will erase all the data in the USB key." 14 70 4 \
1314 "none" "Do not erase the USB key" on \
1315 "ext3" "Ext3 journaling filesystem" off \
1316 "ext2" "Ext2 filesystem" off \
1317 "fat32" "Windows FAT32 filesystem" off \
1318 2>&1 1>&3`
1319 retval=$?
1320 exec 3>&-
1321 [ $retval -eq 0 ] || return
1322 [ "$format" != "none" ] && tazusb format $device "SliTaz" $format
1323 tazusb gen-iso2usb "$ISO" $device
1326 flavdata()
1328 [ $(get 1024 "$ISO") -eq 35615 ] && n=2 || n=$((1+$(get 417 "$ISO" 1)))
1329 [ $n -eq 4 ] && n=20
1330 [ $(get $(($n*512)) "$ISO") -eq 35615 ] || n=13
1331 ddq if="$ISO" bs=512 skip=$n count=20 | zcat 2>/dev/null
1334 hasflavinfo()
1336 [ "$(flavdata | ddq bs=1 count=7)" = "0707010" ] && menuitem "$@"
1339 showfavinfo()
1341 mkdir -p /tmp/data
1342 flavdata | ( cd /tmp/data ; cpio -i )
1343 file=/tmp/data/info
1344 cat /tmp/data/*desc > $file
1345 if [ -s /tmp/data/*receipt ]; then
1346 echo "=== receipt ==="
1347 cat /tmp/data/*receipt
1348 fi >> $file
1349 for i in /tmp/data/*list* ; do
1350 echo "=== extra ${i#*list} files"
1351 cat $i
1352 done >> $file
1353 if [ "$1" ]; then
1354 cat $file
1355 else
1356 $DIALOG --clear --title " Flavor info " \
1357 --textbox $file 0 0
1358 fi
1359 rm -rf /tmp/data
1362 flavor()
1364 name="$(flavdata | cpio -t 2> /dev/null | sed 's/.[a-z]*$//;q')"
1365 echo "Create ${name:=flavor}.flavor..."
1366 tazlito iso2flavor "$ISO" $name
1367 ls -l $name.flavor 2> /dev/null && return
1368 sleep 5
1369 [ "$1" ] || read_return
1372 if [ "$1" = "--build" ]; then #install-begin
1373 uuencode -m - < header.com | sed -e '/^HEADERCODE$/r/dev/stdin' \
1374 -e "s|HEADERSZ|$(size header.com)|" -e '/^HEADERCODE$/d' -i $0
1375 uuencode -m - < ifmem.bin | sed -e '/^ifmemcode$/r/dev/stdin' \
1376 -e '/^ifmemcode$/d' -i $0
1377 uuencode -m - < bootloader.bin | sed -e '/^bootloader$/r/dev/stdin' \
1378 -e '/^bootloader$/d' -e '/install-begin$/,/install-end$/d' -i $0
1379 exit
1380 fi #install-end
1381 parse_isolinux()
1383 awk 'BEGIN { IGNORECASE=1 }
1384 function multi(n)
1386 auto=$n
1387 for (--n; n < NF; n+=2) {
1388 s=$n
1389 if (s ~ /M$/) s = substr(s,0,length(s)-1)
1390 else s /= 1024
1391 sizes=int(s) " " sizes
1393 next
1396 if ($1 == "LABEL") {
1397 label=$2
1398 if (auto == "") auto=label
1400 if ($1 == "KERNEL" || $1 == "COM32") kernel[label]=$2
1401 if ($1 == "INITRD") initrd[label]=$2
1402 if ($1 == "APPEND") {
1403 i=2
1404 if (kernel[label] ~ "ifmem.c32") multi(3)
1405 if (kernel[label] ~ "c32box.c32") {
1406 if ($2 == "linux") { kernel[label]=$3; i=4 }
1407 if ($2 == "ifmem") multi(4)
1409 if (kernel[label] ~ "ifcpu64.c32") { auto=$4; next }
1410 while (i <= NF) {
1411 if ($i ~ "^initrd=") initrd[label]=substr($i,8)
1412 else cmdline[label]=cmdline[label] " " $i
1413 i++
1417 END {
1418 print "KERNEL=\"" kernel[auto] "\""
1419 print "INITRD=\"" initrd[auto] "\""
1420 print "CMDLINE=\"" substr(cmdline[auto],2) "\""
1421 print "SIZES=\"" sizes "\""
1422 }'
1425 locase()
1427 echo "$1" | tr [A-Z] [a-z]
1430 ifmemcode()
1432 uudecode <<EOT
1433 ifmemcode
1434 EOT
1437 floppyset()
1439 gotcdfile 'isolinux.cfg'
1440 $0 include $file | parse_isolinux > /tmp/var$$
1441 . /tmp/var$$
1442 [ -z "$KERNEL" ] && echo "Can't parse isolinux.cfg" && return
1443 for i in $media/$KERNEL $(dirname $file)/$KERNEL $media/$(locase $KERNEL) \
1444 $(dirname $file)/$(locase $KERNEL); do
1445 i="$(ls $i* | sed q)"
1446 [ -n "$i" ] && KERNEL=$i && break
1447 done
1448 rm -f /tmp/var$$
1449 [ $(get 514 $KERNEL 4) -eq 1400005704 ] || return
1450 n=$(($(get 497 $KERNEL 1)+1))
1451 ddq bs=512 count=$n if=$KERNEL of=/tmp/fd$$
1452 uudecode <<EOT | ddn of=/tmp/fd$$
1453 bootloader
1454 EOT
1455 pos=$(($n*512))
1456 if [ -n "$CMDLINE" ]; then
1457 echo -n "$CMDLINE" | ddq bs=512 count=1 conv=sync >> /tmp/fd$$
1458 bytes2bin $n | ddn bs=1 seek=497 of=/tmp/fd$$
1459 words2bin $pos | ddn bs=1 seek=34 of=/tmp/fd$$
1460 [ $(get 518 $KERNEL 4) -ge 514 ] &&
1461 words2bin 32768 9 | ddn bs=1 seek=552 of=/tmp/fd$$
1462 fi
1463 syssize=$(echo $(get 500 /tmp/fd$$ 4))
1464 ddq bs=512 skip=$n if=$KERNEL | cat - /dev/zero | \
1465 ddq bs=512 count=$((($syssize+31)/32)) conv=sync >> /tmp/fd$$
1466 base=$(size /tmp/fd$$)
1467 len=
1468 if [ "$INITRD" ]; then
1469 l=0
1470 for i in ${INITRD//,/ }; do
1471 for j in $media/$i $(dirname $KERNEL)/$i $media/$(locase $i) \
1472 $(dirname $KERNEL)/$(locase $i); do
1473 j="$(ls $j* | sed q)"
1474 [ -n "$j" ] && i=$j && break
1475 done
1476 ddq if=$i >> /tmp/fd$$
1477 l=$(($l+$(size $i)))
1478 r=$((4 - ($l % 4)))
1479 if [ $r -ne 4 ]; then
1480 ddq if=/dev/zero bs=1 count=$r >> /tmp/fd$$
1481 l=$(($l + $r))
1482 fi
1483 case "$i:$INITRD" in
1484 *rootfs.gz:*rootfs.gz,*) continue # loram
1485 esac
1486 len="$len $l"; l=0
1487 done
1488 rdadrs=${RDADRS:-$(((($syssize*16)+0x1F0000) & -4096))}
1489 quads2bin $rdadrs | ddn bs=1 seek=536 of=/tmp/fd$$
1490 fi
1491 n=$(echo $len | wc -w)
1492 if [ $((494 - $(get 494 /tmp/fd$$))) -ge $(($n * 4)) ]; then
1493 i=$(($(get 494 /tmp/fd$$)))
1494 bytes2bin $(($i + ($n*4) - 256)) | ddn bs=1 \
1495 seek=496 of=/tmp/fd$$
1496 else
1497 i=$(($pos + 0x1FC - ($n*4)))
1498 bytes2bin $(($i % 256)) $((i / 256)) 252 | ddn bs=1 \
1499 seek=494 of=/tmp/fd$$
1500 s=$(($i - 2*$(echo "$SIZES" | wc -w)))
1501 p=$(($s - $(ifmemcode | wc -c)))
1502 ifmemcode | ddn bs=1 seek=$p of=/tmp/fd$$
1503 words2bin $SIZES | ddn bs=1 seek=$s of=/tmp/fd$$
1504 bytes2bin 154 $(($p%256)) $(($p/256)) 0 144 | \
1505 ddn bs=1 seek=60 of=/tmp/fd$$
1506 fi
1507 for r in $len ; do
1508 quads2bin $r | ddn bs=1 seek=$i of=/tmp/fd$$
1509 i=$(($i + 4))
1510 done
1511 split -b 1440k /tmp/fd$$ fd$$
1512 rm -f /tmp/fd$$
1513 n=1; i=0; r=0
1514 set -- $len
1515 ls fd$$* | while read file ; do
1516 if [ $i -gt $(($1+$base)) ]; then
1517 shift
1518 r=$(($r+100)); n=0; i=0; base=0
1519 fi
1520 ddq of=$file bs=18k seek=80 count=0
1521 i=$(($i+1474560))
1522 printf "mv %s fd%03d.img\n" $file $(($r+$n))
1523 n=$(($n+1))
1524 done | sh
1525 du -ch $PWD/fd???.img
1528 quit()
1530 umount -d $media
1531 rmdir $media
1532 ${1:-exit}
1535 infoiso()
1537 isoinfo -d -i "$ISO" > /tmp/isoinfo$$
1538 if [ -x "$(which iso2exe)" ]; then
1539 echo "----"
1540 blkid "$ISO" | while read args; do
1541 set -- $args
1542 while [ -n "$2" ]; do
1543 case "$2" in
1544 *UUID*|PT*) echo $2;;
1545 esac
1546 shift
1547 done
1548 done
1549 if ! fdisk -l "$ISO" | grep -q 'valid partition'; then
1550 fdisk -l "$ISO" | grep heads
1551 fdisk -l "$ISO" | sed 's/^ *[^ ]* *//;s/ */ /g;$!d'
1552 fi
1553 echo "----"
1554 iso2exe -l "$ISO"
1555 fi >> /tmp/isoinfo$$
1556 if [ "$1" ]; then
1557 cat /tmp/isoinfo$$
1558 else
1559 $DIALOG --clear --title " Info ISO " \
1560 --textbox /tmp/isoinfo$$ 0 0
1561 fi
1562 rm -f /tmp/isoinfo$$
1565 isotitle()
1567 echo "$(blkid "$ISO" | sed 's/.*LABEL="\([^"]*\).*/\1/') $(stat \
1568 -c %y $media/.|sed 's/ .*//') $(basename "$ISO")"
1571 if [ $0 = /init.exe ]; then
1573 case "${ISO##*/}$(getarg mode)" in
1574 *install*|*INSTALL*) install;;
1575 *live*|*LIVE*) live;;
1576 *text*|*TEXT*) text;;
1577 esac
1578 dmesg > /tmp/dmesg
1580 else
1582 if [ "$1" = "include" ]; then
1583 [ -s "$2" ] && cd $(dirname "$2") && awk -v exe=$0 \
1584 '{ if ($1 == "include") system(exe " include " $2); else print }' <"$2"
1585 exit
1586 fi
1587 ISO="${1:-/dev/null}"
1588 while [ -L "$ISO" ]; do
1589 media="$(readlink "$ISO")"
1590 case "$media" in
1591 /*) ISO="$media" ;;
1592 *) ISO="$(dirname "$ISO")/$media" ;;
1593 esac
1594 done
1595 [ "${ISO:0:1}" != "/" ] && ISO="$(cd $(dirname "$ISO"); echo $PWD/$(basename "$ISO"))"
1596 [ -z "$(isiso 2> /dev/null)" ] && echo "Usage : $0 file.iso" && exit 1
1597 media=/tmp/media$$
1598 mkdir -p $media
1599 mount -o loop,ro "$ISO" $media
1601 if [ "$2" = "list" ]; then
1602 sed '/^\$(.*") \\/!d;s/^\$(\(.*\)").*/\1"/' $0 | while read line; do
1603 eval $line
1604 echo
1605 done | sed '/^$/d;/"usbkey"/d'
1606 quit
1607 fi
1608 if grep -q "^$2()" $0; then
1609 exe=$2
1610 shift 2
1611 if [ -n "$(eval $(grep "\"$exe\"" $0 | sed \
1612 '/^\$/!d;s/.(\(.*\)[\t ]*".*"[\t ]*".*/\1/'))" ]; then
1613 isotitle
1614 grep "\"$exe\"" $0 | sed '/^\$/!d;s/.*"[\t ]*"\(.*\)".*/\1/'
1615 echo ----
1616 $exe "$@"
1617 fi
1618 quit
1619 fi
1620 fi
1622 while true; do
1623 keymap="$(cat /etc/keymap.conf 2>/dev/null)"
1624 locale="$(sed '/^LANG=/!d;s/.*=//' /etc/locale.conf 2>/dev/null)"
1625 cat > /tmp/dialog$$ <<EOT
1626 $DIALOG --clear --title " $(isotitle) " --menu "" 28 70 30 \
1627 $(initxfile tazkeymap "tazkeymap" "Select keyboard (${keymap:-none})") \
1628 $(initxfile tazlocale "tazlocale" "Select locale (${locale:-none})") \
1629 $(initx "live" "Linux RAM boot (full desktop)") \
1630 $(initx "text" "Linux RAM boot") \
1631 $(cdfile 'README*' "readme" "Show the README file") \
1632 $(gotcustomconf "getcustomconf" "Get custom config") \
1633 $(noinit "setcustomconf" "Set custom config") \
1634 $(gotisomd5 "isomd5" "Check the ISO image") \
1635 $(cdfile 'md5sum*' "md5" "Check the ISO files") \
1636 $(cdfile 'sha*sum*' "sha" "Check the ISO files") \
1637 $(xfile isoinfo "infoiso" "ISO image info") \
1638 $(cdfilex 'bzImage*' "bootiso" "Boot the ISO image") \
1639 $(burnable "burniso" "Burn the ISO image") \
1640 $(blankable "blankcd" "Blank the CD/DVD") \
1641 $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \
1642 $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \
1643 $(gotposixovlzip "inst2zip" "ZIP installation archive (UMSDOS way)") \
1644 $(gotposixovlzip "insttaz2zip" "ZIP installation archive (TAZUSB way)") \
1645 $(gottazusb "usbkey" "USB key read/write installation") \
1646 $(ishybrid "usbbootkey" "USB boot key (not upgradable)") \
1647 $(hasflavinfo "showfavinfo" "Show flavor extra info") \
1648 $(hasflavor "flavor" "Get flavor file") \
1649 $(cdfile isolinux.cfg "floppyset" "Boot floppy set") \
1650 $(cdfile linld.com "tazboot" "Get tazboot.exe Linux loader for DOS") \
1651 $(cdexe 'bzImage*' "bzimage" "Get linux DOS/EXE file") \
1652 $(cdexe 'memtest*' "memtest" "Get Memtest86 DOS/EXE file") \
1653 $(cdfilef 'memtest*' "fdmemtest" "Create a Memtest86 boot floppy") \
1654 $(cdexe '?pxe*' "pxe" "Get SliTaz Web boot DOS/EXE utility") \
1655 $(cdfilef '?pxe*' "fdpxe" "Create a SliTaz Web boot floppy") \
1656 $(cdexe 'plop.exe' "plop" "Get USB boot DOS/EXE utility") \
1657 $(cdfilef 'plop.exe' "fdplop" "Create a USB boot floppy") \
1658 $(initxfile reboot "restart" "Restart the computer") \
1659 $(initxfile poweroff "stop" "Power off") \
1660 $(initx "bootlog" "Linux boot messages") \
1661 $(initx "shell" "Shell prompt") \
1662 $(noinitmisspkg "missing" "Install packages to get more options") \
1663 $(noinit "quit" "Quit this utility")
1664 EOT
1665 exec 3>&1
1666 value=$(. /tmp/dialog$$ 2>&1 1>&3)
1667 retval=$?
1668 exec 3>&-
1669 rm -f /tmp/dialog$$
1670 [ $retval -ne 0 ] && [ $0 != /init.exe ] && quit
1671 $value
1672 done