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

syslinux/iso2exe: fix linld.com path
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon May 25 18:40:12 2020 +0000 (2020-05-25)
parents e93fa0cecd8a
children 7744355508b9
line source
1 #!/bin/sh
3 [ $(id -u) -eq 0 ] || exec su -c "$0 $@"
5 DIALOG=dialog
7 ddq()
8 {
9 dd $@ 2> /dev/null
10 }
12 get()
13 {
14 od -v -j $1 -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An "$2" 2>/dev/null ||
15 hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %u\n\"" "$2"
16 }
18 bytes2bin()
19 {
20 for i in $@ ; do
21 printf '\\\\x%02X' $(($i&255))
22 done | xargs echo -en
23 }
25 words2bin()
26 {
27 for i in $@ ; do
28 printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255))
29 done | xargs echo -en
30 }
32 gettazboot()
33 {
34 echo -e "\nCreating $(basename $1) ..."
35 S=$((32+HEADERSZ))
36 P=$((($S+511)/512))
37 E=$((4096-(32*$P)))
38 words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 -16 \
39 -2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1
40 uudecode - >> $1 << EOT
41 HEADERCODE
42 EOT
43 gotcdfile linld.com
44 ddq if=$file >> $1
45 }
47 uncpio()
48 {
49 [ -s "$1" ] || return
50 echo -en "\n Extracting $(basename $1) ..."
51 case $(get 0 $1) in
52 *35615) ( zcat || gunzip ) ;;
53 *14333) unxz ;;
54 *\ 93) unlzma ;;
55 *) cat ;;
56 esac < $1 | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
57 }
59 dotwait()
60 {
61 echo -n "${1:-Install filesystem}.."
62 touch /tmp/wait
63 [ "$REQUEST_URI" ] && return
64 while [ -e /tmp/wait ]; do
65 echo -n "." > /dev/tty
66 sleep 1
67 done &
68 }
70 getuuid()
71 {
72 dev=$(mount | sed "/ $(echo $mnt | sed 's|/|\\/|g') /!d;s/ .*//;s|/dev/||;q")
73 [ "$dev" ] &&
74 blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/" ||
75 echo "/dev/hda1"
76 }
78 tazusbinitfs()
79 {
80 PAD=$(($(stat -c %s $1) % 4))
81 [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1
82 mkdir -p /tmp/fs$$/etc /tmp/fs$$/lib /tmp/fs$$/home
83 cp -a /etc/locale.conf /etc/locale.conf /tmp/fs$$/etc 2> /dev/null
84 cat > /tmp/fs$$/init1 <<EOT
85 #!/bin/sh
86 sed -i 's|sbin/init|init2|' /init
87 exec /init
88 EOT
89 cat > /tmp/fs$$/init2 <<EOT
90 #!/bin/sh
92 mount -t proc /proc /proc
93 for i in /lib/modules/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
94 v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2> /dev/null)
95 mount / -o remount,rw
96 mkdir /mnt/dos
97 rm -f /cmdline 2> /dev/null
98 mount / -o remount,ro
99 mnt=/mnt/dos/\${v#*/}
100 dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q')
101 echo "Mount \$dev in /mnt/dos for \$v..." | tee -a /run/boot.log
102 mount \$dev /mnt/dos
103 if [ ! -d /mnt/dos/slitaz ]; then
104 umount /mnt/dos 2> /dev/null
105 (blkid /dev/[sh]d* || blkid) | while read dev line; do
106 case "\$line" in
107 *ntfs*|*vfat*|*msdos*) ;;
108 *) continue ;;
109 esac
110 mount \${dev%:} /mnt/dos
111 [ -d /mnt/dos/slitaz ] && break
112 umount /mnt/dos
113 done
114 fi
115 $([ "$2" ] || echo '# ')mount.posixovl -F \$mnt -- -oallow_other -odefault_permissions -osuid
116 mount --bind \$mnt /home
117 mount -o size=0,ro -t tmpfs tmpfs \$mnt
118 umount /proc
119 exec /sbin/init
120 EOT
121 chmod 755 /tmp/fs$$/init?
122 ln -s /sqfs/bin/gzip /bin 2> /dev/null
123 ( cd /tmp/fs$$ ; find * | cpio -o -H newc ) | gzip -9 >> $1
124 rm -rf /tmp/fs$$
125 }
127 mkinitrd()
128 {
129 echo -en "\nCreating $(basename $1) "
130 fs=/tmp/fs$$
131 for i in bin lib dev proc tmp mnt etc ; do
132 mkdir -p $fs/$i
133 done
134 for i in /dev/null /dev/tty /dev/tty[012] /dev/fuse /dev/[hs]d* \
135 /dev/console ; do
136 cp -a $2$i $fs/dev/
137 done
138 for i in /bin/busybox $(which mount.posixovl) $(which blkid) \
139 $(which ntfs-3g); do
140 cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \
141 sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') $fs/lib
142 cp $i $fs/bin
143 done
144 cp -a /sqfs/lib/ld-* /tmp/fs/lib 2> /dev/null ||
145 cp -a /lib/ld-* $fs/lib
146 for i in $(busybox | sed '/Current/,$!d'); do
147 [ -e $fs/bin/${i%,} ] || ln -s busybox $fs/bin/${i%,}
148 done
149 ln -s /proc/mounts $fs/etc/mtab
150 sed 's/ .*//' /proc/modules | while read mod ; do
151 find /lib/modules/ | grep $mod.ko | \
152 sed 's|.*|cp & $fs/lib|' | sh
153 done
154 cat > $fs/init <<EOT
155 #!/bin/sh
157 arg()
158 {
159 grep -q \$1 /proc/cmdline &&
160 val="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" < /proc/cmdline)" &&
161 echo "\$2 \$val"
162 }
164 mount -t proc /proc /proc
165 arg debug "shell" && debug=true && set -x
166 for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
167 arg mount "Mount device"
168 dsk=\$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q')
169 mount \$dsk /mnt || mount.ntfs \$dsk /mnt
170 arg subroot "Change root to directory"
171 if [ -d /mnt/\$val ]; then
172 umount /mnt 2> /dev/null
173 (blkid /dev/[sh]d* || blkid) | while read dev line; do
174 case "\$line" in
175 *ntfs*|*vfat*|*msdos*) ;;
176 *) continue ;;
177 esac
178 mount \${dev%:} /mnt
179 [ -d /mnt/\$val ] && break
180 umount /mnt
181 done
182 fi
184 $([ "$3" ] || echo -n '# ')mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid
185 mount --bind /mnt /mnt/\$val/mnt/dos
186 mount -o size=0,ro -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val
187 LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q)
188 export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib
189 [ "$debug" = "true" ] && sh
190 umount /proc
191 exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init
192 EOT
193 chmod +x $fs/init
194 ( cd $fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null
195 rm -rf $fs /tmp/wait
196 }
198 ls_r()
199 {
200 ls -r $@ 2> /dev/null || ls $@
201 }
203 doinstall()
204 {
205 unset useposixovl
206 blkid | grep $(df $mnt | sed '$!d;s/ .*/:/') | \
207 grep -qiE "(msdos|vfat|ntfs)" && useposixovl=YES
208 case "$mnt" in
209 *mkzip*) useposixovl=YES
210 esac
211 mkdir -p $mnt/slitaz/boot $mnt/slitaz/mnt/dos
212 [ "$useposixovl" ] &&
213 if ! mount.posixovl -F $mnt/slitaz -- \
214 -oallow_other -odefault_permissions -osuid; then
215 echo "Can't install SliTaz. Abort."
216 sleep 5
217 return 1
218 fi
219 dotwait "Install root filesystem in /slitaz.."
220 if [ "$1" ]; then
221 ls_r $media/boot/rootfs*gz | \
222 xargs cat > $mnt/slitaz/boot/rootfs.gz
223 tazusbinitfs $mnt/slitaz/boot/rootfs.gz $useposixovl
224 initrd=rootfs.gz
225 extraargs="/home=$(getuuid)/slitaz rdinit=/init1"
226 else
227 for i in $(ls_r $media/boot/rootfs*gz); do
228 uncpio $i $mnt/slitaz
229 done
230 for i in $packages_list; do
231 tazpkg get-install $i --root=$mnt/slitaz
232 done
233 for i in $packages_dir/*.tazpkg; do
234 [ -s "$i" ] &&
235 tazpkg install $i --root=$mnt/slitaz
236 done
237 cp -a /etc/locale.conf $mnt/slitaz/etc 2> /dev/null
238 cp -a /etc/keymap.conf $mnt/slitaz/etc 2> /dev/null
239 mkinitrd $mnt/slitaz/boot/initrd $mnt/slitaz $useposixovl
240 initrd=initrd
241 extraargs="mount=$(getuuid) subroot=slitaz"
242 fi
243 echo -en "\nInstall boot files..."
244 for i in $media/boot/bzImage* $media/boot/*pxe* \
245 $media/boot/isolinux/he* $media/boot/isolinux/opt* \
246 $media/README $media/boot/memtest* ; do
247 [ -s $i ] && cp $i $mnt/slitaz/boot
248 done
249 for i in $mnt/slitaz/boot/memtest $mnt/slitaz/boot/*pxe ; do
250 [ $(get 0 $i 2> /dev/null || echo 0) -eq 23117 ] &&
251 mv $i $i.exe
252 done
253 bzimage=$(cd $mnt/slitaz/boot ; ls bzimage*)
254 cp /etc/keymap.conf /etc/locale.conf $mnt/slitaz/etc 2> /dev/null
255 gettazboot $mnt/slitaz/boot/tazboot.exe # autoappend 64 suffix
256 unix2dos > $mnt/slitaz/boot/tazboot.cmd <<EOT
257 image=/slitaz/boot/bzimage
258 initrd=/slitaz/boot/$initrd
259 $extraargs autologin
260 EOT
261 uudecode - <<EOT | gunzip > $mnt/slitaz/boot/slitaz.pif
262 begin-base64 644 -
263 H4sIAAAAAAACA8XPxUHGMBTA8X9ecb/glgFwv+FO23zeI+7ucMFhCjZgEEZh
264 Ctzd4Rf3PFbtQHGLG9BmfmZqdlE/tSmw2LfePzOzWDK0OsQXpPHvFGfZBmL5
265 f3Zns98NuG1BbTrbWj0OFMypSKfT4kYCurKuRleWlBEth2qUTYFBKjg746pI
266 2nZaIT/v9vWwbeuqi9fPznLlSPFLLuK22/0lLT09/BDhXgWKO1f9aLKxOObE
267 EhLuVvO4FksSwaH5qbHpvkle0TyzND82NK+doRVeZgGGbIw0XD2QwV9SnAN/
268 ACxDxwMAAA==
269 ====
270 EOT
271 unix2dos $mnt/slitaz/boot/he* $mnt/slitaz/boot/opt* \
272 $mnt/slitaz/boot/README
273 [ -d $mnt/slitaz/usr/sbin -a ! -x $mnt/slitaz/usr/sbin/mount.posixovl ] &&
274 cp $(which mount.posixovl) $mnt/slitaz/usr/sbin
275 if [ "$useposixovl" ] && grep -qs " $mnt " /proc/mounts &&
276 [ ! -d $mnt/boot/grub ]; then
277 mkdir -p $mnt/boot/grub
278 echo -en "\nInstall grub in /boot/grub..."
279 cp -a /usr/lib/grub/*/* $mnt/boot/grub
280 cat > $mnt/boot/grub/menu.lst <<EOT
281 # /boot/grub/menu.lst: GRUB boot loader configuration.
283 # By default, boot the first entry.
284 default 0
286 # Boot automatically after 8 secs.
287 timeout 8
289 title Microsoft Windows
290 chainloader +1
292 EOT
293 dev=$(grep " $mnt " /proc/mounts | awk '{ print $1 }')
294 base=${dev//[0-9]/}
295 dd if=$base bs=32k count=1 of=$mnt/boot/grub/$(basename $base)
296 cat > $mnt/boot/grub/uninstall-grub.sh <<EOT
297 #!/bin/sh
299 [ -s /boot/grub/$(basename $base) ] &&
300 dd if=/boot/grub/$(basename $base) of=$base
301 EOT
302 grub-install --no-floppy --root-directory=$mnt $base
303 fi
304 if [ -s $mnt/boot/grub/menu.lst ] &&
305 ! grep -q /slitaz/boot/$bzimage $mnt/boot/grub/menu.lst; then
306 echo -en "\nUpdate /boot/grub/menu.lst..."
307 cat >> $mnt/boot/grub/menu.lst <<EOT
308 title SliTaz GNU/Linux $(cat $mnt/slitaz/etc/slitaz-release)
309 kernel /slitaz/boot/$bzimage $extraargs autologin
310 initrd /slitaz/boot/$initrd
312 EOT
313 fi
314 rm -f /tmp/wait
315 [ "$useposixovl" ] && umount $mnt/slitaz
316 return 0
317 }
319 windev()
320 {
321 if [ -b "$1" ]; then
322 device=$1
323 elif [ "$1" ]; then
324 echo "Invalid Linux/Windows partition"
325 return 1
326 else
327 DEV="$(blkid | grep -iE "(msdos|vfat|ntfs|ext[234]|xfs|btrfs)" | sed 's/:.*//;s|/dev/||')"
328 [ "$DEV" ] || return
329 cat > /tmp/dialog$$ <<EOT
330 $DIALOG --clear --title " Select your Linux/Windows partition " \
331 --menu "\nPlease select the Linux/Windows partition according to its known size.
332 The data will be kept untouched.\n" 17 70 8 \
333 $(for i in $DEV ; do
334 label="$(blkid | sed "/$i:/!d;s/.*://;s/[^ ]*UUID=[^ ]* //g;s/LABEL=//")"
335 echo -n "/dev/$i \"$(($(cat /sys/block/*/$i/size)/2048))MB $label\" "
336 done)
337 EOT
338 exec 3>&1
339 [ $? -eq 0 ] || return
340 device=$(. /tmp/dialog$$ 2>&1 1>&3)
341 exec 3>&-
342 rm -f /tmp/dialog$$
343 fi
344 mnt=/tmp/mnt$$
345 mkdir -p $mnt && mount $device $mnt
346 }
348 extra_packages()
349 {
350 packages_list=
351 packages_dir=
352 $DIALOG --clear --title " Extra packages " \
353 --defaultno --yesno \
354 "Do you want to add extra packages ?" 7 70
355 [ $? -eq 0 ] || return
356 [ -s /var/lib/tazpkg/packages.txt ] || tazpkg recharge
357 if [ -s $media/boot/vmlinuz-$(uname -r) ]; then
358 cat > /tmp/dialog$$ <<EOT
359 $DIALOG --clear --title " Select the packages " \
360 --separate-output \
361 --cancel-label "Skip" \
362 --checklist "Please select the packages you want to install. Try with the first letter." \
363 0 0 0 \\
364 EOT
365 awk -F\| '{ printf "%s \"%s\" off ",$1,$3 }' \
366 /var/lib/tazpkg/packages.desc >> /tmp/dialog$$
367 sh /tmp/dialog$$ 2> /tmp/dialog.out$$
368 [ $? -eq 0 ] && packages_list="$(cat /tmp/dialog.out$$)"
369 fi
370 cat > /tmp/dialog$$ <<EOT
371 $DIALOG --clear \
372 --title "Please select the directory with every custom package to install." \
373 --cancel-label "Skip" --dselect $PWD 13 78
374 EOT
375 sh /tmp/dialog$$ 2> /tmp/dialog.out$$
376 [ $? -eq 0 ] && packages_dir="$(cat /tmp/dialog.out$$)"
377 rm -f /tmp/dialog$$ /tmp/dialog.out$$
378 }
380 _install()
381 {
382 extra_packages
383 $DIALOG --clear --title " SliTaz UMSDOS way installation " \
384 --yes-label "Install" --yesno \
385 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
386 Linux/DOS/Windows partition. You can see your files from /mnt/dos.\n\n
387 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
388 To uninstall SliTaz, you have only to remove this directory.
389 The file \\boot.ini or \\config.sys may be modified too.\n\n
390 SliTaz may run slowly on the 'UMSDOS way' installation due to the
391 posixovl filesystem. The 'TAZUSB way' installation runs faster.\n\n
392 To do a traditional installation with disk partitioning,
393 start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
394 [ $? -eq 0 ] || return
395 doinstall
396 }
398 readtazbootconf()
399 {
400 kernel="$(sed '/^image=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)"
401 initrd="$(sed '/^initrd=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)"
402 cmdline="$(sed '/^image=/d;/^initrd=/d' $mnt/slitaz/boot/tazboot.cmd)"
403 }
405 bootinstalled()
406 {
407 [ "$(which kexec)" ] || return
408 [ -x $mnt/slitaz$1 ] || return
409 [ -s $mnt/slitaz/boot/tazboot.cmd ] || return
410 readtazbootconf
411 kexec -l $kernel --initrd $initrd --command-line "$cmdline" || return
412 umount $mnt
413 rm -rf $mnt
414 quit "kexec -e"
415 }
417 mkzip()
418 {
419 device=
420 packages_list=
421 packages_dir=
422 mnt=/tmp/mkzipmnt$$
423 mkdir -p $mnt
424 $1 $2 || return
425 for i in bootlace.com grubinst.exe grldr ; do
426 wget -O $mnt/slitaz/boot/$i http://mirror.slitaz.org/boot/$i
427 done
428 readtazbootconf
429 cat > $mnt/slitaz/boot/menu.lst <<EOT
430 title SliTaz
431 kernel $kernel $cmdline
432 initrd $initrd
434 EOT
435 while read file title; do
436 file=$(ls $mnt/slitaz/boot/*$file* 2> /dev/null)
437 [ -s "$file" ] && cat >> $mnt/slitaz/boot/menu.lst <<EOT
438 title $title
439 kernel ${file#$mnt}
441 EOT
442 done <<EOT
443 memtest MemTest
444 pxe Web boot
445 EOT
446 unix2dos $mnt/slitaz/boot/menu.lst
447 unix2dos > $mnt/slitaz/boot/install.txt <<EOT
448 For DOS users (real mode only):
450 Start SliTaz with \\slitaz\\boot\\tazboot.exe
453 For NT/2000/XP users:
455 1- Move the files grldr and menu.lst into the root directory
457 C:\\> copy \\slitaz\\boot\\grldr \\
458 C:\\> copy \\slitaz\\boot\\menu.lst \\
460 2- Remove boot.ini attributes
462 C:\\> attrib -r -h -s boot.ini
464 3- Append the following line to boot.init
466 C:\\grldr="slitaz"
468 4- Restore boot.ini attributes
470 C:\\> attrib +r +h +s boot.ini
472 See http://diddy.boot-land.net/grub4dos/files/README_GRUB4DOS.txt
473 and http://xpt.sourceforge.net/techdocs/nix/disk/boot/boot07-GrubForDosInfo/ar01s03.html
474 EOT
475 ( cd $mnt ; echo 'See \slitaz\boot\install.txt to launch SliTaz.' | \
476 zip -zr9 $(basename "$ISO" .iso).zip slitaz )
477 [ "$(which advzip)" ] &&
478 echo "Recompressing $(basename "$ISO" .iso).zip ..." &&
479 advzip -z4 $mnt/*.zip
480 mv $mnt/*.zip .
481 du -h $PWD/$(basename "$ISO" .iso).zip
482 umount $mnt
483 rm -rf $mnt
484 }
486 install()
487 {
488 windev $1 || return
489 packages_list=
490 packages_dir=
491 if [ "$1" ]; then
492 doinstall
493 else
494 _install && bootinstalled /sbin/init
495 fi
496 umount $mnt
497 rm -rf $mnt
498 }
500 inst2zip()
501 {
502 if [ "$1" ]; then
503 mkzip doinstall
504 else
505 mkzip _install
506 fi
507 }
509 _installtaz()
510 {
511 $DIALOG --clear --title " SliTaz TAZUSB way installation " \
512 --yes-label "Install" --yesno \
513 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
514 Linux/DOS/Windows partition. You can see your files from /mnt/dos.\n\n
515 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
516 To uninstall SliTaz, you have only to remove this directory.
517 The file \\boot.ini or \\config.sys may be modified too.\n\n
518 The filesystem is loaded entirely into memory upon boot to
519 increase responsiveness. Only /home lands on the hard disk.\n\n
520 To do a traditional installation with disk partitioning,
521 start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
522 [ $? -eq 0 ] || return
523 doinstall tazusblike
524 }
526 installtaz()
527 {
528 windev $1 || return
529 packages_list=
530 packages_dir=
531 if [ "$1" ]; then
532 doinstall tazusblike
533 else
534 _installtaz && bootinstalled /boot/bzimage
535 fi
536 umount $mnt
537 rm -rf $mnt
538 }
540 insttaz2zip()
541 {
542 if [ "$1" ]; then
543 mkzip doinstall tazusblike
544 else
545 mkzip _installtaz
546 fi
547 }
549 bootiso()
550 {
551 cd /tmp
552 for i in $(ls_r $media/boot/rootfs*gz); do
553 grep -q ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64
554 cat $i
555 n=$((4 - ($(stat -c %s $i) % 4)))
556 [ $n -eq 4 ] || dd if=/dev/zero bs=1 count=$n
557 done > initrd$$
558 cmdline="autologin lang=$LANG"
559 [ -s /etc/keymap.conf ] && cmdline="$cmdline kmap=$(cat /etc/keymap.conf)"
560 [ -s /etc/TZ ] && cmdline="$cmdline tz=$(cat /etc/TZ)"
561 rm -f cmdline initrd 2> /dev/null
562 getcustomconf kexec >/dev/null
563 [ -s cmdline ] && cmdline="$cmdline $(cat cmdline)" && rm cmdline
564 [ -s initrd ] && cat initrd >> initrd$$ && rm initrd
565 kernel=$media/boot/bzImage
566 grep -q ' lm ' /proc/cpuinfo && [ -s ${kernel}64 ] && kernel=${kernel}64
567 . /etc/locale.conf
568 kexec -l $kernel --initrd initrd$$ --command-line "$cmdline" &&
569 rm -f initrd$$
570 quit "kexec -e"
571 }
573 tazboot()
574 {
575 if [ -z "$1" ]; then
576 $DIALOG --clear --title " SliTaz bootloader for DOS " \
577 --yes-label "Install" --yesno \
578 "\nThe file TAZBOOT.EXE will be created in the top directory. It supports
579 any linux kernel, multiple initramfs and a kernel command line.\n\n
580 Usage: tazboot.exe [[@commands]|[image=<bzimage>]
581 [initrd=<rootfs>[,<rootfs2>...]] cmdline args ...]\n\n
582 Defaults: tazboot @tazboot.cmd or tazboot image=bzImage auto\n\n\
583 Examples for tazboot.cmd:\n\n\
584 image=boot/bzImage\n\
585 initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\
586 autologin\n\n\
587 image=\\slitaz\\vmlinuz root=/dev/sda5 ro\n" 0 0
588 [ $? -eq 0 ] || return
589 fi
590 gettazboot tazboot.exe
591 du -h $PWD/tazboot.exe
592 }
594 md5()
595 {
596 dotwait "Checking files"
597 ( cd $media ; ${md5sum:-md5sum -c md5sum*} 2>&1 | sort ) > /tmp/data
598 unset md5sum
599 rm -f /tmp/wait
600 if [ "$1" ]; then
601 cat /tmp/data
602 else
603 $DIALOG --clear --title " Checked files " \
604 --textbox /tmp/data 0 0
605 fi
606 rm -f /tmp/data
607 }
609 gotcdfile()
610 {
611 for i in "$media/$1" "$media/*/$1" "$media/*/isolinux/$1" ; do
612 file=$(ls $i 2> /dev/null | sed q)
613 [ -s "$file" ] && break
614 done
615 }
617 sha()
618 {
619 gotcdfile 'sha*sum*'
620 sha=$(basename $file)
621 md5sum="${sha%sum*}sum -c ${file#$media/}"
622 md5 $@
623 }
625 readme()
626 {
627 gotcdfile 'README*'
628 if [ "$1" ]; then
629 cat $file
630 else
631 $DIALOG --clear --title " Readme " --textbox $file 0 0
632 fi
633 }
635 bzimage()
636 {
637 if [ -z "$1" ]; then
638 $DIALOG --clear --title " Create linux.exe ? " \
639 --yes-label "Install" --yesno \
640 "\nLinux.exe launches the linux kernel under DOS (in real mode only).
641 The cmdline arguments are supported except initrd=,
642 vga= (you can try 'rdev -v') and mem= (partially).
643 \nExample:\nC:\\> linux.exe root=/dev/hda2 ro panic=60\n" 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 --title " Create memtest.exe ? " \
654 --yes-label "Install" --yesno \
655 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
656 computers. BIOS based memory tests are a quick, cursory check and often
657 miss many of the failures that are detected by Memtest86.\n" 0 0
658 [ $? -eq 0 ] || return
659 fi
660 gotcdfile 'memtest*' && cp $file memtest.exe
661 du -h $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 .exe) 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 --title " Create a Memtest86 boot floppy " \
700 --yes-label "Create floppy" --yesno \
701 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
702 computers. BIOS based memory tests are a quick, cursory check and often
703 miss many of the failures that are detected by Memtest86.\n\n
704 Please insert a blank disk in floppy drive.\n" 0 0
705 [ $? -eq 0 ] || return
706 fi
707 gotcdfile 'memtest*' && mkfloppy $file
708 }
710 pxe()
711 {
712 gotcdfile '?pxe*'
713 if [ -z "$1" ]; then
714 $DIALOG --clear --title " Create $(basename $file .exe).exe ? " \
715 --yes-label "Install" --yesno \
716 "\nBoot your operating system from the internet and enjoy a full system
717 working entirely in RAM with speed and stability in mind. The Linux Kernel
718 and the complete SliTaz compressed root filesystem will be loaded into RAM
719 from the Web using PXE and HTTP protocols.\n" 0 0
720 [ $? -eq 0 ] || return
721 fi
722 cp $file $(basename $file .exe).exe
723 du -h $PWD/$(basename $file .exe).exe
724 }
726 fdpxe()
727 {
728 if [ -z "$1" ]; then
729 $DIALOG --clear --title " Create a SliTaz Web boot floppy " \
730 --yes-label "Create floppy" --yesno \
731 "\nBoot your operating system from the internet and enjoy a full system
732 working entirely in RAM with speed and stability in mind. The Linux Kernel
733 and the complete SliTaz compressed root filesystem will be loaded into RAM
734 from the Web using PXE and HTTP protocols.\n\n
735 Please insert a blank disk in floppy drive.\n" 0 0
736 [ $? -eq 0 ] || return
737 fi
738 gotcdfile '?pxe*' && mkfloppy $file
739 }
741 menuitem()
742 {
743 [ "$3" ] && shift
744 echo -en "\"$1\" \"$2\""
745 }
747 gotposixovl()
748 {
749 mount.posixovl 2>&1 | grep -qi usage && gotcdfile 'rootfs*.gz' &&
750 menuitem "$@"
751 }
753 gotposixovlzip()
754 {
755 [ "$(which zip)" ] && gotposixovl "$1" "$2"
756 }
758 xfile()
759 {
760 [ "$(which $1)" ] && menuitem "$@"
761 }
763 cdfile()
764 {
765 gotcdfile "$1" && menuitem "$@"
766 }
768 gottazusb()
769 {
770 gotcdfile 'rootfs*.gz' && xfile tazusb "$@"
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 cdrkit-isoinfo ; 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 burnable()
826 {
827 [ "$(sed '/Can wr.*1$/!d' /proc/sys/dev/cdrom/info 2> /dev/null)" ] &&
828 menuitem "$@"
829 }
831 blankable()
832 {
833 [ "$(sed '/Can wr.*RW.*1$/!d' /proc/sys/dev/cdrom/info 2> /dev/null)" ] &&
834 menuitem "$@"
835 }
837 burniso()
838 {
839 wodim -v speed=$(fgrep "drive speed" /proc/sys/dev/cdrom/info | cut -f3) \
840 -eject -multi "$ISO"
841 }
843 blankcd()
844 {
845 wodim -v -blank=fast
846 }
848 customsector()
849 {
850 local c=$(echo $(get 32848 "$ISO" 4))
851 hascustomconf $(($c+16)) && echo $(($c+16)) || echo $c
852 }
854 hascustomconf()
855 {
856 [ "$(ddq bs=2k skip=${1:-$(customsector)} if="$ISO" | ddq bs=1 count=6)" \
857 = "#!boot" ]
858 }
860 gotcustomconf()
861 {
862 hascustomconf && menuitem "$@"
863 }
865 hasflavor()
866 {
867 [ -x /usr/bin/tazlito ] && [ -s $media/boot/bzImage ] && menuitem "$@"
868 }
870 gotisomd5()
871 {
872 [ "$(which md5sum 2> /dev/null)" ] &&
873 [ $(get 0 "$ISO") -eq 23117 ] &&
874 [ $(get 18 "$ISO") -ne 0 ] && menuitem "$@"
875 }
877 getcustomconf()
878 {
879 ddq bs=2k skip=$(customsector) if="$ISO" | while read line; do
880 case "$line" in
881 \#!boot*) ;;
882 append=*) echo ${line#append=} > cmdline && ls -l $PWD/cmdline ;;
883 initrd:*) cnt=${line#initrd:}
884 { ddq bs=512 count=$(($cnt / 512));
885 ddq bs=1 count=$(($cnt % 512)); } > initrd &&
886 ls -l $PWD/initrd
887 break ;;
888 *) break ;;
889 esac
890 done
891 [ "$1" ] && return 0
892 echo -e "\rPress RETURN to continue."
893 read n
894 }
896 isomd5()
897 {
898 dotwait "Checking iso image"
899 [ "$(ddq if="$ISO" bs=2k skip=16 \
900 count=$(($(get 32848 "$ISO" 4)-16)) | md5sum)" = \
901 "$(ddq if="$ISO" bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \
902 sed 's/ //g') -" ] && echo "OK" || echo "ERROR"
903 echo -en "\rChecking iso hybrid boot..."
904 n=$(($(get 2 "$ISO")-1+($(get 4 "$ISO")-1)*512))
905 if [ $n -lt 40000 -a $n -gt 32768 ]; then
906 s=$(get 0 "$ISO" 2 $n | awk '{ i+= $0 } END { print i }')
907 [ $(((1+$s+$(get $(($n+1)) "$ISO" 1)) % 65536)) -eq 0 ] &&
908 echo "OK" || echo "ERROR"
909 fi
910 if hascustomconf; then
911 echo -en "\rChecking iso custom config..."
912 TMP=/tmp/$(basename $0)$$md5
913 md5="$(ddq bs=2k skip=$(customsector) if="$ISO" | while read line; do
914 case "$line" in
915 \#!boot*) echo ${line#*boot } > $TMP ;;
916 append=*) echo $line ;;
917 initrd:*) echo $line
918 cnt=${line#initrd:}
919 ddq bs=512 count=$((cnt / 512))
920 ddq bs=1 count=$((cnt % 512))
921 break ;;
922 *) break ;;
923 esac
924 done | md5sum | cut -c1-32)"
925 [ "$md5" = "$(cat $TMP)" ] && echo "OK" || echo "ERROR"
926 rm -f $TMP
927 fi
928 rm -f /tmp/wait
929 [ "$1" ] && return 0
930 echo -e "\rPress RETURN to continue."
931 read n
932 }
934 usbdev()
935 {
936 dotwait "Wait 5 seconds for USB devices"
937 sleep 5
938 rm -f /tmp/wait
939 DEV="$(grep -l 1 /sys/block/*/removable | \
940 sed 's|/sys/block/\(.*\)/removable|\1|')"
941 grep -qs 1 /sys/block/$DEV/ro && return
942 [ "$DEV" ] || return
943 cat > /tmp/dialog$$ <<EOT
944 $DIALOG --clear --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 --title " Create a USB boot key " \
977 --yes-label "Continue" --yesno \
978 "\nThe USB key will be used like a CD-ROM. You will not be able to write
979 any data on the boot partition.\n\n
980 An extra FAT32 partition will be created with the remaining free space.\n\n
981 $(tazusbmsg)Please plug your USB stick in now.\n" 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 --title " Create a SliTaz USB key " \
1026 --yes-label "Continue" --yesno \
1027 "\nUnlike a hard drive install, the filesystem is kept in a compressed
1028 rootfs.gz. The filesystem is loaded entirely into memory upon boot.
1029 This should increase responsiveness, protect the filesystem against
1030 accidental corruption and reduce read/writes to the USB drive.
1031 Once setup, the tazusb utility can rewrite the root filesystem
1032 with any changes you have made since booting up,
1033 giving the effective benefits of a hard drive install.\n\n
1034 /home is mounted on boot using the UUID of your particular flash drive.
1035 Unlike a device name, the UUID has the benefit of never changing from machine
1036 to machine.\n\n
1037 Please plug your USB stick in now.\n" 19 70
1038 [ $? -eq 0 ] || return
1039 usbdev || return
1040 exec 3>&1
1041 format=`$DIALOG --clear \
1042 --title " Select the filesystem " \
1043 --radiolist "\nPlease select the filesystem type to create.\n\n\
1044 The filesystem creation will erase all the data in the USB key." 14 70 4 \
1045 "none" "Do not erase the USB key" on \
1046 "ext3" "Ext3 journaling filesystem" off \
1047 "ext2" "Ext2 filesystem" off \
1048 "fat32" "Windows FAT32 filesystem" off \
1049 2>&1 1>&3`
1050 retval=$?
1051 exec 3>&-
1052 [ $retval -eq 0 ] || return
1053 [ "$format" != "none" ] && tazusb format $device "SliTaz" $format
1054 tazusb gen-iso2usb "$ISO" $device
1057 dokexec()
1059 kexec -l $file || return
1060 quit "kexec -e"
1063 runmemtest()
1065 gotcdfile 'memtest*' && dokexec
1068 runpxe()
1070 gotcdfile '?pxe*' && dokexec
1073 flavdata()
1075 [ $(get 1024 "$ISO") -eq 35615 ] && n=2 || n=$((1+$(get 417 "$ISO" 1)))
1076 [ $n -eq 4 ] && n=20
1077 [ $(get $(($n*512)) "$ISO") -eq 35615 ] || n=13
1078 ddq if="$ISO" bs=512 skip=$n count=20 | zcat 2>/dev/null
1081 hasflavinfo()
1083 [ "$(flavdata | ddq bs=1 count=7 | strings)" = \
1084 "0707010" ] && menuitem "$@"
1087 showfavinfo()
1089 mkdir -p /tmp/data
1090 flavdata | ( cd /tmp/data ; cpio -i )
1091 file=/tmp/data/info
1092 cat /tmp/data/*desc > $file
1093 if [ -s /tmp/data/*receipt ]; then
1094 echo "=== receipt ==="
1095 cat /tmp/data/*receipt
1096 fi >> $file
1097 for i in /tmp/data/*list* ; do
1098 echo "=== extra ${i#*list} files"
1099 cat $i
1100 done >> $file
1101 if [ "$1" ]; then
1102 cat $file
1103 else
1104 $DIALOG --clear --title " Flavor info " \
1105 --textbox $file 0 0
1106 fi
1107 rm -rf /tmp/data
1110 flavor()
1112 name="$(flavdata | cpio -t 2> /dev/null | sed 's/.[a-z]*$//;q')"
1113 echo "Create ${name:=flavor}.flavor..."
1114 tazlito iso2flavor "$ISO" $name
1115 ls -l $name.flavor 2> /dev/null && return
1116 sleep 5
1117 [ "$1" ] && return
1118 echo -e "\rPress RETURN to continue."
1119 read n
1122 if [ "$1" = "--build" ]; then #install-begin
1123 uuencode -m - < header.com | sed -e '/^HEADERCODE$/r/dev/stdin' \
1124 -e "s|HEADERSZ|$(stat -c %s header.com)|" -e '/^HEADERCODE$/d' -i $0
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 $0 include $file | parse_isolinux > /tmp/var$$
1191 . /tmp/var$$
1192 [ -z "$KERNEL" ] && echo "Can't parse isolinux.cfg" && return
1193 for i in $media/$KERNEL $(dirname $file)/$KERNEL $media/$(locase $KERNEL) \
1194 $(dirname $file)/$(locase $KERNEL); do
1195 i="$(ls $i* | sed q)"
1196 [ -n "$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 j="$(ls $j* | sed q)"
1227 [ -n "$j" ] && i=$j && break
1228 done
1229 ddq if=$i >> /tmp/fd$$
1230 l=$(($l+$(stat -c %s $i)))
1231 r=$((4 - ($l % 4)))
1232 if [ $r -ne 4 ]; then
1233 ddq if=/dev/zero bs=1 count=$r >> /tmp/fd$$
1234 l=$(($l + $r))
1235 fi
1236 case "$i:$INITRD" in
1237 *rootfs.gz:*rootfs.gz,*) continue # loram
1238 esac
1239 len="$len $l"; l=0
1240 done
1241 rdadrs=${RDADRS:-$(((($syssize*16)+0x1F0000) & -4096))}
1242 words2bin $(($rdadrs & 0xFFFF)) $(($rdadrs >> 16)) | ddq \
1243 conv=notrunc bs=1 seek=536 count=4 of=/tmp/fd$$
1244 fi
1245 n=$(echo $len | wc -w)
1246 if [ $((494 - $(get 494 /tmp/fd$$))) -ge $(($n * 4)) ]; then
1247 i=$(($(get 494 /tmp/fd$$)))
1248 bytes2bin $(($i + ($n*4) - 256)) | ddq bs=1 conv=notrunc \
1249 seek=496 count=1 of=/tmp/fd$$
1250 else
1251 i=$(($pos + 0x1FC - ($n*4)))
1252 bytes2bin $(($i % 256)) $((i / 256)) 252 | ddq bs=1 \
1253 conv=notrunc seek=494 count=3 of=/tmp/fd$$
1254 s=$(($i - 2*$(echo "$SIZES" | wc -w)))
1255 p=$(($s - $(ifmemcode | wc -c)))
1256 ifmemcode | ddq bs=1 conv=notrunc seek=$p of=/tmp/fd$$
1257 words2bin $SIZES | ddq bs=1 conv=notrunc seek=$s of=/tmp/fd$$
1258 bytes2bin 154 $(($p%256)) $(($p/256)) 0 144 | \
1259 ddq bs=1 conv=notrunc seek=60 of=/tmp/fd$$
1260 fi
1261 for r in $len ; do
1262 words2bin $(($r & 0xFFFF)) $(($r >> 16)) | ddq conv=notrunc \
1263 bs=1 seek=$i count=4 of=/tmp/fd$$
1264 i=$(($i + 4))
1265 done
1266 split -b 1440k /tmp/fd$$ fd$$
1267 rm -f /tmp/fd$$
1268 n=1; i=0; r=0
1269 set -- $len
1270 ls fd$$* | while read file ; do
1271 if [ $i -gt $(($1+$base)) ]; then
1272 shift
1273 r=$(($r+100)); n=0; i=0; base=0
1274 fi
1275 ddq of=$file bs=18k seek=80 count=0
1276 i=$(($i+1474560))
1277 printf "mv %s fd%03d.img\n" $file $(($r+$n))
1278 n=$(($n+1))
1279 done | sh
1280 du -ch $PWD/fd???.img
1283 quit()
1285 umount -d $media
1286 rmdir $media
1287 ${1:-exit}
1290 infoiso()
1292 isoinfo -d -i "$ISO" > /tmp/isoinfo$$
1293 if [ -x "$(which iso2exe)" ]; then
1294 echo "----"
1295 blkid "$ISO" | while read args; do
1296 set -- $args
1297 while [ -n "$2" ]; do
1298 case "$2" in
1299 *UUID*|PT*) echo $2;;
1300 esac
1301 shift
1302 done
1303 done
1304 if ! fdisk -l "$ISO" | grep -q 'valid partition'; then
1305 fdisk -l "$ISO" | grep heads
1306 fdisk -l "$ISO" | sed 's/^ *[^ ]* *//;s/ */ /g;$!d'
1307 fi
1308 echo "----"
1309 iso2exe -l "$ISO"
1310 fi >> /tmp/isoinfo$$
1311 if [ "$1" ]; then
1312 cat /tmp/isoinfo$$
1313 else
1314 $DIALOG --clear --title " Info ISO " \
1315 --textbox /tmp/isoinfo$$ 0 0
1316 fi
1317 rm -f /tmp/isoinfo$$
1320 isotitle()
1322 echo "$(blkid "$ISO" | sed 's/.*LABEL="\([^"]*\).*/\1/') $(stat \
1323 -c %y $media/.|sed 's/ .*//') $(basename "$ISO")"
1326 if [ "$1" = "include" ]; then
1327 [ -s "$2" ] && cd $(dirname "$2") && awk -v exe=$0 \
1328 '{ if ($1 == "include") system(exe " include " $2); else print }' <"$2"
1329 exit
1330 fi
1331 ISO="${1:-/dev/null}"
1332 [ ${ISO:0:1} != "/" ] && ISO=$(cd $(dirname $ISO); echo $PWD/$(basename $ISO))
1333 [ -z "$(isiso 2> /dev/null)" ] && echo "Usage : $0 file.iso" && exit 1
1334 media=/tmp/media$$
1335 mkdir -p $media
1336 mount -o loop,ro "$ISO" $media
1338 if [ "$2" = "list" ]; then
1339 sed '/^\$(.*") \\/!d;s/^\$(\(.*\)").*/\1"/' $0 | while read line; do
1340 eval $line
1341 echo
1342 done | sed '/^$/d;/"usbkey"/d'
1343 quit
1344 fi
1345 if grep -q "^$2()" $0; then
1346 exe=$2
1347 shift 2
1348 if [ -n "$(eval $(grep "\"$exe\"" $0 | sed \
1349 '/^\$/!d;s/.(\(.*\)[\t ]*".*"[\t ]*".*/\1/'))" ]; then
1350 isotitle
1351 grep "\"$exe\"" $0 | sed '/^\$/!d;s/.*"[\t ]*"\(.*\)".*/\1/'
1352 echo ----
1353 $exe "$@"
1354 fi
1355 quit
1356 fi
1358 while true; do
1359 cat > /tmp/dialog$$ <<EOT
1360 $DIALOG --clear --title " $(isotitle) " --menu "" 28 70 30 \
1361 $(cdfile 'README*' "readme" "Show the README file") \
1362 $(gotcustomconf "getcustomconf" "Get custom config") \
1363 $(gotisomd5 "isomd5" "Check the ISO image") \
1364 $(cdfile 'md5sum*' "md5" "Check the ISO files") \
1365 $(cdfile 'sha*sum*' "sha" "Check the ISO files") \
1366 $(xfile isoinfo "infoiso" "ISO image info") \
1367 $(cdfilex boot/bzImage "bootiso" "Boot the ISO image") \
1368 $(burnable "burniso" "Burn the ISO image") \
1369 $(blankable "blankcd" "Blank the CD/DVD") \
1370 $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \
1371 $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \
1372 $(gotposixovlzip "inst2zip" "ZIP installation archive (UMSDOS way)") \
1373 $(gotposixovlzip "insttaz2zip" "ZIP installation archive (TAZUSB way)") \
1374 $(gottazusb "usbkey" "USB key read/write installation") \
1375 $(ishybrid "usbbootkey" "USB boot key (read only)") \
1376 $(hasflavinfo "showfavinfo" "Show flavor extra info") \
1377 $(hasflavor "flavor" "Get flavor file") \
1378 $(cdfile isolinux.cfg "floppyset" "Boot floppy set") \
1379 $(cdfile linld.com "tazboot" "Get tazboot.exe Linux loader") \
1380 $(cdexe boot/bzImage "bzimage" "Get linux DOS/EXE file") \
1381 $(cdexe 'memtest*' "memtest" "Get Memtest86 DOS/EXE file") \
1382 $(cdfilef 'memtest*' "fdmemtest" "Create a Memtest86 boot floppy") \
1383 $(cdfilex 'memtest*' "runmemtest" "Start Memtest86") \
1384 $(cdexe '?pxe*' "pxe" "Get SliTaz Web boot DOS/EXE utility") \
1385 $(cdfilef '?pxe*' "fdpxe" "Create a SliTaz Web boot floppy") \
1386 $(cdfilex '?pxe*' "runpxe" "Start the SliTaz Web boot utility") \
1387 $(misspkg "missing" "Install packages to get more options") \
1388 $(menuitem "quit" "Quit this utility")
1389 EOT
1390 exec 3>&1
1391 value=$(. /tmp/dialog$$ 2>&1 1>&3)
1392 retval=$?
1393 exec 3>&-
1394 rm -f /tmp/dialog$$
1395 [ $retval -eq 0 ] || quit
1396 $value
1397 done