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

syslinux/taziso: fix inst*2zip
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Apr 05 09:37:40 2016 +0200 (2016-04-05)
parents dbf4eeed945f
children 83ffe9fe03d8
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
201 case "$mnt" in
202 *mkzip*) useposixovl=YES
203 esac
204 mkdir -p $mnt/slitaz/boot $mnt/slitaz/mnt/dos
205 [ "$useposixovl" ] &&
206 if ! mount.posixovl -F $mnt/slitaz -- \
207 -oallow_other -odefault_permissions -osuid; then
208 echo "Can't install SliTaz. Abort."
209 sleep 5
210 return 1
211 fi
212 dotwait "Install root filesystem in /slitaz.."
213 if [ "$1" ]; then
214 ls_r $media/boot/rootfs*gz | \
215 xargs cat > $mnt/slitaz/boot/rootfs.gz
216 tazusbinitfs $mnt/slitaz/boot/rootfs.gz $useposixovl
217 initrd=rootfs.gz
218 extraargs="/home=$(getuuid)/slitaz rdinit=/init1"
219 else
220 for i in $(ls_r $media/boot/rootfs*gz); do
221 uncpio $i $mnt/slitaz
222 done
223 for i in $packages_list; do
224 tazpkg get-install $i --root=$mnt/slitaz
225 done
226 for i in $packages_dir/*.tazpkg; do
227 [ -s "$i" ] &&
228 tazpkg install $i --root=$mnt/slitaz
229 done
230 cp -a /etc/locale.conf $mnt/slitaz/etc 2> /dev/null
231 cp -a /etc/keymap.conf $mnt/slitaz/etc 2> /dev/null
232 mkinitrd $mnt/slitaz/boot/initrd $mnt/slitaz $useposixovl
233 initrd=initrd
234 extraargs="mount=$(getuuid) subroot=slitaz"
235 fi
236 echo -en "\nInstall boot files..."
237 for i in $media/boot/bzImage $media/boot/*pxe* \
238 $media/boot/isolinux/he* $media/boot/isolinux/opt* \
239 $media/README $media/boot/memtest* ; do
240 [ -s $i ] && cp $i $mnt/slitaz/boot
241 done
242 for i in $mnt/slitaz/boot/memtest $mnt/slitaz/boot/*pxe* ; do
243 [ $(get 0 $i 2> /dev/null || echo 0) -eq 23117 ] &&
244 mv $i $i.exe
245 done
246 gettazboot $mnt/slitaz/boot/tazboot.exe
247 unix2dos > $mnt/slitaz/boot/tazboot.cmd <<EOT
248 kernel=/slitaz/boot/bzimage
249 initrd=/slitaz/boot/$initrd
250 rw root=/dev/null $extraargs autologin
251 EOT
252 unix2dos $mnt/slitaz/boot/he* $mnt/slitaz/boot/opt* \
253 $mnt/slitaz/boot/README
254 [ -d $mnt/slitaz/usr/sbin -a ! -x $mnt/slitaz/usr/sbin/mount.posixovl ] &&
255 cp $(which mount.posixovl) $mnt/slitaz/usr/sbin
256 if "$useposixovl" && grep -qs " $mnt " /proc/mounts &&
257 [ ! -d $mnt/boot/grub ]; then
258 mkdir -p $mnt/boot/grub
259 echo -en "\nInstall grub in /boot/grub..."
260 cp -a /usr/lib/grub/*/* $mnt/boot/grub
261 cat > $mnt/boot/grub/menu.lst <<EOT
262 # /boot/grub/menu.lst: GRUB boot loader configuration.
264 # By default, boot the first entry.
265 default 0
267 # Boot automatically after 8 secs.
268 timeout 8
270 title Microsoft Windows
271 chainloader +1
273 EOT
274 dev=$(grep " $mnt " /proc/mounts | awk '{ print $1 }')
275 base=${dev//[0-9]/}
276 dd if=$base bs=32k count=1 of=$mnt/boot/grub/$(basename $base)
277 cat > $mnt/boot/grub/uninstall-grub.sh <<EOT
278 #!/bin/sh
280 [ -s /boot/grub/$(basename $base) ] &&
281 dd if=/boot/grub/$(basename $base) of=$base
282 EOT
283 grub-install --no-floppy --root-directory=$mnt $base
284 fi
285 if [ -s $mnt/boot/grub/menu.lst ] &&
286 ! grep -q /slitaz/boot/bzimage $mnt/boot/grub/menu.lst; then
287 echo -en "\nUpdate /boot/grub/menu/lst..."
288 cat >> $mnt/boot/grub/menu.lst <<EOT
289 title SliTaz GNU/Linux $(cat $mnt/slitaz/etc/slitaz-release)
290 kernel /slitaz/boot/bzimage rw root=/dev/null $extraargs autologin
291 initrd /slitaz/boot/$initrd
293 EOT
294 fi
295 rm -f /tmp/wait
296 [ "$useposixovl" ] && umount $mnt/slitaz
297 return 0
298 }
300 windev()
301 {
302 if [ -b "$1" ]; then
303 device=$1
304 elif [ "$1" ]; then
305 echo "Invalid Linux/Windows partition"
306 return 1
307 else
308 DEV="$(blkid | grep -iE "(msdos|vfat|ntfs|ext[234]|xfs|btrfs)" | sed 's/:.*//;s|/dev/||')"
309 [ "$DEV" ] || return
310 cat > /tmp/dialog$$ <<EOT
311 $DIALOG --clear \
312 --title " Select your Linux/Windows partition " \
313 --menu "\nPlease select the Linux/Windows partition according to its known size.
314 The data will be kept untouched.\n" \
315 17 70 8 \
316 $(for i in $DEV ; do
317 label="$(blkid | sed "/$i:/!d;s/.*://;s/[^ ]*UUID=[^ ]* //g;s/LABEL=//")"
318 echo -n "/dev/$i \"$(($(cat /sys/block/*/$i/size)/2048))MB $label\" "
319 done)
320 EOT
321 exec 3>&1
322 [ $? -eq 0 ] || return
323 device=$(. /tmp/dialog$$ 2>&1 1>&3)
324 exec 3>&-
325 rm -f /tmp/dialog$$
326 fi
327 mnt=/tmp/mnt$$
328 mkdir -p $mnt && mount $device $mnt
329 }
331 extra_packages()
332 {
333 packages_list=
334 packages_dir=
335 $DIALOG --clear \
336 --title " Extra packages " \
337 --defaultno --yesno \
338 "
339 Do you want to add extra packages ?
340 " 7 70
341 [ $? -eq 0 ] || return
342 [ -s /var/lib/tazpkg/packages.txt ] || tazpkg recharge
343 if [ -s $media/boot/vmlinuz-$(uname -r) ]; then
344 cat > /tmp/dialog$$ <<EOT
345 $DIALOG --clear \
346 --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" \
361 --dselect $PWD 13 78
362 EOT
363 sh /tmp/dialog$$ 2> /tmp/dialog.out$$
364 [ $? -eq 0 ] && packages_dir="$(cat /tmp/dialog.out$$)"
365 rm -f /tmp/dialog$$ /tmp/dialog.out$$
366 }
368 _install()
369 {
370 extra_packages
371 $DIALOG --clear \
372 --title " SliTaz UMSDOS way installation " \
373 --yes-label "Install" --yesno \
374 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
375 Linux/DOS/Windows partition. You can see your files from /mnt/dos.\n\n
376 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
377 To uninstall SliTaz, you have only to remove this directory.
378 The file \\boot.ini or \\config.sys may be modified too.\n\n
379 SliTaz may run slowly on 'UMSDOS way' installation due to the
380 posixovl filesystem. The 'TAZUSB way' installation runs faster.\n\n
381 To do a traditional installation with disk partitioning,
382 start SliTaz Live with 'SliTaz RAM boot' menu.\n
383 " 19 70
384 [ $? -eq 0 ] || return
385 doinstall
386 }
388 readtazbootconf()
389 {
390 kernel="$(sed '/^kernel=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)"
391 initrd="$(sed '/^initrd=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)"
392 cmdline="$(sed '/^kernel=/d;/^initrd=/d' $mnt/slitaz/boot/tazboot.cmd)"
393 }
395 bootinstalled()
396 {
397 [ "$(which kexec)" ] || return
398 [ -x $mnt/slitaz$1 ] || return
399 [ -s $mnt/slitaz/boot/tazboot.cmd ] || return
400 readtazbootconf
401 kexec -l $kernel --initrd $initrd --command-line "$cmdline" || return
402 umount $mnt
403 rm -rf $mnt
404 quit "kexec -e"
405 }
407 mkzip()
408 {
409 device=
410 packages_list=
411 packages_dir=
412 mnt=/tmp/mkzipmnt$$
413 mkdir -p $mnt
414 $1 $2 || return
415 for i in bootlace.com grubinst.exe grldr ; do
416 wget -O $mnt/slitaz/boot/$i http://mirror.slitaz.org/boot/$i
417 done
418 readtazbootconf
419 cat > $mnt/slitaz/boot/menu.lst <<EOT
420 title SliTaz
421 kernel $kernel $cmdline
422 initrd $initrd
424 EOT
425 while read file title; do
426 file=$(ls $mnt/slitaz/boot/*$file* 2> /dev/null)
427 [ -s "$file" ] && cat >> $mnt/slitaz/boot/menu.lst <<EOT
428 title $title
429 kernel ${file#$mnt}
431 EOT
432 done <<EOT
433 memtest MemTest
434 pxe Web boot
435 EOT
436 unix2dos $mnt/slitaz/boot/menu.lst
437 unix2dos > $mnt/slitaz/boot/install.txt <<EOT
438 For DOS users (real mode only):
440 Start SliTaz with \\slitaz\\boot\\tazboot.exe
443 For NT/2000/XP users:
445 1- Move the files grldr and menu.lst into the root directory
447 C:\\> copy \\slitaz\\boot\\grldr \\
448 C:\\> copy \\slitaz\\boot\\menu.lst \\
450 2- Remove boot.ini attributes
452 C:\\> attrib -r -h -s boot.ini
454 3- Append the following line to boot.init
456 C:\\grldr="slitaz"
458 4- Restore boot.ini attributes
460 C:\\> attrib +r +h +s boot.ini
462 See http://diddy.boot-land.net/grub4dos/files/README_GRUB4DOS.txt
463 and http://xpt.sourceforge.net/techdocs/nix/disk/boot/boot07-GrubForDosInfo/ar01s03.html
464 EOT
465 ( cd $mnt ; echo 'See \slitaz\boot\install.txt to launch SliTaz.' | \
466 zip -zr9 $(basename "$ISO" .iso).zip slitaz )
467 [ "$(which advzip)" ] && advzip -z4 $mnt/*.zip
468 mv $mnt/*.zip .
469 du -h $PWD/$(basename "$ISO" .iso).zip
470 umount $mnt
471 rm -rf $mnt
472 }
474 install()
475 {
476 windev $1 || return
477 packages_list=
478 packages_dir=
479 if [ "$1" ]; then
480 doinstall
481 else
482 _install && bootinstalled /sbin/init
483 fi
484 umount $mnt
485 rm -rf $mnt
486 }
488 inst2zip()
489 {
490 if [ "$1" ]; then
491 mkzip doinstall
492 else
493 mkzip _install
494 fi
495 }
497 _installtaz()
498 {
499 $DIALOG --clear \
500 --title " SliTaz TAZUSB way installation " \
501 --yes-label "Install" --yesno \
502 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
503 Linux/DOS/Windows partition. You can see your files from /mnt/dos.\n\n
504 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
505 To uninstall SliTaz, you have only to remove this directory.
506 The file \\boot.ini or \\config.sys may be modified too.\n\n
507 The filesystem is loaded entirely into memory upon boot to
508 increase responsiveness. Only /home lands on hard disk.\n\n
509 To do a traditional installation with disk partitioning,
510 start SliTaz Live with 'SliTaz RAM boot' menu.\n
511 " 19 70
512 [ $? -eq 0 ] || return
513 doinstall tazusblike
514 }
516 installtaz()
517 {
518 windev $1 || return
519 packages_list=
520 packages_dir=
521 if [ "$1" ]; then
522 doinstall tazusblike
523 else
524 _installtaz && bootinstalled /boot/bzimage
525 fi
526 umount $mnt
527 rm -rf $mnt
528 }
530 insttaz2zip()
531 {
532 if [ "$1" ]; then
533 mkzip doinstall tazusblike
534 else
535 mkzip _installtaz
536 fi
537 }
539 bootiso()
540 {
541 cd /tmp
542 for i in $(ls_r $media/boot/rootfs*gz); do
543 grep -q ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64
544 cat $i
545 n=$((4 - ($(stat -c %s $i) % 4)))
546 [ $n -eq 4 ] || dd if=/dev/zero bs=1 count=$n
547 done > initrd$$
548 cmdline="root=/dev/null autologin lang=$LANG"
549 [ -s /etc/keymap.conf ] && cmdline="$cmdline kmap=$(cat /etc/keymap.conf)"
550 [ -s /etc/TZ ] && cmdline="$cmdline tz=$(cat /etc/TZ)"
551 rm -f cmdline initrd 2> /dev/null
552 getcustomconf kexec >/dev/null
553 [ -s cmdline ] && cmdline="$cmdline $(cat cmdline)" && rm cmdline
554 [ -s initrd ] && cat initrd >> initrd$$ && rm initrd
555 kernel=$media/boot/bzImage
556 grep -q ' lm ' /proc/cpuinfo && [ -s ${kernel}64 ] && kernel=${kernel}64
557 . /etc/locale.conf
558 kexec -l $kernel --initrd initrd$$ --command-line "$cmdline" &&
559 rm -f initrd$$
560 quit "kexec -e"
561 }
563 tazboot()
564 {
565 if [ -z "$1" ]; then
566 $DIALOG --clear \
567 --title " SliTaz bootloader for DOS " \
568 --yes-label "Install" --yesno \
569 "\nThe file TAZBOOT.EXE will be created in the top directory. It supports
570 any linux kernel, multiple initramfs, a kernel command line and
571 an ISO image file loopback (retrieves files from an ISO file).\n\n
572 Usage: tazboot.exe [[@commands]|[kernel=<bzimage>]
573 [initrd=<rootfs>[,<rootfs2>...]] [bootfrom=<isofile>] cmdline args ...]\n\n
574 Defaults: tazboot @tazboot.cmd or tazboot kernel=bzImage auto\n\n\
575 Examples for tazboot.cmd:\n\n\
576 bootfrom=\\isos\\slitaz-4.0.iso\n\
577 kernel=boot/bzImage\n\
578 initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\
579 rw root=/dev/null autologin\n\n\
580 kernel=\\slitaz\\vmlinuz root=/dev/sda5 ro\n\n
581 Unlike GRUB4DOS, it doesn't require unfragmented ISO image files.\n
582 " 0 0
583 [ $? -eq 0 ] || return
584 fi
585 gettazboot tazboot.exe
586 du -h $PWD/tazboot.exe
587 }
589 md5()
590 {
591 dotwait "Checking files"
592 ( cd $media ; ${md5sum:-md5sum -c md5sum*} | sort ) > /tmp/data
593 unset md5sum
594 rm -f /tmp/wait
595 if [ "$1" ]; then
596 cat /tmp/data
597 else
598 $DIALOG --clear \
599 --title " Checked files " \
600 --textbox /tmp/data 0 0
601 fi
602 rm -f /tmp/data
603 }
605 gotcdfile()
606 {
607 for i in "$media/$1" "$media/*/$1" "$media/*/isolinux/$1" ; do
608 file=$(ls $i 2> /dev/null | sed q)
609 [ -s "$file" ] && break
610 done
611 }
613 sha()
614 {
615 gotcdfile 'sha*sum*'
616 sha=$(basename $file)
617 md5sum="${sha%sum*}sum -c ${file#$media/}"
618 md5 $@
619 }
621 readme()
622 {
623 gotcdfile 'README*'
624 if [ "$1" ]; then
625 cat $file
626 else
627 $DIALOG --clear \
628 --title " Readme " \
629 --textbox $file 0 0
630 fi
631 }
633 bzimage()
634 {
635 if [ -z "$1" ]; then
636 $DIALOG --clear \
637 --title " Create linux.exe ? " \
638 --yes-label "Install" --yesno \
639 "\nLinux.exe launches the linux kernel under DOS (in real mode only).
640 The cmdline arguments are supported except initrd=,
641 vga= (you can try 'rdev -v') and mem= (partially).
642 \nExample:\nC:\\> linux.exe root=/dev/hda2 ro panic=60\n
643 " 12 70
644 [ $? -eq 0 ] || return
645 fi
646 cp $media/boot/bzImage linux.exe
647 du -h $PWD/linux.exe
648 }
650 memtest()
651 {
652 if [ -z "$1" ]; then
653 $DIALOG --clear \
654 --title " Create memtest.exe ? " \
655 --yes-label "Install" --yesno \
656 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
657 computers. BIOS based memory tests are a quick, cursory check and often
658 miss many of the failures that are detected by Memtest86.\n
659 " 0 0
660 [ $? -eq 0 ] || return
661 fi
662 gotcdfile 'memtest*' && cp $file memtest.exe
663 du -h $PWD/memtest.exe
664 }
666 mkfat12()
667 {
668 [ $(($(get 0 $1) - 0x5A4D)) -eq 0 ] || return
669 J=$(($(get 3 $1 1) + 0x02))
670 R=$((1 + $(get 497 $1 1) + 1 + ($(get 500 $1)-1)/32))
671 [ $R -lt 2500 ] || return
672 [ $((($(get 500 $1)-1) & 31)) -lt 30 ] &&
673 ddq if=$file bs=32 count=1 seek=$(($R*16 - 1)) of=/dev/fd0
674 G="18 0 2 0 0 0 0 0"
675 [ $J -gt 25 ] || G=""
676 F=0
677 for i in 1 2 3; do
678 F=$((((2880-$R-$F-$F)*3+1023)/1024))
679 done
680 bytes2bin 0xEB $J 0x90 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 \
681 0 2 2 $(($R%256)) $(($R/256)) 2 64 0 64 11 0xF0 $F 0 \
682 $G | ddq bs=1 of=/dev/fd0
683 ddq if=/dev/zero bs=512 count=$((4+$F+$F)) seek=$R of=/dev/fd0
684 for i in $R $(($R+$F)) ; do
685 bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0
686 done
687 echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0
688 }
690 mkfloppy()
691 {
692 dotwait "Create a $(basename $1) boot floppy"
693 ddq if=$1 of=/dev/fd0
694 mkfat12 $1
695 rm -f /tmp/wait
696 }
698 fdmemtest()
699 {
700 if [ -z "$1" ]; then
701 $DIALOG --clear \
702 --title " Create a Memtest86 boot floppy " \
703 --yes-label "Create floppy" --yesno \
704 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
705 computers. BIOS based memory tests are a quick, cursory check and often
706 miss many of the failures that are detected by Memtest86.\n\n
707 Please insert a blank disk in floppy drive.\n
708 " 0 0
709 [ $? -eq 0 ] || return
710 fi
711 gotcdfile 'memtest*' && mkfloppy $file
712 }
714 pxe()
715 {
716 gotcdfile '?pxe'
717 if [ -z "$1" ]; then
718 $DIALOG --clear \
719 --title " Create $(basename $file).exe ? " \
720 --yes-label "Install" --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
725 " 0 0
726 [ $? -eq 0 ] || return
727 fi
728 cp $file $(basename $file).exe
729 du -h $PWD/$(basename $file).exe
730 }
732 fdpxe()
733 {
734 if [ -z "$1" ]; then
735 $DIALOG --clear \
736 --title " Create a SliTaz Web boot floppy " \
737 --yes-label "Create floppy" --yesno \
738 "\nBoot your operating system from the internet and enjoy a full system
739 working entirely in RAM with speed and stability in mind. The Linux Kernel
740 and the complete SliTaz compressed root filesystem will be loaded into RAM
741 from the Web using PXE and HTTP protocols.\n\n
742 Please insert a blank disk in floppy drive.\n
743 " 0 0
744 [ $? -eq 0 ] || return
745 fi
746 gotcdfile '?pxe' && mkfloppy $file
747 }
749 menuitem()
750 {
751 [ "$3" ] && shift
752 echo -en "\"$1\" \"$2\""
753 }
755 gotposixovl()
756 {
757 mount.posixovl 2>&1 | grep -qi usage && menuitem "$@"
758 }
760 gotposixovlzip()
761 {
762 [ "$(which zip)" ] && gotposixovl "$1" "$2"
763 }
765 xfile()
766 {
767 [ "$(which $1)" ] && menuitem "$@"
768 }
770 cdfile()
771 {
772 gotcdfile "$1" && menuitem "$@"
773 }
775 isbzImage()
776 {
777 [ $(get 514 $file 4) -eq 1400005704 ] &&
778 [ $(($(get 529 $file 1) & 1)) -eq 1 ]
779 }
781 cdfilex()
782 {
783 gotcdfile "$1" && [ "$(which kexec)" ] && isbzImage && menuitem "$@"
784 }
786 cdfilef()
787 {
788 [ -e /sys/block/fd0 ] && cdfile "$@"
789 }
791 cdexe()
792 {
793 gotcdfile "$1" &&
794 [ $(get 0 $file 2>/dev/null || echo 0) -eq 23117 ] &&
795 menuitem "$@"
796 }
798 misspkg()
799 {
800 for i in zip kexec-tools posixovl cdrkit cdrkit-isoinfo ; do
801 [ -d /var/lib/tazpkg/installed/$i/ ] && continue
802 [ "$1" != "install" ] && menuitem "$@" && return
803 tazpkg get-install $i
804 done
805 }
807 missing()
808 {
809 misspkg install
810 }
812 ishybrid()
813 {
814 [ $(get 510 "$ISO") -eq 43605 ] || return
815 C=$((2048*$(get $(((17*2048) + 71)) "$ISO" 4)))
816 [ $(get $C "$ISO" 4) -eq 1 ] || return
817 [ $(get $(($C+30)) "$ISO" 4) -eq $((0x88AA55)) ] || return
818 C=$((2048*$(get $(($C+40)) "$ISO" 4)))
819 [ $(get $(($C+64)) "$ISO" 4) -eq 1886961915 ] && menuitem "$@"
820 }
822 isiso()
823 {
824 [ $(get 32769 "$ISO" 4) -eq 808469571 ] && menuitem "$@"
825 }
827 hastazboot()
828 {
829 [ $(get 0 "$ISO") -eq 23117 ] && menuitem "$@"
830 }
832 burnable()
833 {
834 [ "$(sed '/Can wr.*1$/!d' /proc/sys/dev/cdrom/info)" ] && menuitem "$@"
835 }
837 blankable()
838 {
839 [ "$(sed '/Can wr.*RW.*1$/!d' /proc/sys/dev/cdrom/info)" ] && menuitem "$@"
840 }
842 burniso()
843 {
844 wodim -v speed=$(fgrep "drive speed" /proc/sys/dev/cdrom/info | cut -f3) \
845 -eject -multi "$ISO"
846 }
848 blankcd()
849 {
850 wodim -v -blank=fast
851 }
853 customsector()
854 {
855 echo $(($(get 32848 "$ISO" 4)+16))
856 }
858 hascustomconf()
859 {
860 [ "$(ddq bs=2k skip=$(customsector) if="$ISO" | ddq bs=1 count=6)" \
861 == "#!boot" ]
862 }
864 gotcustomconf()
865 {
866 hascustomconf && menuitem "$@"
867 }
869 gotisomd5()
870 {
871 [ "$(which md5sum 2> /dev/null)" ] &&
872 [ $(get 0 "$ISO") -eq 23117 ] &&
873 [ $(get 18 "$ISO") -ne 0 ] && menuitem "$@"
874 }
876 getcustomconf()
877 {
878 ddq bs=2k skip=$(customsector) if="$ISO" | while read line; do
879 case "$line" in
880 \#!boot*) ;;
881 append=*) echo ${line#append=} > cmdline && ls -l $PWD/cmdline ;;
882 initrd:*) cnt=${line#initrd:}
883 { ddq bs=512 count=$(($cnt / 512));
884 ddq bs=1 count=$(($cnt % 512)); } > initrd &&
885 ls -l $PWD/initrd
886 break ;;
887 *) break ;;
888 esac
889 done
890 [ "$1" ] && return 0
891 echo -e "\rPress RETURN to continue."
892 read n
893 }
895 isomd5()
896 {
897 dotwait "Checking iso image"
898 [ "$(ddq if="$ISO" bs=2k skip=16 \
899 count=$(echo $(get 32848 "$ISO" 4)) | md5sum)" == \
900 "$(ddq if="$ISO" bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \
901 sed 's/ //g') -" ] && echo "OK" || echo "ERROR"
902 echo -en "\rChecking iso hybrid boot..."
903 n=$(($(get 2 "$ISO")-1+($(get 4 "$ISO")-1)*512))
904 if [ $n -lt 40000 -a $n -gt 32768 ]; then
905 s=$(get 0 "$ISO" 2 $n | awk '{ i+= $0 } END { print i }')
906 [ $(((1+$s+$(get $(($n+1)) "$ISO" 1)) % 65536)) -eq 0 ] &&
907 echo "OK" || echo "ERROR"
908 fi
909 if hascustomconf; then
910 echo -en "\rChecking iso custom config..."
911 TMP=/tmp/$(basename $0)$$md5
912 md5="$(ddq bs=2k skip=$(customsector) if="$ISO" | while read line; do
913 case "$line" in
914 \#!boot*) echo ${line#*boot } > $TMP ;;
915 append=*) echo $line ;;
916 initrd:*) echo $line
917 cnt=${line#initrd:}
918 ddq bs=512 count=$((cnt / 512))
919 ddq bs=1 count=$((cnt % 512))
920 break ;;
921 *) break ;;
922 esac
923 done | md5sum | cut -c1-32)"
924 [ "$md5" == "$(cat $TMP)" ] && echo "OK" || echo "ERROR"
925 rm -f $TMP
926 fi
927 rm -f /tmp/wait
928 [ "$1" ] && return 0
929 echo -e "\rPress RETURN to continue."
930 read n
931 }
933 usbdev()
934 {
935 dotwait "Wait 5 seconds for USB devices"
936 sleep 5
937 rm -f /tmp/wait
938 DEV="$(grep -l 1 /sys/block/*/removable | \
939 sed 's|/sys/block/\(.*\)/removable|\1|')"
940 grep -qs 1 /sys/block/$DEV/ro && return
941 [ "$DEV" ] || return
942 cat > /tmp/dialog$$ <<EOT
943 $DIALOG --clear \
944 --title " Select your USB key " \
945 --menu "\nPlease select the USB key according to its known size.\n\n" \
946 0 0 0 \
947 $(for i in $DEV ; do
948 echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2> /dev/null)\" "
949 done) \
951 EOT
952 exec 3>&1
953 device=$(. /tmp/dialog$$ 2>&1 1>&3)
954 rm -f /tmp/dialog$$
955 retval=$?
956 exec 3>&-
957 rm -f /tmp/dialog$$
958 [ $retval -eq 0 ]
959 }
961 tazusbmsg()
962 {
963 [ "$(which tazusb 2> /dev/null)" ] || return
964 echo "You should choose 'USB key read/write installation' to be
965 able to save the package updates or your own configuration and data files.\n\n"
966 }
968 usbbootkey()
969 {
970 if [ -b "$1" ]; then
971 device=$1
972 elif [ "$1" ]; then
973 echo "Invalid USB key device"
974 return 1
975 else
976 $DIALOG --clear \
977 --title " Create a USB boot key " \
978 --yes-label "Continue" --yesno \
979 "\nThe USB key will be used like a CD-ROM. You will not be able to write
980 any data on the boot partition.\n\n
981 An extra FAT32 partition will be created with the remaining free space.\n\n
982 $(tazusbmsg)Please plug your USB stick in now.\n
983 " 16 70
984 [ $? -eq 0 ] || return
985 usbdev || return
987 # perform dd in progress bar
988 max=$(($(stat -c %s "$ISO")/2048))
989 i=0; ddq if="$ISO" bs=1024k | (
990 while ddq bs=1024k count=1 ; do
991 i=$(($i + 1))
992 [ $i -gt $max ] && break
993 echo $((($i*100)/$max)) | dialog --gauge \
994 " The ISO image transfer can be long. Please wait..." \
995 6 70 0 > /dev/tty 2>&1
996 done ) > $device
997 fi
999 # partition + fat32 format for the remaining space
1000 for p in 0 16; do
1001 get $((450+$p)) $device 2 12 | xargs echo | {
1002 read dx cx ol oh ll lh
1003 [ $dx -eq $((0x3F17)) ] || continue
1004 cx=$(($cx & 0xFF00))
1005 ofs=$(($ll+($lh<<16)))
1006 n=$(($(cat /sys/block/${device#/dev/}/size)-$ofs))
1007 m=$(($cx+($n/8)))
1008 [ $m -gt $((0x3FF00)) ] && m=$((0x3FF00))
1009 m=$((($m & 0xFF00)+(($m>>16)<<6)))
1010 words2bin 0 $((0x101+$cx)) 0x3F0B $((32+$m)) \
1011 $ll $lh $(($n & 0xFFFF)) $(($n >> 16)) | \
1012 ddq bs=1 seek=$((462-$p)) of=$device
1013 if [ "$(which mkdosfs 2> /dev/null)" ]; then
1014 losetup -o $((512*$ofs)) /dev/loop2 $device
1015 mkdosfs -n "SLITAZ BOOT" /dev/loop2
1016 words2bin $(($ofs & 0xFFFF)) $(($ofs >> 16)) | \
1017 ddq bs=1 seek=28 of=/dev/loop2
1018 sync
1019 losetup -d /dev/loop2
1020 fi
1022 done
1025 usbkey()
1027 $DIALOG --clear \
1028 --title " Create a SliTaz USB key " \
1029 --yes-label "Continue" --yesno \
1030 "\nUnlike a hard drive install, the filesystem is kept in a compressed
1031 rootfs.gz. The filesystem is loaded entirely into memory upon boot.
1032 This should increase responsiveness, protect the filesystem against
1033 accidental corruption and reduce read/writes to the USB drive.
1034 Once setup, the tazusb utility can rewrite the root filesystem
1035 with any changes you have made since booting up,
1036 giving the effective benefits of a hard drive install.\n\n
1037 /home is mounted on boot using the UUID of your particular flash drive.
1038 Unlike a device name, the UUID has the benefit of never changing from machine
1039 to machine.\n\n
1040 Please plug your USB stick in now.\n
1041 " 19 70
1042 [ $? -eq 0 ] || return
1043 usbdev || return
1044 exec 3>&1
1045 format=`$DIALOG --clear \
1046 --title " Select the filesystem " \
1047 --radiolist "\nPlease select the filesystem type to create.\n\n\
1048 The filesystem creation will erase all the data \
1049 in the USB key." 14 70 4 \
1050 "none" "Do not erase the USB key" on \
1051 "ext3" "Ext3 journaling filesystem" off \
1052 "ext2" "Ext2 filesystem" off \
1053 "fat32" "Windows FAT32 filesystem" off \
1054 2>&1 1>&3`
1055 retval=$?
1056 exec 3>&-
1057 [ $retval -eq 0 ] || return
1058 [ "$format" != "none" ] && tazusb format $device "SliTaz" $format
1059 tazusb gen-iso2usb "$ISO" $device
1062 dokexec()
1064 kexec -l $file || return
1065 quit "kexec -e"
1068 runmemtest()
1070 gotcdfile 'memtest*' && dokexec
1073 runpxe()
1075 gotcdfile '?pxe' && dokexec
1078 flavdata()
1080 [ $(get 1024 "$ISO") -eq 35615 ] && n=2 || n=$((1+$(get 417 "$ISO" 1)))
1081 dd if="$ISO" bs=512 skip=$n count=20 2>/dev/null | zcat 2>/dev/null
1084 hasflavinfo()
1086 [ "$(flavdata | dd bs=1 count=8 2> /dev/null | strings)" == \
1087 "07070100" ] && menuitem "$@"
1090 showfavinfo()
1092 mkdir -p /tmp/data
1093 flavdata | ( cd /tmp/data ; cpio -i )
1094 file=/tmp/data/info
1095 cat /tmp/data/*desc > $file
1096 if [ -s /tmp/data/*receipt ]; then
1097 echo "=== receipt ==="
1098 cat /tmp/data/*receipt
1099 fi >> $file
1100 for i in /tmp/data/*list* ; do
1101 echo "=== extra ${i#*list} files"
1102 cat $i
1103 done >> $file
1104 if [ "$1" ]; then
1105 cat $file
1106 else
1107 $DIALOG --clear \
1108 --title " Flavor info " \
1109 --textbox $file 0 0
1110 fi
1111 rm -rf /tmp/data
1114 flavor()
1116 name="$(flavdata | cpio -t 2> /dev/null | sed 's/.[a-z]*$//;q')"
1117 echo "Create ${name:=flavor}.flavor..."
1118 tazlito iso2flavor "$ISO" $name
1119 ls -l $name.flavor 2> /dev/null && return
1120 sleep 5
1121 [ "$1" ] && return
1122 echo -e "\rPress RETURN to continue."
1123 read n
1126 if [ "$1" == "--build" ]; then #install-begin
1127 uuencode -m - < ifmem.bin | sed -e '/^ifmemcode$/r/dev/stdin' \
1128 -e '/^ifmemcode$/d' -i $0
1129 uuencode -m - < bootloader.bin | sed -e '/^bootloader$/r/dev/stdin' \
1130 -e '/^bootloader$/d' -e '/install-begin$/,/install-end$/d' -i $0
1131 exit
1132 fi #install-end
1133 parse_isolinux()
1135 awk 'BEGIN { IGNORECASE=1 }
1136 function multi(n)
1138 auto=$n
1139 for (--n; n < NF; n+=2) {
1140 s=$n
1141 if (s ~ /M$/) s = substr(s,0,length(s)-1)
1142 else s /= 1024
1143 sizes=int(s) " " sizes
1145 next
1148 if ($1 == "LABEL") {
1149 label=$2
1150 if (auto == "") auto=label
1152 if ($1 == "KERNEL" || $1 == "COM32") kernel[label]=$2
1153 if ($1 == "INITRD") initrd[label]=$2
1154 if ($1 == "APPEND") {
1155 i=2
1156 if (kernel[label] ~ "ifmem.c32") multi(3)
1157 if (kernel[label] ~ "c32box.c32") {
1158 if ($2 == "linux") { kernel[label]=$3; i=4 }
1159 if ($2 == "ifmem") multi(4)
1161 if (kernel[label] ~ "ifcpu64.c32") { auto=$4; next }
1162 while (i <= NF) {
1163 if ($i ~ "^initrd=") initrd[label]=substr($i,8)
1164 else cmdline[label]=cmdline[label] " " $i
1165 i++
1169 END {
1170 print "KERNEL=\"" kernel[auto] "\""
1171 print "INITRD=\"" initrd[auto] "\""
1172 print "CMDLINE=\"" substr(cmdline[auto],2) "\""
1173 print "SIZES=\"" sizes "\""
1174 }'
1177 locase()
1179 echo "$1" | tr [A-Z] [a-z]
1182 ifmemcode()
1184 uudecode <<EOT
1185 ifmemcode
1186 EOT
1189 floppyset()
1191 gotcdfile isolinux.cfg
1192 parse_isolinux < $file > /tmp/var$$
1193 . /tmp/var$$
1194 for i in $media/$KERNEL $(dirname $file)/$KERNEL $media/$(locase $KERNEL) \
1195 $(dirname $file)/$(locase $KERNEL); do
1196 [ -s $i ] && KERNEL=$i && break
1197 done
1198 rm -f /tmp/var$$
1199 [ $(get 514 $KERNEL 4) -eq 1400005704 ] || return
1200 n=$(($(get 497 $KERNEL 1)+1))
1201 ddq bs=512 count=$n if=$KERNEL of=/tmp/fd$$
1202 uudecode <<EOT | ddq of=/tmp/fd$$ conv=notrunc
1203 bootloader
1204 EOT
1205 pos=$(($n*512))
1206 if [ -n "$CMDLINE" ]; then
1207 echo -n "$CMDLINE" | ddq bs=512 count=1 conv=sync >> /tmp/fd$$
1208 bytes2bin $n | ddq conv=notrunc \
1209 bs=1 seek=497 count=1 of=/tmp/fd$$
1210 words2bin $pos | ddq conv=notrunc \
1211 bs=1 seek=34 count=2 of=/tmp/fd$$
1212 [ $(get 518 $KERNEL 4) -ge 514 ] &&
1213 words2bin 32768 9 | ddq conv=notrunc \
1214 bs=1 seek=552 count=4 of=/tmp/fd$$
1215 fi
1216 syssize=$(echo $(get 500 /tmp/fd$$ 4))
1217 ddq bs=512 skip=$n if=$KERNEL | cat - /dev/zero | \
1218 ddq bs=512 count=$((($syssize+31)/32)) conv=sync >> /tmp/fd$$
1219 base=$(stat -c %s /tmp/fd$$)
1220 len=
1221 if [ "$INITRD" ]; then
1222 l=0
1223 for i in ${INITRD//,/ }; do
1224 for j in $media/$i $(dirname $KERNEL)/$i $media/$(locase $i) \
1225 $(dirname $KERNEL)/$(locase $i); do
1226 [ -s $j ] && i=$j && break
1227 done
1228 ddq if=$i >> /tmp/fd$$
1229 l=$(($l+$(stat -c %s $i)))
1230 r=$((4 - ($l % 4)))
1231 if [ $r -ne 4 ]; then
1232 ddq if=/dev/zero bs=1 count=$r >> /tmp/fd$$
1233 l=$(($l + $r))
1234 fi
1235 case "$i:$INITRD" in
1236 *rootfs.gz:*rootfs.gz,*) continue # loram
1237 esac
1238 len="$len $l"; l=0
1239 done
1240 rdadrs=${RDADRS:-$(((($syssize*16)+0x1F0000) & -4096))}
1241 words2bin $(($rdadrs & 0xFFFF)) $(($rdadrs >> 16)) | ddq \
1242 conv=notrunc bs=1 seek=536 count=4 of=/tmp/fd$$
1243 fi
1244 n=$(echo $len | wc -w)
1245 if [ $((494 - $(get 494 /tmp/fd$$))) -ge $(($n * 4)) ]; then
1246 i=$(($(get 494 /tmp/fd$$)))
1247 bytes2bin $(($i + ($n*4) - 256)) | ddq bs=1 conv=notrunc \
1248 seek=496 count=1 of=/tmp/fd$$
1249 else
1250 i=$(($pos + 0x1FC - ($n*4)))
1251 bytes2bin $(($i % 256)) $((i / 256)) 252 | ddq bs=1 \
1252 conv=notrunc seek=494 count=3 of=/tmp/fd$$
1253 s=$(($i - 2*$(echo "$SIZES" | wc -w)))
1254 p=$(($s - $(ifmemcode | wc -c)))
1255 ifmemcode | ddq bs=1 conv=notrunc seek=$p of=/tmp/fd$$
1256 words2bin $SIZES | ddq bs=1 conv=notrunc seek=$s of=/tmp/fd$$
1257 bytes2bin 154 $(($p%256)) $(($p/256)) 0 144 | \
1258 ddq bs=1 conv=notrunc seek=60 of=/tmp/fd$$
1259 fi
1260 for r in $len ; do
1261 words2bin $(($r & 0xFFFF)) $(($r >> 16)) | ddq conv=notrunc \
1262 bs=1 seek=$i count=4 of=/tmp/fd$$
1263 i=$(($i + 4))
1264 done
1265 split -b 1440k /tmp/fd$$ fd$$
1266 rm -f /tmp/fd$$
1267 n=1; i=0; r=0
1268 set -- $len
1269 ls fd$$* | while read file ; do
1270 if [ $i -gt $(($1+$base)) ]; then
1271 shift
1272 r=$(($r+100)); n=0; i=0; base=0
1273 fi
1274 ddq of=$file bs=18k seek=80 count=0
1275 i=$(($i+1474560))
1276 printf "mv %s fd%03d.img\n" $file $(($r+$n))
1277 n=$(($n+1))
1278 done | sh
1279 du -ch $PWD/fd???.img
1282 quit()
1284 umount -d $media
1285 rmdir $media
1286 ${1:-exit}
1289 infoiso()
1291 isoinfo -d -i "$ISO" > /tmp/isoinfo$$
1292 if [ -x "$(which iso2exe)" ]; then
1293 echo "----"
1294 iso2exe -l "$ISO"
1295 fi >> /tmp/isoinfo$$
1296 if [ "$1" ]; then
1297 cat /tmp/isoinfo$$
1298 else
1299 $DIALOG --clear \
1300 --title " Info ISO " \
1301 --textbox /tmp/isoinfo$$ 0 0
1302 fi
1303 rm -f /tmp/isoinfo$$
1306 isotitle()
1308 echo "$(blkid "$ISO" | sed 's/.*LABEL="\([^"]*\).*/\1/') $(stat \
1309 -c %y $media/.|sed 's/ .*//') $(basename "$ISO")"
1312 ISO="${1:-/dev/null}"
1313 [ -z "$(isiso 2> /dev/null)" ] && echo "Usage : $0 file.iso" && exit 1
1314 media=/tmp/media$$
1315 mkdir -p $media
1316 mount -o loop,ro "$ISO" $media
1318 if [ "$2" == "list" ]; then
1319 sed '/^\$(.*") \\/!d;s/^\$(\(.*\)").*/\1"/' $0 | while read line; do
1320 eval $line
1321 echo
1322 done | sed '/^$/d;/"usbkey"/d'
1323 quit
1324 fi
1325 if grep -q "^$2()" $0; then
1326 exe=$2
1327 shift 2
1328 if [ -n "$(eval $(grep "\"$exe\"" $0 | sed \
1329 '/^\$/!d;s/.(\(.*\)[\t ]*".*"[\t ]*".*/\1/'))" ]; then
1330 isotitle
1331 grep "\"$exe\"" $0 | sed '/^\$/!d;s/.*"[\t ]*"\(.*\)".*/\1/'
1332 echo ----
1333 $exe "$@"
1334 fi
1335 quit
1336 fi
1338 while true; do
1339 cat > /tmp/dialog$$ <<EOT
1340 $DIALOG --clear \
1341 --title " $(isotitle) " \
1342 --menu "" -2 70 0 \
1343 $(cdfile 'README*' "readme" "Show the README file") \
1344 $(gotcustomconf "getcustomconf" "Get custom config") \
1345 $(gotisomd5 "isomd5" "Check the ISO image") \
1346 $(cdfile 'md5sum*' "md5" "Check the ISO files") \
1347 $(cdfile 'sha*sum*' "sha" "Check the ISO files") \
1348 $(xfile isoinfo "infoiso" "ISO image info") \
1349 $(cdfilex boot/bzImage "bootiso" "Boot the ISO image") \
1350 $(burnable "burniso" "Burn the ISO image") \
1351 $(blankable "blankcd" "Blank the CD/DVD") \
1352 $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \
1353 $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \
1354 $(gotposixovlzip "inst2zip" "ZIP installation archive (UMSDOS way)") \
1355 $(gotposixovlzip "insttaz2zip" "ZIP installation archive (TAZUSB way)") \
1356 $(xfile tazusb "usbkey" "USB key read/write installation") \
1357 $(ishybrid "usbbootkey" "USB boot key (read only)") \
1358 $(hasflavinfo "showfavinfo" "Show flavor extra info") \
1359 $(xfile tazlito "flavor" "Get flavor file") \
1360 $(cdfile isolinux.cfg "floppyset" "Boot floppy set") \
1361 $(hastazboot "tazboot" "Get tazboot.exe Linux loader") \
1362 $(cdexe boot/bzImage "bzimage" "Get linux DOS/EXE file") \
1363 $(cdexe 'memtest*' "memtest" "Get Memtest86 DOS/EXE file") \
1364 $(cdfilef 'memtest*' "fdmemtest" "Create a Memtest86 boot floppy") \
1365 $(cdfilex 'memtest*' "runmemtest" "Start Memtest86") \
1366 $(cdexe '?pxe' "pxe" "Get SliTaz Web boot DOS/EXE utility") \
1367 $(cdfilef '?pxe' "fdpxe" "Create a SliTaz Web boot floppy") \
1368 $(cdfilex '?pxe' "runpxe" "Start the SliTaz Web boot utility") \
1369 $(misspkg "missing" "Install packages to get more options") \
1370 $(menuitem "quit" "Quit this utility")
1371 EOT
1372 exec 3>&1
1373 value=$(. /tmp/dialog$$ 2>&1 1>&3)
1374 retval=$?
1375 exec 3>&-
1376 rm -f /tmp/dialog$$
1377 [ $retval -eq 0 ] || quit
1378 $value
1379 done