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

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