wok view syslinux/stuff/iso2exe/taziso @ rev 21542

fix fusedav
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun May 05 18:36:52 2019 +0200 (2019-05-05)
parents 426eec51ef7c
children 5b74f1dbb49a
line source
1 #!/bin/sh
3 [ $(id -u) -eq 0 ] || exec su -c "$0 $@"
5 DIALOG=dialog
7 ddq()
8 {
9 dd $@ 2> /dev/null
10 }
12 get()
13 {
14 od -v -j $1 -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An "$2" 2>/dev/null ||
15 hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %u\n\"" "$2"
16 }
18 bytes2bin()
19 {
20 for i in $@ ; do
21 printf '\\\\x%02X' $(($i&255))
22 done | xargs echo -en
23 }
25 words2bin()
26 {
27 for i in $@ ; do
28 printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255))
29 done | xargs echo -en
30 }
32 gettazboot()
33 {
34 echo -e "\nCreating $(basename $1) ..."
35 X=$(($(get 20 /mnt/$ISO) - 0xC0))
36 [ $X -lt 30000 ] && X=$((0x7FF0))
37 O=$(($(get 64 "$ISO") - 0xC0))
38 L=$(($X - $(get 24 "$ISO") - $O))
39 S=$((32+$L))
40 P=$((($S+511)/512))
41 E=$((4096-(32*$P)))
42 words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) \
43 -2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1
44 ddq bs=1 count=$(echo $L) skip=$(echo $O) if="$ISO" >> $1
45 }
47 uncpio()
48 {
49 [ -s "$1" ] || return
50 echo -en "\n Extracting $(basename $1) ..."
51 case $(get 0 $1) in
52 *35615) ( zcat || gunzip ) ;;
53 *14333) unxz ;;
54 *\ 93) unlzma ;;
55 *) cat ;;
56 esac < $1 | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
57 }
59 dotwait()
60 {
61 echo -n "${1:-Install filesystem}.."
62 touch /tmp/wait
63 [ "$REQUEST_URI" ] && return
64 while [ -e /tmp/wait ]; do
65 echo -n "." > /dev/tty
66 sleep 1
67 done &
68 }
70 getuuid()
71 {
72 dev=$(mount | sed "/ $(echo $mnt | sed 's|/|\\/|g') /!d;s/ .*//;s|/dev/||;q")
73 [ "$dev" ] &&
74 blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/" ||
75 echo "/dev/hda1"
76 }
78 tazusbinitfs()
79 {
80 PAD=$(($(stat -c %s $1) % 4))
81 [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1
82 mkdir -p /tmp/fs$$/etc /tmp/fs$$/lib /tmp/fs$$/home
83 cp -a /etc/locale.conf /etc/locale.conf /tmp/fs$$/etc 2> /dev/null
84 cat > /tmp/fs$$/init1 <<EOT
85 #!/bin/sh
86 sed -i 's|sbin/init|init2|' /init
87 exec /init
88 EOT
89 cat > /tmp/fs$$/init2 <<EOT
90 #!/bin/sh
92 mount -t proc /proc /proc
93 for i in /lib/modules/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
94 v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2> /dev/null)
95 mount / -o remount,rw
96 mkdir /mnt/dos
97 rm -f /cmdline 2> /dev/null
98 mount / -o remount,ro
99 mnt=/mnt/dos/\${v#*/}
100 dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q')
101 echo "Mount \$dev in /mnt/dos for \$v..." | tee -a /run/boot.log
102 mount \$dev /mnt/dos
103 if [ ! -d /mnt/dos/slitaz ]; then
104 umount /mnt/dos 2> /dev/null
105 (blkid /dev/[sh]d* || blkid) | while read dev line; do
106 case "\$line" in
107 *ntfs*|*vfat*|*msdos*) ;;
108 *) continue ;;
109 esac
110 mount \${dev%:} /mnt/dos
111 [ -d /mnt/dos/slitaz ] && break
112 umount /mnt/dos
113 done
114 fi
115 $([ "$2" ] || echo '# ')mount.posixovl -F \$mnt -- -oallow_other -odefault_permissions -osuid
116 mount --bind \$mnt /home
117 mount -o size=0,ro -t tmpfs tmpfs \$mnt
118 umount /proc
119 exec /sbin/init
120 EOT
121 chmod 755 /tmp/fs$$/init?
122 ln -s /sqfs/bin/gzip /bin 2> /dev/null
123 ( cd /tmp/fs$$ ; find * | cpio -o -H newc ) | gzip -9 >> $1
124 rm -rf /tmp/fs$$
125 }
127 mkinitrd()
128 {
129 echo -en "\nCreating $(basename $1) "
130 fs=/tmp/fs$$
131 for i in bin lib dev proc tmp mnt etc ; do
132 mkdir -p $fs/$i
133 done
134 for i in /dev/null /dev/tty /dev/tty[012] /dev/fuse /dev/[hs]d* \
135 /dev/console ; do
136 cp -a $2$i $fs/dev/
137 done
138 for i in /bin/busybox $(which mount.posixovl) $(which blkid); do
139 cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \
140 sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') $fs/lib
141 cp $i $fs/bin
142 done
143 cp -a /sqfs/lib/ld-* /tmp/fs/lib 2> /dev/null ||
144 cp -a /lib/ld-* $fs/lib
145 for i in $(busybox | sed '/Current/,$!d'); do
146 [ -e $fs/bin/${i%,} ] || ln -s busybox $fs/bin/${i%,}
147 done
148 ln -s /proc/mounts $fs/etc/mtab
149 sed 's/ .*//' /proc/modules | while read mod ; do
150 find /lib/modules/ | grep $mod.ko | \
151 sed 's|.*|cp & $fs/lib|' | sh
152 done
153 cat > $fs/init <<EOT
154 #!/bin/sh
156 arg()
157 {
158 grep -q \$1 /proc/cmdline &&
159 val="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" < /proc/cmdline)" &&
160 echo "\$2 \$val"
161 }
163 mount -t proc /proc /proc
164 arg debug "shell" && debug=true && set -x
165 for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
166 arg mount "Mount device"
167 mount \$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q') /mnt
168 arg subroot "Change root to directory"
169 if [ -d /mnt/\$val ]; then
170 umount /mnt 2> /dev/null
171 (blkid /dev/[sh]d* || blkid) | while read dev line; do
172 case "\$line" in
173 *ntfs*|*vfat*|*msdos*) ;;
174 *) continue ;;
175 esac
176 mount \${dev%:} /mnt
177 [ -d /mnt/\$val ] && break
178 umount /mnt
179 done
180 fi
181 $([ "$3" ] || echo '# ')mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid
182 mount --bind /mnt /mnt/\$val/mnt/dos
183 mount -o size=0,ro -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val
184 LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q)
185 export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib
186 [ "$debug" = "true" ] && sh
187 umount /proc
188 exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init
189 EOT
190 chmod +x $fs/init
191 ( cd $fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null
192 rm -rf $fs /tmp/wait
193 }
195 ls_r()
196 {
197 ls -r $@ 2> /dev/null || ls $@
198 }
200 doinstall()
201 {
202 unset useposixovl
203 blkid | grep $(df $mnt | sed '$!d;s/ .*/:/') | \
204 grep -qiE "(msdos|vfat|ntfs)" && useposixovl=YES
205 case "$mnt" in
206 *mkzip*) useposixovl=YES
207 esac
208 mkdir -p $mnt/slitaz/boot $mnt/slitaz/mnt/dos
209 [ "$useposixovl" ] &&
210 if ! mount.posixovl -F $mnt/slitaz -- \
211 -oallow_other -odefault_permissions -osuid; then
212 echo "Can't install SliTaz. Abort."
213 sleep 5
214 return 1
215 fi
216 dotwait "Install root filesystem in /slitaz.."
217 if [ "$1" ]; then
218 ls_r $media/boot/rootfs*gz | \
219 xargs cat > $mnt/slitaz/boot/rootfs.gz
220 tazusbinitfs $mnt/slitaz/boot/rootfs.gz $useposixovl
221 initrd=rootfs.gz
222 extraargs="/home=$(getuuid)/slitaz rdinit=/init1"
223 else
224 for i in $(ls_r $media/boot/rootfs*gz); do
225 uncpio $i $mnt/slitaz
226 done
227 for i in $packages_list; do
228 tazpkg get-install $i --root=$mnt/slitaz
229 done
230 for i in $packages_dir/*.tazpkg; do
231 [ -s "$i" ] &&
232 tazpkg install $i --root=$mnt/slitaz
233 done
234 cp -a /etc/locale.conf $mnt/slitaz/etc 2> /dev/null
235 cp -a /etc/keymap.conf $mnt/slitaz/etc 2> /dev/null
236 mkinitrd $mnt/slitaz/boot/initrd $mnt/slitaz $useposixovl
237 initrd=initrd
238 extraargs="mount=$(getuuid) subroot=slitaz"
239 fi
240 echo -en "\nInstall boot files..."
241 for i in $media/boot/bzImage* $media/boot/*pxe* \
242 $media/boot/isolinux/he* $media/boot/isolinux/opt* \
243 $media/README $media/boot/memtest* ; do
244 [ -s $i ] && cp $i $mnt/slitaz/boot
245 done
246 for i in $mnt/slitaz/boot/memtest $mnt/slitaz/boot/*pxe ; do
247 [ $(get 0 $i 2> /dev/null || echo 0) -eq 23117 ] &&
248 mv $i $i.exe
249 done
250 bzimage=$(cd $mnt/slitaz/boot ; ls bzimage*)
251 cp /etc/keymap.conf /etc/locale.conf $mnt/slitaz/etc 2> /dev/null
252 gettazboot $mnt/slitaz/boot/tazboot.exe # autoappend 64 suffix
253 unix2dos > $mnt/slitaz/boot/tazboot.cmd <<EOT
254 kernel=/slitaz/boot/bzimage
255 initrd=/slitaz/boot/$initrd
256 rw root=/dev/null $extraargs autologin
257 EOT
258 unix2dos $mnt/slitaz/boot/he* $mnt/slitaz/boot/opt* \
259 $mnt/slitaz/boot/README
260 [ -d $mnt/slitaz/usr/sbin -a ! -x $mnt/slitaz/usr/sbin/mount.posixovl ] &&
261 cp $(which mount.posixovl) $mnt/slitaz/usr/sbin
262 if [ "$useposixovl" ] && grep -qs " $mnt " /proc/mounts &&
263 [ ! -d $mnt/boot/grub ]; then
264 mkdir -p $mnt/boot/grub
265 echo -en "\nInstall grub in /boot/grub..."
266 cp -a /usr/lib/grub/*/* $mnt/boot/grub
267 cat > $mnt/boot/grub/menu.lst <<EOT
268 # /boot/grub/menu.lst: GRUB boot loader configuration.
270 # By default, boot the first entry.
271 default 0
273 # Boot automatically after 8 secs.
274 timeout 8
276 title Microsoft Windows
277 chainloader +1
279 EOT
280 dev=$(grep " $mnt " /proc/mounts | awk '{ print $1 }')
281 base=${dev//[0-9]/}
282 dd if=$base bs=32k count=1 of=$mnt/boot/grub/$(basename $base)
283 cat > $mnt/boot/grub/uninstall-grub.sh <<EOT
284 #!/bin/sh
286 [ -s /boot/grub/$(basename $base) ] &&
287 dd if=/boot/grub/$(basename $base) of=$base
288 EOT
289 grub-install --no-floppy --root-directory=$mnt $base
290 fi
291 if [ -s $mnt/boot/grub/menu.lst ] &&
292 ! grep -q /slitaz/boot/$bzimage $mnt/boot/grub/menu.lst; then
293 echo -en "\nUpdate /boot/grub/menu.lst..."
294 cat >> $mnt/boot/grub/menu.lst <<EOT
295 title SliTaz GNU/Linux $(cat $mnt/slitaz/etc/slitaz-release)
296 kernel /slitaz/boot/$bzimage rw root=/dev/null $extraargs autologin
297 initrd /slitaz/boot/$initrd
299 EOT
300 fi
301 rm -f /tmp/wait
302 [ "$useposixovl" ] && umount $mnt/slitaz
303 return 0
304 }
306 windev()
307 {
308 if [ -b "$1" ]; then
309 device=$1
310 elif [ "$1" ]; then
311 echo "Invalid Linux/Windows partition"
312 return 1
313 else
314 DEV="$(blkid | grep -iE "(msdos|vfat|ntfs|ext[234]|xfs|btrfs)" | sed 's/:.*//;s|/dev/||')"
315 [ "$DEV" ] || return
316 cat > /tmp/dialog$$ <<EOT
317 $DIALOG --clear --title " Select your Linux/Windows partition " \
318 --menu "\nPlease select the Linux/Windows partition according to its known size.
319 The data will be kept untouched.\n" 17 70 8 \
320 $(for i in $DEV ; do
321 label="$(blkid | sed "/$i:/!d;s/.*://;s/[^ ]*UUID=[^ ]* //g;s/LABEL=//")"
322 echo -n "/dev/$i \"$(($(cat /sys/block/*/$i/size)/2048))MB $label\" "
323 done)
324 EOT
325 exec 3>&1
326 [ $? -eq 0 ] || return
327 device=$(. /tmp/dialog$$ 2>&1 1>&3)
328 exec 3>&-
329 rm -f /tmp/dialog$$
330 fi
331 mnt=/tmp/mnt$$
332 mkdir -p $mnt && mount $device $mnt
333 }
335 extra_packages()
336 {
337 packages_list=
338 packages_dir=
339 $DIALOG --clear --title " Extra packages " \
340 --defaultno --yesno \
341 "Do you want to add extra packages ?" 7 70
342 [ $? -eq 0 ] || return
343 [ -s /var/lib/tazpkg/packages.txt ] || tazpkg recharge
344 if [ -s $media/boot/vmlinuz-$(uname -r) ]; then
345 cat > /tmp/dialog$$ <<EOT
346 $DIALOG --clear --title " Select the packages " \
347 --separate-output \
348 --cancel-label "Skip" \
349 --checklist "Please select the packages you want to install. Try with the first letter." \
350 0 0 0 \\
351 EOT
352 awk -F\| '{ printf "%s \"%s\" off ",$1,$3 }' \
353 /var/lib/tazpkg/packages.desc >> /tmp/dialog$$
354 sh /tmp/dialog$$ 2> /tmp/dialog.out$$
355 [ $? -eq 0 ] && packages_list="$(cat /tmp/dialog.out$$)"
356 fi
357 cat > /tmp/dialog$$ <<EOT
358 $DIALOG --clear \
359 --title "Please select the directory with every custom package to install." \
360 --cancel-label "Skip" --dselect $PWD 13 78
361 EOT
362 sh /tmp/dialog$$ 2> /tmp/dialog.out$$
363 [ $? -eq 0 ] && packages_dir="$(cat /tmp/dialog.out$$)"
364 rm -f /tmp/dialog$$ /tmp/dialog.out$$
365 }
367 _install()
368 {
369 extra_packages
370 $DIALOG --clear --title " SliTaz UMSDOS way installation " \
371 --yes-label "Install" --yesno \
372 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
373 Linux/DOS/Windows partition. You can see your files from /mnt/dos.\n\n
374 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
375 To uninstall SliTaz, you have only to remove this directory.
376 The file \\boot.ini or \\config.sys may be modified too.\n\n
377 SliTaz may run slowly on the 'UMSDOS way' installation due to the
378 posixovl filesystem. The 'TAZUSB way' installation runs faster.\n\n
379 To do a traditional installation with disk partitioning,
380 start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
381 [ $? -eq 0 ] || return
382 doinstall
383 }
385 readtazbootconf()
386 {
387 kernel="$(sed '/^kernel=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)"
388 initrd="$(sed '/^initrd=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)"
389 cmdline="$(sed '/^kernel=/d;/^initrd=/d' $mnt/slitaz/boot/tazboot.cmd)"
390 }
392 bootinstalled()
393 {
394 [ "$(which kexec)" ] || return
395 [ -x $mnt/slitaz$1 ] || return
396 [ -s $mnt/slitaz/boot/tazboot.cmd ] || return
397 readtazbootconf
398 kexec -l $kernel --initrd $initrd --command-line "$cmdline" || return
399 umount $mnt
400 rm -rf $mnt
401 quit "kexec -e"
402 }
404 mkzip()
405 {
406 device=
407 packages_list=
408 packages_dir=
409 mnt=/tmp/mkzipmnt$$
410 mkdir -p $mnt
411 $1 $2 || return
412 for i in bootlace.com grubinst.exe grldr ; do
413 wget -O $mnt/slitaz/boot/$i http://mirror.slitaz.org/boot/$i
414 done
415 readtazbootconf
416 cat > $mnt/slitaz/boot/menu.lst <<EOT
417 title SliTaz
418 kernel $kernel $cmdline
419 initrd $initrd
421 EOT
422 while read file title; do
423 file=$(ls $mnt/slitaz/boot/*$file* 2> /dev/null)
424 [ -s "$file" ] && cat >> $mnt/slitaz/boot/menu.lst <<EOT
425 title $title
426 kernel ${file#$mnt}
428 EOT
429 done <<EOT
430 memtest MemTest
431 pxe Web boot
432 EOT
433 unix2dos $mnt/slitaz/boot/menu.lst
434 unix2dos > $mnt/slitaz/boot/install.txt <<EOT
435 For DOS users (real mode only):
437 Start SliTaz with \\slitaz\\boot\\tazboot.exe
440 For NT/2000/XP users:
442 1- Move the files grldr and menu.lst into the root directory
444 C:\\> copy \\slitaz\\boot\\grldr \\
445 C:\\> copy \\slitaz\\boot\\menu.lst \\
447 2- Remove boot.ini attributes
449 C:\\> attrib -r -h -s boot.ini
451 3- Append the following line to boot.init
453 C:\\grldr="slitaz"
455 4- Restore boot.ini attributes
457 C:\\> attrib +r +h +s boot.ini
459 See http://diddy.boot-land.net/grub4dos/files/README_GRUB4DOS.txt
460 and http://xpt.sourceforge.net/techdocs/nix/disk/boot/boot07-GrubForDosInfo/ar01s03.html
461 EOT
462 ( cd $mnt ; echo 'See \slitaz\boot\install.txt to launch SliTaz.' | \
463 zip -zr9 $(basename "$ISO" .iso).zip slitaz )
464 [ "$(which advzip)" ] &&
465 echo "Recompressing $(basename "$ISO" .iso).zip ..." &&
466 advzip -z4 $mnt/*.zip
467 mv $mnt/*.zip .
468 du -h $PWD/$(basename "$ISO" .iso).zip
469 umount $mnt
470 rm -rf $mnt
471 }
473 install()
474 {
475 windev $1 || return
476 packages_list=
477 packages_dir=
478 if [ "$1" ]; then
479 doinstall
480 else
481 _install && bootinstalled /sbin/init
482 fi
483 umount $mnt
484 rm -rf $mnt
485 }
487 inst2zip()
488 {
489 if [ "$1" ]; then
490 mkzip doinstall
491 else
492 mkzip _install
493 fi
494 }
496 _installtaz()
497 {
498 $DIALOG --clear --title " SliTaz TAZUSB way installation " \
499 --yes-label "Install" --yesno \
500 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
501 Linux/DOS/Windows partition. You can see your files from /mnt/dos.\n\n
502 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
503 To uninstall SliTaz, you have only to remove this directory.
504 The file \\boot.ini or \\config.sys may be modified too.\n\n
505 The filesystem is loaded entirely into memory upon boot to
506 increase responsiveness. Only /home lands on the hard disk.\n\n
507 To do a traditional installation with disk partitioning,
508 start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
509 [ $? -eq 0 ] || return
510 doinstall tazusblike
511 }
513 installtaz()
514 {
515 windev $1 || return
516 packages_list=
517 packages_dir=
518 if [ "$1" ]; then
519 doinstall tazusblike
520 else
521 _installtaz && bootinstalled /boot/bzimage
522 fi
523 umount $mnt
524 rm -rf $mnt
525 }
527 insttaz2zip()
528 {
529 if [ "$1" ]; then
530 mkzip doinstall tazusblike
531 else
532 mkzip _installtaz
533 fi
534 }
536 bootiso()
537 {
538 cd /tmp
539 for i in $(ls_r $media/boot/rootfs*gz); do
540 grep -q ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64
541 cat $i
542 n=$((4 - ($(stat -c %s $i) % 4)))
543 [ $n -eq 4 ] || dd if=/dev/zero bs=1 count=$n
544 done > initrd$$
545 cmdline="root=/dev/null autologin lang=$LANG"
546 [ -s /etc/keymap.conf ] && cmdline="$cmdline kmap=$(cat /etc/keymap.conf)"
547 [ -s /etc/TZ ] && cmdline="$cmdline tz=$(cat /etc/TZ)"
548 rm -f cmdline initrd 2> /dev/null
549 getcustomconf kexec >/dev/null
550 [ -s cmdline ] && cmdline="$cmdline $(cat cmdline)" && rm cmdline
551 [ -s initrd ] && cat initrd >> initrd$$ && rm initrd
552 kernel=$media/boot/bzImage
553 grep -q ' lm ' /proc/cpuinfo && [ -s ${kernel}64 ] && kernel=${kernel}64
554 . /etc/locale.conf
555 kexec -l $kernel --initrd initrd$$ --command-line "$cmdline" &&
556 rm -f initrd$$
557 quit "kexec -e"
558 }
560 tazboot()
561 {
562 if [ -z "$1" ]; then
563 $DIALOG --clear --title " SliTaz bootloader for DOS " \
564 --yes-label "Install" --yesno \
565 "\nThe file TAZBOOT.EXE will be created in the top directory. It supports
566 any linux kernel, multiple initramfs, a kernel command line and
567 an ISO image file loopback (retrieves files from an ISO file).\n\n
568 Usage: tazboot.exe [[@commands]|[kernel=<bzimage>]
569 [initrd=<rootfs>[,<rootfs2>...]] [bootfrom=<isofile>] cmdline args ...]\n\n
570 Defaults: tazboot @tazboot.cmd or tazboot kernel=bzImage auto\n\n\
571 Examples for tazboot.cmd:\n\n\
572 bootfrom=\\isos\\slitaz-4.0.iso\n\
573 kernel=boot/bzImage\n\
574 initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\
575 rw root=/dev/null autologin\n\n\
576 kernel=\\slitaz\\vmlinuz root=/dev/sda5 ro\n\n
577 Unlike GRUB4DOS, it doesn't require unfragmented ISO image files.\n" 0 0
578 [ $? -eq 0 ] || return
579 fi
580 gettazboot tazboot.exe
581 du -h $PWD/tazboot.exe
582 }
584 md5()
585 {
586 dotwait "Checking files"
587 ( cd $media ; ${md5sum:-md5sum -c md5sum*} 2>&1 | sort ) > /tmp/data
588 unset md5sum
589 rm -f /tmp/wait
590 if [ "$1" ]; then
591 cat /tmp/data
592 else
593 $DIALOG --clear --title " Checked files " \
594 --textbox /tmp/data 0 0
595 fi
596 rm -f /tmp/data
597 }
599 gotcdfile()
600 {
601 for i in "$media/$1" "$media/*/$1" "$media/*/isolinux/$1" ; do
602 file=$(ls $i 2> /dev/null | sed q)
603 [ -s "$file" ] && break
604 done
605 }
607 sha()
608 {
609 gotcdfile 'sha*sum*'
610 sha=$(basename $file)
611 md5sum="${sha%sum*}sum -c ${file#$media/}"
612 md5 $@
613 }
615 readme()
616 {
617 gotcdfile 'README*'
618 if [ "$1" ]; then
619 cat $file
620 else
621 $DIALOG --clear --title " Readme " --textbox $file 0 0
622 fi
623 }
625 bzimage()
626 {
627 if [ -z "$1" ]; then
628 $DIALOG --clear --title " Create linux.exe ? " \
629 --yes-label "Install" --yesno \
630 "\nLinux.exe launches the linux kernel under DOS (in real mode only).
631 The cmdline arguments are supported except initrd=,
632 vga= (you can try 'rdev -v') and mem= (partially).
633 \nExample:\nC:\\> linux.exe root=/dev/hda2 ro panic=60\n" 12 70
634 [ $? -eq 0 ] || return
635 fi
636 cp $media/boot/bzImage linux.exe
637 du -h $PWD/linux.exe
638 }
640 memtest()
641 {
642 if [ -z "$1" ]; then
643 $DIALOG --clear --title " Create memtest.exe ? " \
644 --yes-label "Install" --yesno \
645 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
646 computers. BIOS based memory tests are a quick, cursory check and often
647 miss many of the failures that are detected by Memtest86.\n" 0 0
648 [ $? -eq 0 ] || return
649 fi
650 gotcdfile 'memtest*' && cp $file memtest.exe
651 du -h $PWD/memtest.exe
652 }
654 mkfat12()
655 {
656 [ $(($(get 0 $1) - 0x5A4D)) -eq 0 ] || return
657 J=$(($(get 3 $1 1) + 0x02))
658 R=$((1 + $(get 497 $1 1) + 1 + ($(get 500 $1)-1)/32))
659 [ $R -lt 2500 ] || return
660 [ $((($(get 500 $1)-1) & 31)) -lt 30 ] &&
661 ddq if=$file bs=32 count=1 seek=$(($R*16 - 1)) of=/dev/fd0
662 G="18 0 2 0 0 0 0 0"
663 [ $J -gt 25 ] || G=""
664 F=0
665 for i in 1 2 3; do
666 F=$((((2880-$R-$F-$F)*3+1023)/1024))
667 done
668 bytes2bin 0xEB $J 0x90 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 \
669 0 2 2 $(($R%256)) $(($R/256)) 2 64 0 64 11 0xF0 $F 0 \
670 $G | ddq bs=1 of=/dev/fd0
671 ddq if=/dev/zero bs=512 count=$((4+$F+$F)) seek=$R of=/dev/fd0
672 for i in $R $(($R+$F)) ; do
673 bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0
674 done
675 echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0
676 }
678 mkfloppy()
679 {
680 dotwait "Create a $(basename $1 .exe) boot floppy"
681 ddq if=$1 of=/dev/fd0
682 mkfat12 $1
683 rm -f /tmp/wait
684 }
686 fdmemtest()
687 {
688 if [ -z "$1" ]; then
689 $DIALOG --clear --title " Create a Memtest86 boot floppy " \
690 --yes-label "Create floppy" --yesno \
691 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
692 computers. BIOS based memory tests are a quick, cursory check and often
693 miss many of the failures that are detected by Memtest86.\n\n
694 Please insert a blank disk in floppy drive.\n" 0 0
695 [ $? -eq 0 ] || return
696 fi
697 gotcdfile 'memtest*' && mkfloppy $file
698 }
700 pxe()
701 {
702 gotcdfile '?pxe*'
703 if [ -z "$1" ]; then
704 $DIALOG --clear --title " Create $(basename $file .exe).exe ? " \
705 --yes-label "Install" --yesno \
706 "\nBoot your operating system from the internet and enjoy a full system
707 working entirely in RAM with speed and stability in mind. The Linux Kernel
708 and the complete SliTaz compressed root filesystem will be loaded into RAM
709 from the Web using PXE and HTTP protocols.\n" 0 0
710 [ $? -eq 0 ] || return
711 fi
712 cp $file $(basename $file .exe).exe
713 du -h $PWD/$(basename $file .exe).exe
714 }
716 fdpxe()
717 {
718 if [ -z "$1" ]; then
719 $DIALOG --clear --title " Create a SliTaz Web boot floppy " \
720 --yes-label "Create floppy" --yesno \
721 "\nBoot your operating system from the internet and enjoy a full system
722 working entirely in RAM with speed and stability in mind. The Linux Kernel
723 and the complete SliTaz compressed root filesystem will be loaded into RAM
724 from the Web using PXE and HTTP protocols.\n\n
725 Please insert a blank disk in floppy drive.\n" 0 0
726 [ $? -eq 0 ] || return
727 fi
728 gotcdfile '?pxe*' && mkfloppy $file
729 }
731 menuitem()
732 {
733 [ "$3" ] && shift
734 echo -en "\"$1\" \"$2\""
735 }
737 gotposixovl()
738 {
739 mount.posixovl 2>&1 | grep -qi usage && gotcdfile 'rootfs*.gz' &&
740 menuitem "$@"
741 }
743 gotposixovlzip()
744 {
745 [ "$(which zip)" ] && gotposixovl "$1" "$2"
746 }
748 xfile()
749 {
750 [ "$(which $1)" ] && menuitem "$@"
751 }
753 cdfile()
754 {
755 gotcdfile "$1" && menuitem "$@"
756 }
758 gottazusb()
759 {
760 gotcdfile 'rootfs*.gz' && xfile tazusb "$@"
761 }
763 isbzImage()
764 {
765 [ $(get 514 $file 4) -eq 1400005704 ] &&
766 [ $(($(get 529 $file 1) & 1)) -eq 1 ]
767 }
769 cdfilex()
770 {
771 gotcdfile "$1" && [ "$(which kexec)" ] && isbzImage && menuitem "$@"
772 }
774 cdfilef()
775 {
776 [ -e /sys/block/fd0 ] && cdfile "$@"
777 }
779 cdexe()
780 {
781 gotcdfile "$1" &&
782 [ $(get 0 $file 2>/dev/null || echo 0) -eq 23117 ] &&
783 menuitem "$@"
784 }
786 misspkg()
787 {
788 for i in zip kexec-tools posixovl cdrkit cdrkit-isoinfo ; do
789 [ -d /var/lib/tazpkg/installed/$i/ ] && continue
790 [ "$1" != "install" ] && menuitem "$@" && return
791 tazpkg get-install $i
792 done
793 }
795 missing()
796 {
797 misspkg install
798 }
800 ishybrid()
801 {
802 [ $(get 510 "$ISO") -eq 43605 ] || return
803 C=$((2048*$(get $(((17*2048) + 71)) "$ISO" 4)))
804 [ $(get $C "$ISO" 4) -eq 1 ] || return
805 [ $(get $(($C+30)) "$ISO" 4) -eq $((0x88AA55)) ] || return
806 C=$((2048*$(get $(($C+40)) "$ISO" 4)))
807 [ $(get $(($C+64)) "$ISO" 4) -eq 1886961915 ] && menuitem "$@"
808 }
810 isiso()
811 {
812 [ $(get 32769 "$ISO" 4) -eq 808469571 ] && menuitem "$@"
813 }
815 hastazboot()
816 {
817 [ $(get 0 "$ISO") -eq 23117 ] && menuitem "$@"
818 }
820 burnable()
821 {
822 [ "$(sed '/Can wr.*1$/!d' /proc/sys/dev/cdrom/info 2> /dev/null)" ] &&
823 menuitem "$@"
824 }
826 blankable()
827 {
828 [ "$(sed '/Can wr.*RW.*1$/!d' /proc/sys/dev/cdrom/info 2> /dev/null)" ] &&
829 menuitem "$@"
830 }
832 burniso()
833 {
834 wodim -v speed=$(fgrep "drive speed" /proc/sys/dev/cdrom/info | cut -f3) \
835 -eject -multi "$ISO"
836 }
838 blankcd()
839 {
840 wodim -v -blank=fast
841 }
843 customsector()
844 {
845 local c=$(echo $(get 32848 "$ISO" 4))
846 hascustomconf $(($c+16)) && echo $(($c+16)) || echo $c
847 }
849 hascustomconf()
850 {
851 [ "$(ddq bs=2k skip=${1:-$(customsector)} if="$ISO" | ddq bs=1 count=6)" \
852 = "#!boot" ]
853 }
855 gotcustomconf()
856 {
857 hascustomconf && menuitem "$@"
858 }
860 hasflavor()
861 {
862 [ -x /usr/bin/tazlito ] && [ -s $media/boot/bzImage ] && menuitem "$@"
863 }
865 gotisomd5()
866 {
867 [ "$(which md5sum 2> /dev/null)" ] &&
868 [ $(get 0 "$ISO") -eq 23117 ] &&
869 [ $(get 18 "$ISO") -ne 0 ] && menuitem "$@"
870 }
872 getcustomconf()
873 {
874 ddq bs=2k skip=$(customsector) if="$ISO" | while read line; do
875 case "$line" in
876 \#!boot*) ;;
877 append=*) echo ${line#append=} > cmdline && ls -l $PWD/cmdline ;;
878 initrd:*) cnt=${line#initrd:}
879 { ddq bs=512 count=$(($cnt / 512));
880 ddq bs=1 count=$(($cnt % 512)); } > initrd &&
881 ls -l $PWD/initrd
882 break ;;
883 *) break ;;
884 esac
885 done
886 [ "$1" ] && return 0
887 echo -e "\rPress RETURN to continue."
888 read n
889 }
891 isomd5()
892 {
893 dotwait "Checking iso image"
894 [ "$(ddq if="$ISO" bs=2k skip=16 \
895 count=$(($(get 32848 "$ISO" 4)-16)) | md5sum)" = \
896 "$(ddq if="$ISO" bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \
897 sed 's/ //g') -" ] && echo "OK" || echo "ERROR"
898 echo -en "\rChecking iso hybrid boot..."
899 n=$(($(get 2 "$ISO")-1+($(get 4 "$ISO")-1)*512))
900 if [ $n -lt 40000 -a $n -gt 32768 ]; then
901 s=$(get 0 "$ISO" 2 $n | awk '{ i+= $0 } END { print i }')
902 [ $(((1+$s+$(get $(($n+1)) "$ISO" 1)) % 65536)) -eq 0 ] &&
903 echo "OK" || echo "ERROR"
904 fi
905 if hascustomconf; then
906 echo -en "\rChecking iso custom config..."
907 TMP=/tmp/$(basename $0)$$md5
908 md5="$(ddq bs=2k skip=$(customsector) if="$ISO" | while read line; do
909 case "$line" in
910 \#!boot*) echo ${line#*boot } > $TMP ;;
911 append=*) echo $line ;;
912 initrd:*) echo $line
913 cnt=${line#initrd:}
914 ddq bs=512 count=$((cnt / 512))
915 ddq bs=1 count=$((cnt % 512))
916 break ;;
917 *) break ;;
918 esac
919 done | md5sum | cut -c1-32)"
920 [ "$md5" = "$(cat $TMP)" ] && echo "OK" || echo "ERROR"
921 rm -f $TMP
922 fi
923 rm -f /tmp/wait
924 [ "$1" ] && return 0
925 echo -e "\rPress RETURN to continue."
926 read n
927 }
929 usbdev()
930 {
931 dotwait "Wait 5 seconds for USB devices"
932 sleep 5
933 rm -f /tmp/wait
934 DEV="$(grep -l 1 /sys/block/*/removable | \
935 sed 's|/sys/block/\(.*\)/removable|\1|')"
936 grep -qs 1 /sys/block/$DEV/ro && return
937 [ "$DEV" ] || return
938 cat > /tmp/dialog$$ <<EOT
939 $DIALOG --clear --title " Select your USB key " \
940 --menu "\nPlease select the USB key according to its known size.\n\n" \
941 0 0 0 \
942 $(for i in $DEV ; do
943 echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2> /dev/null)\" "
944 done) \
946 EOT
947 exec 3>&1
948 device=$(. /tmp/dialog$$ 2>&1 1>&3)
949 rm -f /tmp/dialog$$
950 retval=$?
951 exec 3>&-
952 rm -f /tmp/dialog$$
953 [ $retval -eq 0 ]
954 }
956 tazusbmsg()
957 {
958 [ "$(which tazusb 2> /dev/null)" ] || return
959 echo "You should choose 'USB key read/write installation' to be
960 able to save the package updates or your own configuration and data files.\n\n"
961 }
963 usbbootkey()
964 {
965 if [ -b "$1" ]; then
966 device=$1
967 elif [ "$1" ]; then
968 echo "Invalid USB key device"
969 return 1
970 else
971 $DIALOG --clear --title " Create a USB boot key " \
972 --yes-label "Continue" --yesno \
973 "\nThe USB key will be used like a CD-ROM. You will not be able to write
974 any data on the boot partition.\n\n
975 An extra FAT32 partition will be created with the remaining free space.\n\n
976 $(tazusbmsg)Please plug your USB stick in now.\n" 16 70
977 [ $? -eq 0 ] || return
978 usbdev || return
980 # perform dd in progress bar
981 max=$(($(stat -c %s "$ISO")/2048))
982 i=0; ddq if="$ISO" bs=1024k | (
983 while ddq bs=1024k count=1 ; do
984 i=$(($i + 1))
985 [ $i -gt $max ] && break
986 echo $((($i*100)/$max)) | dialog --gauge \
987 " The ISO image transfer can be long. Please wait..." \
988 6 70 0 > /dev/tty 2>&1
989 done ) > $device
990 fi
992 # partition + fat32 format for the remaining space
993 for p in 0 16; do
994 get $((450+$p)) $device 2 12 | xargs echo | {
995 read dx cx ol oh ll lh
996 [ $dx -eq $((0x3F17)) ] || continue
997 cx=$(($cx & 0xFF00))
998 ofs=$(($ll+($lh<<16)))
999 n=$(($(cat /sys/block/${device#/dev/}/size)-$ofs))
1000 m=$(($cx+($n/8)))
1001 [ $m -gt $((0x3FF00)) ] && m=$((0x3FF00))
1002 m=$((($m & 0xFF00)+(($m>>16)<<6)))
1003 words2bin 0 $((0x101+$cx)) 0x3F0B $((32+$m)) \
1004 $ll $lh $(($n & 0xFFFF)) $(($n >> 16)) | \
1005 ddq bs=1 seek=$((462-$p)) of=$device
1006 if [ "$(which mkdosfs 2> /dev/null)" ]; then
1007 losetup -o $((512*$ofs)) /dev/loop2 $device
1008 mkdosfs -n "SLITAZ BOOT" /dev/loop2
1009 words2bin $(($ofs & 0xFFFF)) $(($ofs >> 16)) | \
1010 ddq bs=1 seek=28 of=/dev/loop2
1011 sync
1012 losetup -d /dev/loop2
1013 fi
1015 done
1018 usbkey()
1020 $DIALOG --clear --title " Create a SliTaz USB key " \
1021 --yes-label "Continue" --yesno \
1022 "\nUnlike a hard drive install, the filesystem is kept in a compressed
1023 rootfs.gz. The filesystem is loaded entirely into memory upon boot.
1024 This should increase responsiveness, protect the filesystem against
1025 accidental corruption and reduce read/writes to the USB drive.
1026 Once setup, the tazusb utility can rewrite the root filesystem
1027 with any changes you have made since booting up,
1028 giving the effective benefits of a hard drive install.\n\n
1029 /home is mounted on boot using the UUID of your particular flash drive.
1030 Unlike a device name, the UUID has the benefit of never changing from machine
1031 to machine.\n\n
1032 Please plug your USB stick in now.\n" 19 70
1033 [ $? -eq 0 ] || return
1034 usbdev || return
1035 exec 3>&1
1036 format=`$DIALOG --clear \
1037 --title " Select the filesystem " \
1038 --radiolist "\nPlease select the filesystem type to create.\n\n\
1039 The filesystem creation will erase all the data in the USB key." 14 70 4 \
1040 "none" "Do not erase the USB key" on \
1041 "ext3" "Ext3 journaling filesystem" off \
1042 "ext2" "Ext2 filesystem" off \
1043 "fat32" "Windows FAT32 filesystem" off \
1044 2>&1 1>&3`
1045 retval=$?
1046 exec 3>&-
1047 [ $retval -eq 0 ] || return
1048 [ "$format" != "none" ] && tazusb format $device "SliTaz" $format
1049 tazusb gen-iso2usb "$ISO" $device
1052 dokexec()
1054 kexec -l $file || return
1055 quit "kexec -e"
1058 runmemtest()
1060 gotcdfile 'memtest*' && dokexec
1063 runpxe()
1065 gotcdfile '?pxe*' && dokexec
1068 flavdata()
1070 [ $(get 1024 "$ISO") -eq 35615 ] && n=2 || n=$((1+$(get 417 "$ISO" 1)))
1071 [ $n -eq 4 ] && n=20
1072 [ $(get $(($n*512)) "$ISO") -eq 35615 ] || n=13
1073 ddq if="$ISO" bs=512 skip=$n count=20 | zcat 2>/dev/null
1076 hasflavinfo()
1078 [ "$(flavdata | ddq bs=1 count=7 | strings)" = \
1079 "0707010" ] && menuitem "$@"
1082 showfavinfo()
1084 mkdir -p /tmp/data
1085 flavdata | ( cd /tmp/data ; cpio -i )
1086 file=/tmp/data/info
1087 cat /tmp/data/*desc > $file
1088 if [ -s /tmp/data/*receipt ]; then
1089 echo "=== receipt ==="
1090 cat /tmp/data/*receipt
1091 fi >> $file
1092 for i in /tmp/data/*list* ; do
1093 echo "=== extra ${i#*list} files"
1094 cat $i
1095 done >> $file
1096 if [ "$1" ]; then
1097 cat $file
1098 else
1099 $DIALOG --clear --title " Flavor info " \
1100 --textbox $file 0 0
1101 fi
1102 rm -rf /tmp/data
1105 flavor()
1107 name="$(flavdata | cpio -t 2> /dev/null | sed 's/.[a-z]*$//;q')"
1108 echo "Create ${name:=flavor}.flavor..."
1109 tazlito iso2flavor "$ISO" $name
1110 ls -l $name.flavor 2> /dev/null && return
1111 sleep 5
1112 [ "$1" ] && return
1113 echo -e "\rPress RETURN to continue."
1114 read n
1117 if [ "$1" = "--build" ]; then #install-begin
1118 uuencode -m - < ifmem.bin | sed -e '/^ifmemcode$/r/dev/stdin' \
1119 -e '/^ifmemcode$/d' -i $0
1120 uuencode -m - < bootloader.bin | sed -e '/^bootloader$/r/dev/stdin' \
1121 -e '/^bootloader$/d' -e '/install-begin$/,/install-end$/d' -i $0
1122 exit
1123 fi #install-end
1124 parse_isolinux()
1126 awk 'BEGIN { IGNORECASE=1 }
1127 function multi(n)
1129 auto=$n
1130 for (--n; n < NF; n+=2) {
1131 s=$n
1132 if (s ~ /M$/) s = substr(s,0,length(s)-1)
1133 else s /= 1024
1134 sizes=int(s) " " sizes
1136 next
1139 if ($1 == "LABEL") {
1140 label=$2
1141 if (auto == "") auto=label
1143 if ($1 == "KERNEL" || $1 == "COM32") kernel[label]=$2
1144 if ($1 == "INITRD") initrd[label]=$2
1145 if ($1 == "APPEND") {
1146 i=2
1147 if (kernel[label] ~ "ifmem.c32") multi(3)
1148 if (kernel[label] ~ "c32box.c32") {
1149 if ($2 == "linux") { kernel[label]=$3; i=4 }
1150 if ($2 == "ifmem") multi(4)
1152 if (kernel[label] ~ "ifcpu64.c32") { auto=$4; next }
1153 while (i <= NF) {
1154 if ($i ~ "^initrd=") initrd[label]=substr($i,8)
1155 else cmdline[label]=cmdline[label] " " $i
1156 i++
1160 END {
1161 print "KERNEL=\"" kernel[auto] "\""
1162 print "INITRD=\"" initrd[auto] "\""
1163 print "CMDLINE=\"" substr(cmdline[auto],2) "\""
1164 print "SIZES=\"" sizes "\""
1165 }'
1168 locase()
1170 echo "$1" | tr [A-Z] [a-z]
1173 ifmemcode()
1175 uudecode <<EOT
1176 ifmemcode
1177 EOT
1180 floppyset()
1182 gotcdfile 'isolinux.cfg'
1183 $0 include $file | parse_isolinux > /tmp/var$$
1184 . /tmp/var$$
1185 [ -z "$KERNEL" ] && echo "Can't parse isolinux.cfg" && return
1186 for i in $media/$KERNEL $(dirname $file)/$KERNEL $media/$(locase $KERNEL) \
1187 $(dirname $file)/$(locase $KERNEL); do
1188 i="$(ls $i* | sed q)"
1189 [ -n "$i" ] && KERNEL=$i && break
1190 done
1191 rm -f /tmp/var$$
1192 [ $(get 514 $KERNEL 4) -eq 1400005704 ] || return
1193 n=$(($(get 497 $KERNEL 1)+1))
1194 ddq bs=512 count=$n if=$KERNEL of=/tmp/fd$$
1195 uudecode <<EOT | ddq of=/tmp/fd$$ conv=notrunc
1196 bootloader
1197 EOT
1198 pos=$(($n*512))
1199 if [ -n "$CMDLINE" ]; then
1200 echo -n "$CMDLINE" | ddq bs=512 count=1 conv=sync >> /tmp/fd$$
1201 bytes2bin $n | ddq conv=notrunc \
1202 bs=1 seek=497 count=1 of=/tmp/fd$$
1203 words2bin $pos | ddq conv=notrunc \
1204 bs=1 seek=34 count=2 of=/tmp/fd$$
1205 [ $(get 518 $KERNEL 4) -ge 514 ] &&
1206 words2bin 32768 9 | ddq conv=notrunc \
1207 bs=1 seek=552 count=4 of=/tmp/fd$$
1208 fi
1209 syssize=$(echo $(get 500 /tmp/fd$$ 4))
1210 ddq bs=512 skip=$n if=$KERNEL | cat - /dev/zero | \
1211 ddq bs=512 count=$((($syssize+31)/32)) conv=sync >> /tmp/fd$$
1212 base=$(stat -c %s /tmp/fd$$)
1213 len=
1214 if [ "$INITRD" ]; then
1215 l=0
1216 for i in ${INITRD//,/ }; do
1217 for j in $media/$i $(dirname $KERNEL)/$i $media/$(locase $i) \
1218 $(dirname $KERNEL)/$(locase $i); do
1219 j="$(ls $j* | sed q)"
1220 [ -n "$j" ] && i=$j && break
1221 done
1222 ddq if=$i >> /tmp/fd$$
1223 l=$(($l+$(stat -c %s $i)))
1224 r=$((4 - ($l % 4)))
1225 if [ $r -ne 4 ]; then
1226 ddq if=/dev/zero bs=1 count=$r >> /tmp/fd$$
1227 l=$(($l + $r))
1228 fi
1229 case "$i:$INITRD" in
1230 *rootfs.gz:*rootfs.gz,*) continue # loram
1231 esac
1232 len="$len $l"; l=0
1233 done
1234 rdadrs=${RDADRS:-$(((($syssize*16)+0x1F0000) & -4096))}
1235 words2bin $(($rdadrs & 0xFFFF)) $(($rdadrs >> 16)) | ddq \
1236 conv=notrunc bs=1 seek=536 count=4 of=/tmp/fd$$
1237 fi
1238 n=$(echo $len | wc -w)
1239 if [ $((494 - $(get 494 /tmp/fd$$))) -ge $(($n * 4)) ]; then
1240 i=$(($(get 494 /tmp/fd$$)))
1241 bytes2bin $(($i + ($n*4) - 256)) | ddq bs=1 conv=notrunc \
1242 seek=496 count=1 of=/tmp/fd$$
1243 else
1244 i=$(($pos + 0x1FC - ($n*4)))
1245 bytes2bin $(($i % 256)) $((i / 256)) 252 | ddq bs=1 \
1246 conv=notrunc seek=494 count=3 of=/tmp/fd$$
1247 s=$(($i - 2*$(echo "$SIZES" | wc -w)))
1248 p=$(($s - $(ifmemcode | wc -c)))
1249 ifmemcode | ddq bs=1 conv=notrunc seek=$p of=/tmp/fd$$
1250 words2bin $SIZES | ddq bs=1 conv=notrunc seek=$s of=/tmp/fd$$
1251 bytes2bin 154 $(($p%256)) $(($p/256)) 0 144 | \
1252 ddq bs=1 conv=notrunc seek=60 of=/tmp/fd$$
1253 fi
1254 for r in $len ; do
1255 words2bin $(($r & 0xFFFF)) $(($r >> 16)) | ddq conv=notrunc \
1256 bs=1 seek=$i count=4 of=/tmp/fd$$
1257 i=$(($i + 4))
1258 done
1259 split -b 1440k /tmp/fd$$ fd$$
1260 rm -f /tmp/fd$$
1261 n=1; i=0; r=0
1262 set -- $len
1263 ls fd$$* | while read file ; do
1264 if [ $i -gt $(($1+$base)) ]; then
1265 shift
1266 r=$(($r+100)); n=0; i=0; base=0
1267 fi
1268 ddq of=$file bs=18k seek=80 count=0
1269 i=$(($i+1474560))
1270 printf "mv %s fd%03d.img\n" $file $(($r+$n))
1271 n=$(($n+1))
1272 done | sh
1273 du -ch $PWD/fd???.img
1276 quit()
1278 umount -d $media
1279 rmdir $media
1280 ${1:-exit}
1283 infoiso()
1285 isoinfo -d -i "$ISO" > /tmp/isoinfo$$
1286 if [ -x "$(which iso2exe)" ]; then
1287 echo "----"
1288 blkid "$ISO" | while read args; do
1289 set -- $args
1290 while [ -n "$2" ]; do
1291 case "$2" in
1292 *UUID*|PT*) echo $2;;
1293 esac
1294 shift
1295 done
1296 done
1297 if ! fdisk -l "$ISO" | grep -q 'valid partition'; then
1298 fdisk -l "$ISO" | grep heads
1299 fdisk -l "$ISO" | sed 's/^ *[^ ]* *//;s/ */ /g;$!d'
1300 fi
1301 echo "----"
1302 iso2exe -l "$ISO"
1303 fi >> /tmp/isoinfo$$
1304 if [ "$1" ]; then
1305 cat /tmp/isoinfo$$
1306 else
1307 $DIALOG --clear --title " Info ISO " \
1308 --textbox /tmp/isoinfo$$ 0 0
1309 fi
1310 rm -f /tmp/isoinfo$$
1313 isotitle()
1315 echo "$(blkid "$ISO" | sed 's/.*LABEL="\([^"]*\).*/\1/') $(stat \
1316 -c %y $media/.|sed 's/ .*//') $(basename "$ISO")"
1319 if [ "$1" = "include" ]; then
1320 [ -s "$2" ] && cd $(dirname "$2") && awk -v exe=$0 \
1321 '{ if ($1 == "include") system(exe " include " $2); else print }' <"$2"
1322 exit
1323 fi
1324 ISO="${1:-/dev/null}"
1325 [ ${ISO:0:1} != "/" ] && ISO=$(cd $(dirname $ISO); echo $PWD/$(basename $ISO))
1326 [ -z "$(isiso 2> /dev/null)" ] && echo "Usage : $0 file.iso" && exit 1
1327 media=/tmp/media$$
1328 mkdir -p $media
1329 mount -o loop,ro "$ISO" $media
1331 if [ "$2" = "list" ]; then
1332 sed '/^\$(.*") \\/!d;s/^\$(\(.*\)").*/\1"/' $0 | while read line; do
1333 eval $line
1334 echo
1335 done | sed '/^$/d;/"usbkey"/d'
1336 quit
1337 fi
1338 if grep -q "^$2()" $0; then
1339 exe=$2
1340 shift 2
1341 if [ -n "$(eval $(grep "\"$exe\"" $0 | sed \
1342 '/^\$/!d;s/.(\(.*\)[\t ]*".*"[\t ]*".*/\1/'))" ]; then
1343 isotitle
1344 grep "\"$exe\"" $0 | sed '/^\$/!d;s/.*"[\t ]*"\(.*\)".*/\1/'
1345 echo ----
1346 $exe "$@"
1347 fi
1348 quit
1349 fi
1351 while true; do
1352 cat > /tmp/dialog$$ <<EOT
1353 $DIALOG --clear --title " $(isotitle) " --menu "" 28 70 30 \
1354 $(cdfile 'README*' "readme" "Show the README file") \
1355 $(gotcustomconf "getcustomconf" "Get custom config") \
1356 $(gotisomd5 "isomd5" "Check the ISO image") \
1357 $(cdfile 'md5sum*' "md5" "Check the ISO files") \
1358 $(cdfile 'sha*sum*' "sha" "Check the ISO files") \
1359 $(xfile isoinfo "infoiso" "ISO image info") \
1360 $(cdfilex boot/bzImage "bootiso" "Boot the ISO image") \
1361 $(burnable "burniso" "Burn the ISO image") \
1362 $(blankable "blankcd" "Blank the CD/DVD") \
1363 $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \
1364 $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \
1365 $(gotposixovlzip "inst2zip" "ZIP installation archive (UMSDOS way)") \
1366 $(gotposixovlzip "insttaz2zip" "ZIP installation archive (TAZUSB way)") \
1367 $(gottazusb "usbkey" "USB key read/write installation") \
1368 $(ishybrid "usbbootkey" "USB boot key (read only)") \
1369 $(hasflavinfo "showfavinfo" "Show flavor extra info") \
1370 $(hasflavor "flavor" "Get flavor file") \
1371 $(cdfile isolinux.cfg "floppyset" "Boot floppy set") \
1372 $(hastazboot "tazboot" "Get tazboot.exe Linux loader") \
1373 $(cdexe boot/bzImage "bzimage" "Get linux DOS/EXE file") \
1374 $(cdexe 'memtest*' "memtest" "Get Memtest86 DOS/EXE file") \
1375 $(cdfilef 'memtest*' "fdmemtest" "Create a Memtest86 boot floppy") \
1376 $(cdfilex 'memtest*' "runmemtest" "Start Memtest86") \
1377 $(cdexe '?pxe*' "pxe" "Get SliTaz Web boot DOS/EXE utility") \
1378 $(cdfilef '?pxe*' "fdpxe" "Create a SliTaz Web boot floppy") \
1379 $(cdfilex '?pxe*' "runpxe" "Start the SliTaz Web boot utility") \
1380 $(misspkg "missing" "Install packages to get more options") \
1381 $(menuitem "quit" "Quit this utility")
1382 EOT
1383 exec 3>&1
1384 value=$(. /tmp/dialog$$ 2>&1 1>&3)
1385 retval=$?
1386 exec 3>&-
1387 rm -f /tmp/dialog$$
1388 [ $retval -eq 0 ] || quit
1389 $value
1390 done