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

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