wok-current annotate syslinux/stuff/iso2exe/taziso @ rev 25733

Accept licence PyQt-x11-gpl, bump firmware* to 20240610, build imagemagick (merge)
author Stanislas Leduc <shann@slitaz.org>
date Fri Dec 20 16:13:23 2024 +0000 (8 days ago)
parents 2ac466d9d0a7
children
rev   line source
pascal@17635 1 #!/bin/sh
pascal@17635 2
pascal@23831 3 [ 0$(id -u 2>/dev/null) -eq 0 ] || exec su -c "$0 $@"
pascal@17635 4
pascal@17635 5 DIALOG=dialog
pascal@17635 6
pascal@17635 7 ddq()
pascal@17635 8 {
pascal@17635 9 dd $@ 2> /dev/null
pascal@17635 10 }
pascal@17635 11
pascal@23946 12 ddn()
pascal@23946 13 {
pascal@23946 14 ddq conv=notrunc $@
pascal@23946 15 }
pascal@23946 16
pascal@17635 17 get()
pascal@17635 18 {
pascal@21542 19 hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %u\n\"" "$2"
pascal@17635 20 }
pascal@17635 21
pascal@17635 22 bytes2bin()
pascal@17635 23 {
pascal@17635 24 for i in $@ ; do
pascal@24177 25 printf '\\\\x%02X' $((i&255))
pascal@17635 26 done | xargs echo -en
pascal@17635 27 }
pascal@17635 28
pascal@17635 29 words2bin()
pascal@17635 30 {
pascal@17635 31 for i in $@ ; do
pascal@24177 32 printf '\\\\x%02X\\\\x%02X' $((i&255)) $(((i>>8)&255))
pascal@17635 33 done | xargs echo -en
pascal@17635 34 }
pascal@17635 35
pascal@23951 36 quads2bin()
pascal@23947 37 {
pascal@23947 38 for i in $@ ; do
pascal@24177 39 printf '\\\\x%02X\\\\x%02X\\\\x%02X\\\\x%02X' $((i&255)) \
pascal@24177 40 $(((i>>8)&255)) $(((i>>16)&255)) $(((i>>24)&255))
pascal@23947 41 done | xargs echo -en
pascal@23947 42 }
pascal@23947 43
pascal@17635 44 gettazboot()
pascal@17635 45 {
pascal@21542 46 echo -e "\nCreating $(basename $1) ..."
pascal@23996 47 gotcdfile linld.com
pascal@23996 48 S=$(($(stat -c %s $file)+12))
pascal@24177 49 P=$(((S+511)/512))
pascal@24177 50 E=$((4096-(32*P)))
pascal@24177 51 words2bin 0x5A4D $((S%512)) $P 0 2 $E -1 -16 \
pascal@18140 52 -2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1
pascal@23996 53 dd if=$file bs=1 count=$(($(stat -c %s $file)-1)) >> $1 2> /dev/null
pascal@23996 54 echo -en '@tazboot.cmd\0' >> $1
pascal@17635 55 }
pascal@17635 56
pascal@23946 57 maybe64()
pascal@23946 58 {
pascal@23946 59 echo -n $1
pascal@23946 60 grep -q ' lm ' /proc/cpuinfo && [ -s ${1}64 ] && echo 64
pascal@23946 61 }
pascal@23946 62
pascal@23947 63 size()
pascal@23947 64 {
pascal@23951 65 stat -c %s "$1"
pascal@23951 66 }
pascal@23951 67
pascal@23951 68 sectcnt()
pascal@23951 69 {
pascal@23951 70 [ ! -b "$1" ] && echo $(($(size "$1")/512)) ||
pascal@23951 71 cat /sys/block/${1#/dev/}/size
pascal@23947 72 }
pascal@23947 73
pascal@17635 74 uncpio()
pascal@17635 75 {
pascal@23820 76 i=$1
pascal@23946 77 [ $0 = /init.exe ] && i=$(maybe64 $i)
pascal@23820 78 [ -s "$i" ] || return
pascal@23820 79 echo -en "\n Extracting $(basename $i) ..."
pascal@23820 80 case $(get 0 $i) in
pascal@17635 81 *35615) ( zcat || gunzip ) ;;
pascal@17635 82 *14333) unxz ;;
pascal@17635 83 *\ 93) unlzma ;;
pascal@17635 84 *) cat ;;
pascal@23820 85 esac < $i | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
pascal@17635 86 }
pascal@17635 87
pascal@23831 88 xdotwait=dotwait
pascal@17635 89 dotwait()
pascal@17635 90 {
pascal@17635 91 echo -n "${1:-Install filesystem}.."
pascal@23820 92 echo -n > /tmp/wait
pascal@17930 93 [ "$REQUEST_URI" ] && return
pascal@17635 94 while [ -e /tmp/wait ]; do
pascal@23820 95 echo -n "." > /dev/${tty0:-tty}
pascal@17635 96 sleep 1
pascal@17635 97 done &
pascal@17635 98 }
pascal@17635 99
pascal@17635 100 getuuid()
pascal@17635 101 {
pascal@17635 102 dev=$(mount | sed "/ $(echo $mnt | sed 's|/|\\/|g') /!d;s/ .*//;s|/dev/||;q")
pascal@17635 103 [ "$dev" ] &&
pascal@17635 104 blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/" ||
pascal@17635 105 echo "/dev/hda1"
pascal@17635 106 }
pascal@17635 107
pascal@17635 108 tazusbinitfs()
pascal@17635 109 {
pascal@23947 110 PAD=$(($(size $1) % 4))
pascal@24177 111 [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - PAD)) >> $1
pascal@17635 112 mkdir -p /tmp/fs$$/etc /tmp/fs$$/lib /tmp/fs$$/home
pascal@21542 113 cp -a /etc/locale.conf /etc/locale.conf /tmp/fs$$/etc 2> /dev/null
pascal@17635 114 cat > /tmp/fs$$/init1 <<EOT
pascal@17635 115 #!/bin/sh
pascal@17635 116 sed -i 's|sbin/init|init2|' /init
pascal@17635 117 exec /init
pascal@17635 118 EOT
pascal@17635 119 cat > /tmp/fs$$/init2 <<EOT
pascal@17635 120 #!/bin/sh
pascal@17635 121
pascal@17635 122 mount -t proc /proc /proc
pascal@21542 123 for i in /lib/modules/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
pascal@17635 124 v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2> /dev/null)
pascal@17635 125 mount / -o remount,rw
pascal@17635 126 mkdir /mnt/dos
pascal@17635 127 rm -f /cmdline 2> /dev/null
pascal@17635 128 mount / -o remount,ro
pascal@17635 129 mnt=/mnt/dos/\${v#*/}
pascal@17635 130 dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q')
pascal@17635 131 echo "Mount \$dev in /mnt/dos for \$v..." | tee -a /run/boot.log
pascal@17635 132 mount \$dev /mnt/dos
pascal@17635 133 if [ ! -d /mnt/dos/slitaz ]; then
pascal@17635 134 umount /mnt/dos 2> /dev/null
pascal@17635 135 (blkid /dev/[sh]d* || blkid) | while read dev line; do
pascal@17635 136 case "\$line" in
pascal@17635 137 *ntfs*|*vfat*|*msdos*) ;;
pascal@17635 138 *) continue ;;
pascal@17635 139 esac
pascal@17635 140 mount \${dev%:} /mnt/dos
pascal@17635 141 [ -d /mnt/dos/slitaz ] && break
pascal@17635 142 umount /mnt/dos
pascal@17635 143 done
pascal@17635 144 fi
pascal@17932 145 $([ "$2" ] || echo '# ')mount.posixovl -F \$mnt -- -oallow_other -odefault_permissions -osuid
pascal@17635 146 mount --bind \$mnt /home
pascal@21542 147 mount -o size=0,ro -t tmpfs tmpfs \$mnt
pascal@17635 148 umount /proc
pascal@17635 149 exec /sbin/init
pascal@17635 150 EOT
pascal@17635 151 chmod 755 /tmp/fs$$/init?
pascal@21542 152 ln -s /sqfs/bin/gzip /bin 2> /dev/null
pascal@17635 153 ( cd /tmp/fs$$ ; find * | cpio -o -H newc ) | gzip -9 >> $1
pascal@17635 154 rm -rf /tmp/fs$$
pascal@17635 155 }
pascal@17635 156
pascal@17635 157 mkinitrd()
pascal@17635 158 {
pascal@17635 159 echo -en "\nCreating $(basename $1) "
pascal@17635 160 fs=/tmp/fs$$
pascal@17635 161 for i in bin lib dev proc tmp mnt etc ; do
pascal@17635 162 mkdir -p $fs/$i
pascal@17635 163 done
pascal@21542 164 for i in /dev/null /dev/tty /dev/tty[012] /dev/fuse /dev/[hs]d* \
pascal@21542 165 /dev/console ; do
pascal@17635 166 cp -a $2$i $fs/dev/
pascal@17635 167 done
pascal@23149 168 for i in /bin/busybox $(which mount.posixovl) $(which blkid) \
pascal@23149 169 $(which ntfs-3g); do
pascal@17635 170 cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \
pascal@17635 171 sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') $fs/lib
pascal@17635 172 cp $i $fs/bin
pascal@17635 173 done
pascal@21542 174 cp -a /sqfs/lib/ld-* /tmp/fs/lib 2> /dev/null ||
pascal@17635 175 cp -a /lib/ld-* $fs/lib
pascal@17635 176 for i in $(busybox | sed '/Current/,$!d'); do
pascal@17635 177 [ -e $fs/bin/${i%,} ] || ln -s busybox $fs/bin/${i%,}
pascal@17635 178 done
pascal@17635 179 ln -s /proc/mounts $fs/etc/mtab
pascal@17635 180 sed 's/ .*//' /proc/modules | while read mod ; do
pascal@17635 181 find /lib/modules/ | grep $mod.ko | \
pascal@17635 182 sed 's|.*|cp & $fs/lib|' | sh
pascal@17635 183 done
pascal@17635 184 cat > $fs/init <<EOT
pascal@17635 185 #!/bin/sh
pascal@17635 186
pascal@17635 187 arg()
pascal@17635 188 {
pascal@17635 189 grep -q \$1 /proc/cmdline &&
pascal@17635 190 val="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" < /proc/cmdline)" &&
pascal@17635 191 echo "\$2 \$val"
pascal@17635 192 }
pascal@17635 193
pascal@17635 194 mount -t proc /proc /proc
pascal@17635 195 arg debug "shell" && debug=true && set -x
pascal@17635 196 for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
pascal@17635 197 arg mount "Mount device"
pascal@23149 198 dsk=\$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q')
pascal@23149 199 mount \$dsk /mnt || mount.ntfs \$dsk /mnt
pascal@17635 200 arg subroot "Change root to directory"
pascal@17635 201 if [ -d /mnt/\$val ]; then
pascal@17635 202 umount /mnt 2> /dev/null
pascal@17635 203 (blkid /dev/[sh]d* || blkid) | while read dev line; do
pascal@17635 204 case "\$line" in
pascal@17635 205 *ntfs*|*vfat*|*msdos*) ;;
pascal@17635 206 *) continue ;;
pascal@17635 207 esac
pascal@17635 208 mount \${dev%:} /mnt
pascal@17635 209 [ -d /mnt/\$val ] && break
pascal@17635 210 umount /mnt
pascal@17635 211 done
pascal@17635 212 fi
pascal@23149 213
pascal@23149 214 $([ "$3" ] || echo -n '# ')mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid
pascal@17635 215 mount --bind /mnt /mnt/\$val/mnt/dos
pascal@21542 216 mount -o size=0,ro -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val
pascal@17635 217 LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q)
pascal@17635 218 export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib
pascal@17635 219 [ "$debug" = "true" ] && sh
pascal@17635 220 umount /proc
pascal@17635 221 exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init
pascal@17635 222 EOT
pascal@17635 223 chmod +x $fs/init
pascal@17635 224 ( cd $fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null
pascal@17635 225 rm -rf $fs /tmp/wait
pascal@17635 226 }
pascal@17635 227
pascal@17635 228 ls_r()
pascal@17635 229 {
pascal@17635 230 ls -r $@ 2> /dev/null || ls $@
pascal@17635 231 }
pascal@17635 232
pascal@23820 233 is_loram()
pascal@23820 234 {
pascal@23820 235 [ -s /lib/modules/squashfs.ko* ]
pascal@23820 236 }
pascal@23820 237
pascal@17635 238 doinstall()
pascal@17635 239 {
pascal@17932 240 unset useposixovl
pascal@17934 241 blkid | grep $(df $mnt | sed '$!d;s/ .*/:/') | \
pascal@17932 242 grep -qiE "(msdos|vfat|ntfs)" && useposixovl=YES
pascal@19029 243 case "$mnt" in
pascal@19029 244 *mkzip*) useposixovl=YES
pascal@19029 245 esac
pascal@17635 246 mkdir -p $mnt/slitaz/boot $mnt/slitaz/mnt/dos
pascal@17932 247 [ "$useposixovl" ] &&
pascal@17635 248 if ! mount.posixovl -F $mnt/slitaz -- \
pascal@17635 249 -oallow_other -odefault_permissions -osuid; then
pascal@17635 250 echo "Can't install SliTaz. Abort."
pascal@17635 251 sleep 5
pascal@17635 252 return 1
pascal@17635 253 fi
pascal@17635 254 dotwait "Install root filesystem in /slitaz.."
pascal@17635 255 if [ "$1" ]; then
pascal@24023 256 ls_r $media/boot/rootfs*gz* | \
pascal@17635 257 xargs cat > $mnt/slitaz/boot/rootfs.gz
pascal@17932 258 tazusbinitfs $mnt/slitaz/boot/rootfs.gz $useposixovl
pascal@17635 259 initrd=rootfs.gz
pascal@17635 260 extraargs="/home=$(getuuid)/slitaz rdinit=/init1"
pascal@17635 261 else
pascal@23820 262 if [ -d $media/fs ]; then
pascal@23820 263 cp -a $media/fs/. $mnt/slitaz
pascal@23820 264 elif is_loram; then
pascal@23820 265 for i in $(ls_r $media/boot/rootfs*); do
pascal@23820 266 losetup -o 124 /dev/loop7 $i
pascal@23820 267 mount -t squashfs -o ro /dev/loop7 /sqfs/mnt
pascal@23820 268 cp -a /sqfs/mnt/. $mnt/slitaz
pascal@23820 269 umount /sqfs/mnt
pascal@23820 270 losetup -d /dev/loop7
pascal@23820 271 done
pascal@23820 272 else
pascal@24023 273 for i in $(ls_r $media/boot/rootfs*gz*); do
pascal@23820 274 ${uncpio:-uncpio} $i $mnt/slitaz
pascal@23820 275 done
pascal@23820 276 fi
pascal@17635 277 for i in $packages_list; do
pascal@17635 278 tazpkg get-install $i --root=$mnt/slitaz
pascal@17635 279 done
pascal@17635 280 for i in $packages_dir/*.tazpkg; do
pascal@17635 281 [ -s "$i" ] &&
pascal@17635 282 tazpkg install $i --root=$mnt/slitaz
pascal@17635 283 done
pascal@17635 284 cp -a /etc/locale.conf $mnt/slitaz/etc 2> /dev/null
pascal@17635 285 cp -a /etc/keymap.conf $mnt/slitaz/etc 2> /dev/null
pascal@17932 286 mkinitrd $mnt/slitaz/boot/initrd $mnt/slitaz $useposixovl
pascal@17635 287 initrd=initrd
pascal@17635 288 extraargs="mount=$(getuuid) subroot=slitaz"
pascal@17635 289 fi
pascal@17635 290 echo -en "\nInstall boot files..."
pascal@20158 291 for i in $media/boot/bzImage* $media/boot/*pxe* \
pascal@24011 292 $media/boot/plop* \
pascal@18240 293 $media/boot/isolinux/he* $media/boot/isolinux/opt* \
pascal@18240 294 $media/README $media/boot/memtest* ; do
pascal@17635 295 [ -s $i ] && cp $i $mnt/slitaz/boot
pascal@17635 296 done
pascal@21542 297 for i in $mnt/slitaz/boot/memtest $mnt/slitaz/boot/*pxe ; do
pascal@17635 298 [ $(get 0 $i 2> /dev/null || echo 0) -eq 23117 ] &&
pascal@17635 299 mv $i $i.exe
pascal@17635 300 done
pascal@24023 301 bzimage=$(cd $mnt/slitaz/boot ; ls bzImage* | sed q)
pascal@21542 302 cp /etc/keymap.conf /etc/locale.conf $mnt/slitaz/etc 2> /dev/null
pascal@20158 303 gettazboot $mnt/slitaz/boot/tazboot.exe # autoappend 64 suffix
pascal@17635 304 unix2dos > $mnt/slitaz/boot/tazboot.cmd <<EOT
pascal@24023 305 image=/slitaz/boot/$bzimage
pascal@17635 306 initrd=/slitaz/boot/$initrd
pascal@23890 307 root=/dev/null $extraargs autologin
pascal@17635 308 EOT
pascal@21553 309 uudecode - <<EOT | gunzip > $mnt/slitaz/boot/slitaz.pif
pascal@21553 310 begin-base64 644 -
pascal@21553 311 H4sIAAAAAAACA8XPxUHGMBTA8X9ecb/glgFwv+FO23zeI+7ucMFhCjZgEEZh
pascal@21553 312 Ctzd4Rf3PFbtQHGLG9BmfmZqdlE/tSmw2LfePzOzWDK0OsQXpPHvFGfZBmL5
pascal@21553 313 f3Zns98NuG1BbTrbWj0OFMypSKfT4kYCurKuRleWlBEth2qUTYFBKjg746pI
pascal@21553 314 2nZaIT/v9vWwbeuqi9fPznLlSPFLLuK22/0lLT09/BDhXgWKO1f9aLKxOObE
pascal@21553 315 EhLuVvO4FksSwaH5qbHpvkle0TyzND82NK+doRVeZgGGbIw0XD2QwV9SnAN/
pascal@21553 316 ACxDxwMAAA==
pascal@21553 317 ====
pascal@21553 318 EOT
pascal@17635 319 unix2dos $mnt/slitaz/boot/he* $mnt/slitaz/boot/opt* \
pascal@17635 320 $mnt/slitaz/boot/README
pascal@17635 321 [ -d $mnt/slitaz/usr/sbin -a ! -x $mnt/slitaz/usr/sbin/mount.posixovl ] &&
pascal@17635 322 cp $(which mount.posixovl) $mnt/slitaz/usr/sbin
pascal@19033 323 if [ "$useposixovl" ] && grep -qs " $mnt " /proc/mounts &&
pascal@17932 324 [ ! -d $mnt/boot/grub ]; then
pascal@17929 325 mkdir -p $mnt/boot/grub
pascal@17930 326 echo -en "\nInstall grub in /boot/grub..."
pascal@17929 327 cp -a /usr/lib/grub/*/* $mnt/boot/grub
pascal@17929 328 cat > $mnt/boot/grub/menu.lst <<EOT
pascal@17929 329 # /boot/grub/menu.lst: GRUB boot loader configuration.
pascal@17929 330
pascal@17929 331 # By default, boot the first entry.
pascal@17929 332 default 0
pascal@17929 333
pascal@17929 334 # Boot automatically after 8 secs.
pascal@17929 335 timeout 8
pascal@17929 336
pascal@17929 337 title Microsoft Windows
pascal@17929 338 chainloader +1
pascal@17929 339
pascal@17929 340 EOT
pascal@17929 341 dev=$(grep " $mnt " /proc/mounts | awk '{ print $1 }')
pascal@17929 342 base=${dev//[0-9]/}
pascal@17929 343 dd if=$base bs=32k count=1 of=$mnt/boot/grub/$(basename $base)
pascal@17929 344 cat > $mnt/boot/grub/uninstall-grub.sh <<EOT
pascal@17929 345 #!/bin/sh
pascal@17929 346
pascal@17929 347 [ -s /boot/grub/$(basename $base) ] &&
pascal@17929 348 dd if=/boot/grub/$(basename $base) of=$base
pascal@17929 349 EOT
pascal@17929 350 grub-install --no-floppy --root-directory=$mnt $base
pascal@17929 351 fi
pascal@17932 352 if [ -s $mnt/boot/grub/menu.lst ] &&
pascal@20158 353 ! grep -q /slitaz/boot/$bzimage $mnt/boot/grub/menu.lst; then
pascal@20158 354 echo -en "\nUpdate /boot/grub/menu.lst..."
pascal@17932 355 cat >> $mnt/boot/grub/menu.lst <<EOT
pascal@17932 356 title SliTaz GNU/Linux $(cat $mnt/slitaz/etc/slitaz-release)
pascal@23890 357 kernel /slitaz/boot/$bzimage root=/dev/null $extraargs autologin
pascal@17932 358 initrd /slitaz/boot/$initrd
pascal@17932 359
pascal@17932 360 EOT
pascal@17932 361 fi
pascal@23820 362 false &&
pascal@23820 363 [ -s $mnt/boot.ini ] && ! grep -qs tazboot $mnt/boot.ini &&
pascal@23820 364 echo "Update boot.ini ..." && unix2dos >> $mnt/boot.ini <<EOT
pascal@23820 365 C:\\slitaz\\boot\\tazboot.exe="SliTaz"
pascal@24139 366 EOT
pascal@23820 367 false &&
pascal@23820 368 grep -qis menuitem $mnt/config.sys && ! grep -qi tazboot $mnt/config.sys &&
pascal@23820 369 echo "Update config.sys ..." &&
pascal@23820 370 sed -i 's/menudefault/menuitem SLITAZ, SliTaz\r\n&/' $mnt/config.sys &&
pascal@23820 371 unix2dos >> $mnt/config.sys <<EOT
pascal@23820 372 [SLITAZ]
pascal@23820 373 install=\\slitaz\\boot\\tazboot.exe
pascal@23820 374 EOT
pascal@23820 375 rm -f $tmp/wait
pascal@17932 376 [ "$useposixovl" ] && umount $mnt/slitaz
pascal@17635 377 return 0
pascal@17635 378 }
pascal@17635 379
pascal@17635 380 windev()
pascal@17635 381 {
pascal@17924 382 if [ -b "$1" ]; then
pascal@17924 383 device=$1
pascal@17928 384 elif [ "$1" ]; then
pascal@17932 385 echo "Invalid Linux/Windows partition"
pascal@17928 386 return 1
pascal@17924 387 else
pascal@17932 388 DEV="$(blkid | grep -iE "(msdos|vfat|ntfs|ext[234]|xfs|btrfs)" | sed 's/:.*//;s|/dev/||')"
pascal@17924 389 [ "$DEV" ] || return
pascal@17635 390 cat > /tmp/dialog$$ <<EOT
pascal@20771 391 $DIALOG --clear --title " Select your Linux/Windows partition " \
pascal@17932 392 --menu "\nPlease select the Linux/Windows partition according to its known size.
pascal@20771 393 The data will be kept untouched.\n" 17 70 8 \
pascal@17635 394 $(for i in $DEV ; do
pascal@17635 395 label="$(blkid | sed "/$i:/!d;s/.*://;s/[^ ]*UUID=[^ ]* //g;s/LABEL=//")"
pascal@17635 396 echo -n "/dev/$i \"$(($(cat /sys/block/*/$i/size)/2048))MB $label\" "
pascal@17635 397 done)
pascal@17635 398 EOT
pascal@17924 399 exec 3>&1
pascal@17924 400 [ $? -eq 0 ] || return
pascal@17924 401 device=$(. /tmp/dialog$$ 2>&1 1>&3)
pascal@17924 402 exec 3>&-
pascal@17924 403 rm -f /tmp/dialog$$
pascal@17924 404 fi
pascal@17635 405 mnt=/tmp/mnt$$
pascal@17635 406 mkdir -p $mnt && mount $device $mnt
pascal@17635 407 }
pascal@17635 408
pascal@17635 409 extra_packages()
pascal@17635 410 {
pascal@17635 411 packages_list=
pascal@17635 412 packages_dir=
pascal@23820 413 [ $0 = /init.exe ] && return
pascal@20771 414 $DIALOG --clear --title " Extra packages " \
pascal@17635 415 --defaultno --yesno \
pascal@20771 416 "Do you want to add extra packages ?" 7 70
pascal@17635 417 [ $? -eq 0 ] || return
pascal@17635 418 [ -s /var/lib/tazpkg/packages.txt ] || tazpkg recharge
pascal@18240 419 if [ -s $media/boot/vmlinuz-$(uname -r) ]; then
pascal@17635 420 cat > /tmp/dialog$$ <<EOT
pascal@20771 421 $DIALOG --clear --title " Select the packages " \
pascal@17635 422 --separate-output \
pascal@17635 423 --cancel-label "Skip" \
pascal@17635 424 --checklist "Please select the packages you want to install. Try with the first letter." \
pascal@18240 425 0 0 0 \\
pascal@17635 426 EOT
pascal@17635 427 awk -F\| '{ printf "%s \"%s\" off ",$1,$3 }' \
pascal@17635 428 /var/lib/tazpkg/packages.desc >> /tmp/dialog$$
pascal@17635 429 sh /tmp/dialog$$ 2> /tmp/dialog.out$$
pascal@17635 430 [ $? -eq 0 ] && packages_list="$(cat /tmp/dialog.out$$)"
pascal@17635 431 fi
pascal@17635 432 cat > /tmp/dialog$$ <<EOT
pascal@17635 433 $DIALOG --clear \
paul@17671 434 --title "Please select the directory with every custom package to install." \
pascal@20771 435 --cancel-label "Skip" --dselect $PWD 13 78
pascal@17635 436 EOT
pascal@17635 437 sh /tmp/dialog$$ 2> /tmp/dialog.out$$
pascal@17635 438 [ $? -eq 0 ] && packages_dir="$(cat /tmp/dialog.out$$)"
pascal@17635 439 rm -f /tmp/dialog$$ /tmp/dialog.out$$
pascal@17635 440 }
pascal@17635 441
pascal@17635 442 _install()
pascal@17635 443 {
pascal@17635 444 extra_packages
pascal@20771 445 $DIALOG --clear --title " SliTaz UMSDOS way installation " \
pascal@17635 446 --yes-label "Install" --yesno \
pascal@17635 447 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
paul@17935 448 Linux/DOS/Windows partition. You can see your files from /mnt/dos.\n\n
pascal@17635 449 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
pascal@17635 450 To uninstall SliTaz, you have only to remove this directory.
pascal@17635 451 The file \\boot.ini or \\config.sys may be modified too.\n\n
pascal@20771 452 SliTaz may run slowly on the 'UMSDOS way' installation due to the
pascal@17635 453 posixovl filesystem. The 'TAZUSB way' installation runs faster.\n\n
pascal@17635 454 To do a traditional installation with disk partitioning,
pascal@20771 455 start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
pascal@17635 456 [ $? -eq 0 ] || return
pascal@17635 457 doinstall
pascal@24023 458 [ $0 = /init.exe ] || return 0
pascal@24023 459 [ -x $mnt/slitaz/sbin/init ] || return 0
pascal@23820 460 umount -d $media/cdrom
pascal@23820 461 umount_proc
pascal@23820 462 exec chroot $mnt/slitaz /sbin/init
pascal@17635 463 }
pascal@17635 464
pascal@17635 465 readtazbootconf()
pascal@17635 466 {
pascal@23813 467 kernel="$(sed '/^image=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)"
pascal@17635 468 initrd="$(sed '/^initrd=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)"
pascal@23813 469 cmdline="$(sed '/^image=/d;/^initrd=/d' $mnt/slitaz/boot/tazboot.cmd)"
pascal@17635 470 }
pascal@17635 471
pascal@17635 472 bootinstalled()
pascal@17635 473 {
pascal@17635 474 [ "$(which kexec)" ] || return
pascal@17635 475 [ -x $mnt/slitaz$1 ] || return
pascal@17635 476 [ -s $mnt/slitaz/boot/tazboot.cmd ] || return
pascal@17635 477 readtazbootconf
pascal@17659 478 kexec -l $kernel --initrd $initrd --command-line "$cmdline" || return
pascal@17635 479 umount $mnt
pascal@17635 480 rm -rf $mnt
pascal@18240 481 quit "kexec -e"
pascal@17635 482 }
pascal@17635 483
pascal@17635 484 mkzip()
pascal@17635 485 {
pascal@17635 486 device=
pascal@17635 487 packages_list=
pascal@17635 488 packages_dir=
pascal@19029 489 mnt=/tmp/mkzipmnt$$
pascal@17635 490 mkdir -p $mnt
pascal@17930 491 $1 $2 || return
pascal@18140 492 for i in bootlace.com grubinst.exe grldr ; do
pascal@18140 493 wget -O $mnt/slitaz/boot/$i http://mirror.slitaz.org/boot/$i
pascal@18140 494 done
pascal@17635 495 readtazbootconf
pascal@17636 496 cat > $mnt/slitaz/boot/menu.lst <<EOT
pascal@17635 497 title SliTaz
pascal@17635 498 kernel $kernel $cmdline
pascal@17635 499 initrd $initrd
pascal@17635 500
pascal@17635 501 EOT
pascal@17635 502 while read file title; do
pascal@17637 503 file=$(ls $mnt/slitaz/boot/*$file* 2> /dev/null)
pascal@17637 504 [ -s "$file" ] && cat >> $mnt/slitaz/boot/menu.lst <<EOT
pascal@17635 505 title $title
pascal@17637 506 kernel ${file#$mnt}
pascal@17635 507
pascal@17635 508 EOT
pascal@17635 509 done <<EOT
pascal@17635 510 memtest MemTest
pascal@23946 511 plop USB boot
pascal@17635 512 pxe Web boot
pascal@17635 513 EOT
pascal@17636 514 unix2dos $mnt/slitaz/boot/menu.lst
pascal@17636 515 unix2dos > $mnt/slitaz/boot/install.txt <<EOT
pascal@17659 516 For DOS users (real mode only):
pascal@17659 517
pascal@17659 518 Start SliTaz with \\slitaz\\boot\\tazboot.exe
pascal@17659 519
pascal@17659 520
pascal@17635 521 For NT/2000/XP users:
pascal@17635 522
pascal@17635 523 1- Move the files grldr and menu.lst into the root directory
pascal@17635 524
pascal@17635 525 C:\\> copy \\slitaz\\boot\\grldr \\
pascal@17635 526 C:\\> copy \\slitaz\\boot\\menu.lst \\
pascal@17635 527
pascal@17635 528 2- Remove boot.ini attributes
pascal@17635 529
pascal@17635 530 C:\\> attrib -r -h -s boot.ini
pascal@17635 531
pascal@17635 532 3- Append the following line to boot.init
pascal@17635 533
pascal@17635 534 C:\\grldr="slitaz"
pascal@17635 535
pascal@17635 536 4- Restore boot.ini attributes
pascal@17635 537
pascal@17635 538 C:\\> attrib +r +h +s boot.ini
pascal@17635 539
pascal@17635 540 See http://diddy.boot-land.net/grub4dos/files/README_GRUB4DOS.txt
pascal@18140 541 and http://xpt.sourceforge.net/techdocs/nix/disk/boot/boot07-GrubForDosInfo/ar01s03.html
pascal@17635 542 EOT
pascal@18140 543 ( cd $mnt ; echo 'See \slitaz\boot\install.txt to launch SliTaz.' | \
pascal@18670 544 zip -zr9 $(basename "$ISO" .iso).zip slitaz )
pascal@19033 545 [ "$(which advzip)" ] &&
pascal@19033 546 echo "Recompressing $(basename "$ISO" .iso).zip ..." &&
pascal@19033 547 advzip -z4 $mnt/*.zip
pascal@17635 548 mv $mnt/*.zip .
pascal@19029 549 du -h $PWD/$(basename "$ISO" .iso).zip
pascal@17636 550 umount $mnt
pascal@17636 551 rm -rf $mnt
pascal@17635 552 }
pascal@17635 553
pascal@17635 554 install()
pascal@17635 555 {
pascal@17924 556 windev $1 || return
pascal@17635 557 packages_list=
pascal@17635 558 packages_dir=
pascal@17924 559 if [ "$1" ]; then
pascal@17924 560 doinstall
pascal@17924 561 else
pascal@17924 562 _install && bootinstalled /sbin/init
pascal@17924 563 fi
pascal@17635 564 umount $mnt
pascal@17635 565 rm -rf $mnt
pascal@17635 566 }
pascal@17635 567
pascal@17635 568 inst2zip()
pascal@17635 569 {
pascal@17924 570 if [ "$1" ]; then
pascal@17930 571 mkzip doinstall
pascal@17924 572 else
pascal@17924 573 mkzip _install
pascal@17924 574 fi
pascal@17635 575 }
pascal@17635 576
pascal@17635 577 _installtaz()
pascal@17635 578 {
pascal@20771 579 $DIALOG --clear --title " SliTaz TAZUSB way installation " \
pascal@17635 580 --yes-label "Install" --yesno \
pascal@17635 581 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
paul@17935 582 Linux/DOS/Windows partition. You can see your files from /mnt/dos.\n\n
pascal@17635 583 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
pascal@17635 584 To uninstall SliTaz, you have only to remove this directory.
pascal@17635 585 The file \\boot.ini or \\config.sys may be modified too.\n\n
pascal@17635 586 The filesystem is loaded entirely into memory upon boot to
paul@19451 587 increase responsiveness. Only /home lands on the hard disk.\n\n
pascal@17635 588 To do a traditional installation with disk partitioning,
pascal@20771 589 start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
pascal@17635 590 [ $? -eq 0 ] || return
pascal@23820 591 doinstall tazusblike || return
pascal@23820 592 [ $0 = /init.exe ] || return
pascal@23820 593 dotwait
pascal@23820 594 if [ -d /media/cdrom/fs ]; then
pascal@23820 595 cp -a /media/cdrom/fs/. /
pascal@23820 596 else
pascal@23820 597 for i in $(ls_r /media/cdrom/boot/rootfs*); do
pascal@23820 598 ${uncpio:-uncipo} $i
pascal@23820 599 done
pascal@23820 600 fi
pascal@23820 601 cp /tmp/fs/etc/* /etc 2>/dev/null
pascal@23820 602 echo "/home=$(getuuid)/slitaz" > /cmdline
pascal@23820 603 rm -f /tmp/wait
pascal@23820 604 [ -x /init1 ] || return
pascal@23820 605 umount -d /media/cdrom
pascal@23820 606 umount /mnt/slitaz
pascal@23820 607 rm -f /dev/cdrom
pascal@23820 608 umount /mnt
pascal@23820 609 mkdir /mnt/dos
pascal@23820 610 umount_proc
pascal@23820 611 exec /init1
pascal@17635 612 }
pascal@17635 613
pascal@17635 614 installtaz()
pascal@17635 615 {
pascal@17924 616 windev $1 || return
pascal@17635 617 packages_list=
pascal@17635 618 packages_dir=
pascal@17924 619 if [ "$1" ]; then
pascal@17924 620 doinstall tazusblike
pascal@17924 621 else
pascal@24023 622 _installtaz && bootinstalled /boot/bzImage
pascal@17924 623 fi
pascal@17635 624 umount $mnt
pascal@17635 625 rm -rf $mnt
pascal@17635 626 }
pascal@17635 627
pascal@17635 628 insttaz2zip()
pascal@17635 629 {
pascal@17924 630 if [ "$1" ]; then
pascal@17930 631 mkzip doinstall tazusblike
pascal@17924 632 else
pascal@17924 633 mkzip _installtaz
pascal@17924 634 fi
pascal@17635 635 }
pascal@17635 636
pascal@17635 637 bootiso()
pascal@17635 638 {
pascal@18799 639 cd /tmp
pascal@18240 640 for i in $(ls_r $media/boot/rootfs*gz); do
pascal@23946 641 i=$(maybe64 $i)
pascal@17635 642 cat $i
pascal@23947 643 n=$((4 - ($(size $i) % 4)))
pascal@17635 644 [ $n -eq 4 ] || dd if=/dev/zero bs=1 count=$n
pascal@18799 645 done > initrd$$
pascal@23890 646 cmdline="root=/dev/null autologin lang=$LANG"
pascal@18799 647 [ -s /etc/keymap.conf ] && cmdline="$cmdline kmap=$(cat /etc/keymap.conf)"
pascal@18799 648 [ -s /etc/TZ ] && cmdline="$cmdline tz=$(cat /etc/TZ)"
pascal@18799 649 rm -f cmdline initrd 2> /dev/null
pascal@18799 650 getcustomconf kexec >/dev/null
pascal@18799 651 [ -s cmdline ] && cmdline="$cmdline $(cat cmdline)" && rm cmdline
pascal@18799 652 [ -s initrd ] && cat initrd >> initrd$$ && rm initrd
pascal@23946 653 kernel=$(maybe64 $media/boot/bzImage)
pascal@17635 654 . /etc/locale.conf
pascal@18799 655 kexec -l $kernel --initrd initrd$$ --command-line "$cmdline" &&
pascal@18799 656 rm -f initrd$$
pascal@18240 657 quit "kexec -e"
pascal@17635 658 }
pascal@17635 659
pascal@17635 660 tazboot()
pascal@17635 661 {
pascal@17928 662 if [ -z "$1" ]; then
pascal@20771 663 $DIALOG --clear --title " SliTaz bootloader for DOS " \
pascal@17928 664 --yes-label "Install" --yesno \
pascal@17635 665 "\nThe file TAZBOOT.EXE will be created in the top directory. It supports
pascal@23810 666 any linux kernel, multiple initramfs and a kernel command line.\n\n
pascal@23810 667 Usage: tazboot.exe [[@commands]|[image=<bzimage>]
pascal@23810 668 [initrd=<rootfs>[,<rootfs2>...]] cmdline args ...]\n\n
pascal@23810 669 Defaults: tazboot @tazboot.cmd or tazboot image=bzImage auto\n\n\
pascal@17635 670 Examples for tazboot.cmd:\n\n\
pascal@23810 671 image=boot/bzImage\n\
pascal@17635 672 initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\
pascal@23890 673 root=/dev/null autologin\n\n\
pascal@23810 674 image=\\slitaz\\vmlinuz root=/dev/sda5 ro\n" 0 0
pascal@17928 675 [ $? -eq 0 ] || return
pascal@17928 676 fi
pascal@17635 677 gettazboot tazboot.exe
pascal@19029 678 du -h $PWD/tazboot.exe
pascal@17635 679 }
pascal@17635 680
pascal@17635 681 md5()
pascal@17635 682 {
pascal@17635 683 dotwait "Checking files"
pascal@19432 684 ( cd $media ; ${md5sum:-md5sum -c md5sum*} 2>&1 | sort ) > /tmp/data
pascal@17928 685 unset md5sum
pascal@17635 686 rm -f /tmp/wait
pascal@17928 687 if [ "$1" ]; then
pascal@17924 688 cat /tmp/data
pascal@17924 689 else
pascal@20771 690 $DIALOG --clear --title " Checked files " \
pascal@18240 691 --textbox /tmp/data 0 0
pascal@17924 692 fi
pascal@17635 693 rm -f /tmp/data
pascal@17635 694 }
pascal@17635 695
pascal@24004 696 filepos()
pascal@24004 697 {
pascal@24004 698 dotwait "locate files"
pascal@24004 699 ( cd $media; find * -type f | while read f; do
pascal@25179 700 printf "%8d %s\n" $(busybox stat -m "$f" | sed q) "$f"
pascal@24004 701 done | sort -n ) > /tmp/data
pascal@24004 702 rm -f /tmp/wait
pascal@24004 703 if [ "$1" ]; then
pascal@24004 704 cat /tmp/data
pascal@24004 705 else
pascal@24004 706 $DIALOG --clear --title " File start sector " \
pascal@24004 707 --textbox /tmp/data 0 0
pascal@24004 708 fi
pascal@24004 709 rm -f /tmp/data
pascal@24004 710 }
pascal@24004 711
pascal@17635 712 gotcdfile()
pascal@17635 713 {
pascal@18240 714 for i in "$media/$1" "$media/*/$1" "$media/*/isolinux/$1" ; do
pascal@17635 715 file=$(ls $i 2> /dev/null | sed q)
pascal@17635 716 [ -s "$file" ] && break
pascal@17635 717 done
pascal@17635 718 }
pascal@17635 719
pascal@17635 720 sha()
pascal@17635 721 {
pascal@17635 722 gotcdfile 'sha*sum*'
pascal@17635 723 sha=$(basename $file)
pascal@18240 724 md5sum="${sha%sum*}sum -c ${file#$media/}"
pascal@17928 725 md5 $@
pascal@17635 726 }
pascal@17635 727
pascal@17635 728 readme()
pascal@17635 729 {
pascal@17635 730 gotcdfile 'README*'
pascal@17924 731 if [ "$1" ]; then
pascal@17924 732 cat $file
pascal@17924 733 else
pascal@20771 734 $DIALOG --clear --title " Readme " --textbox $file 0 0
pascal@17924 735 fi
pascal@17635 736 }
pascal@17635 737
pascal@17635 738 bzimage()
pascal@17635 739 {
pascal@17928 740 if [ -z "$1" ]; then
pascal@20771 741 $DIALOG --clear --title " Create linux.exe ? " \
pascal@17924 742 --yes-label "Install" --yesno \
pascal@17635 743 "\nLinux.exe launches the linux kernel under DOS (in real mode only).
pascal@17635 744 The cmdline arguments are supported except initrd=,
pascal@17635 745 vga= (you can try 'rdev -v') and mem= (partially).
pascal@20771 746 \nExample:\nC:\\> linux.exe root=/dev/hda2 ro panic=60\n" 12 70
pascal@17924 747 [ $? -eq 0 ] || return
pascal@17924 748 fi
pascal@23946 749 cp $(maybe64 $media/boot/bzImage) linux.exe
pascal@19029 750 du -h $PWD/linux.exe
pascal@17635 751 }
pascal@17635 752
pascal@17635 753 memtest()
pascal@17635 754 {
pascal@17924 755 if [ -z "$1" ]; then
pascal@20771 756 $DIALOG --clear --title " Create memtest.exe ? " \
pascal@17924 757 --yes-label "Install" --yesno \
pascal@17635 758 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
pascal@17635 759 computers. BIOS based memory tests are a quick, cursory check and often
pascal@20771 760 miss many of the failures that are detected by Memtest86.\n" 0 0
pascal@17924 761 [ $? -eq 0 ] || return
pascal@17924 762 fi
pascal@17924 763 gotcdfile 'memtest*' && cp $file memtest.exe
pascal@19029 764 du -h $PWD/memtest.exe
pascal@17635 765 }
pascal@17635 766
pascal@17635 767 mkfat12()
pascal@17635 768 {
pascal@17635 769 [ $(($(get 0 $1) - 0x5A4D)) -eq 0 ] || return
pascal@17635 770 J=$(($(get 3 $1 1) + 0x02))
pascal@17635 771 R=$((1 + $(get 497 $1 1) + 1 + ($(get 500 $1)-1)/32))
pascal@17635 772 [ $R -lt 2500 ] || return
pascal@17635 773 [ $((($(get 500 $1)-1) & 31)) -lt 30 ] &&
pascal@24177 774 ddq if=$file bs=32 count=1 seek=$((R*16 - 1)) of=/dev/fd0
pascal@17635 775 G="18 0 2 0 0 0 0 0"
pascal@17635 776 [ $J -gt 25 ] || G=""
pascal@17635 777 F=0
pascal@17635 778 for i in 1 2 3; do
pascal@24177 779 F=$((((2880-R-F-F)*3+1023)/1024))
pascal@17635 780 done
pascal@17635 781 bytes2bin 0xEB $J 0x90 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 \
pascal@24177 782 0 2 2 $((R%256)) $((R/256)) 2 64 0 64 11 0xF0 $F 0 \
pascal@17635 783 $G | ddq bs=1 of=/dev/fd0
pascal@24177 784 ddq if=/dev/zero bs=512 count=$((4+F+F)) seek=$R of=/dev/fd0
pascal@24177 785 for i in $R $((R+F)) ; do
pascal@17635 786 bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0
pascal@17635 787 done
pascal@17635 788 echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0
pascal@17635 789 }
pascal@17635 790
pascal@17635 791 mkfloppy()
pascal@17635 792 {
pascal@21542 793 dotwait "Create a $(basename $1 .exe) boot floppy"
pascal@17635 794 ddq if=$1 of=/dev/fd0
pascal@17635 795 mkfat12 $1
pascal@17635 796 rm -f /tmp/wait
pascal@17635 797 }
pascal@17635 798
pascal@17635 799 fdmemtest()
pascal@17635 800 {
pascal@17924 801 if [ -z "$1" ]; then
pascal@20771 802 $DIALOG --clear --title " Create a Memtest86 boot floppy " \
pascal@17924 803 --yes-label "Create floppy" --yesno \
pascal@17635 804 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
pascal@17635 805 computers. BIOS based memory tests are a quick, cursory check and often
pascal@17635 806 miss many of the failures that are detected by Memtest86.\n\n
pascal@20771 807 Please insert a blank disk in floppy drive.\n" 0 0
pascal@17924 808 [ $? -eq 0 ] || return
pascal@17924 809 fi
pascal@17924 810 gotcdfile 'memtest*' && mkfloppy $file
pascal@17635 811 }
pascal@17635 812
pascal@17635 813 pxe()
pascal@17635 814 {
pascal@20762 815 gotcdfile '?pxe*'
pascal@17928 816 if [ -z "$1" ]; then
pascal@21542 817 $DIALOG --clear --title " Create $(basename $file .exe).exe ? " \
pascal@17928 818 --yes-label "Install" --yesno \
pascal@17635 819 "\nBoot your operating system from the internet and enjoy a full system
pascal@17635 820 working entirely in RAM with speed and stability in mind. The Linux Kernel
pascal@17635 821 and the complete SliTaz compressed root filesystem will be loaded into RAM
pascal@20771 822 from the Web using PXE and HTTP protocols.\n" 0 0
pascal@17928 823 [ $? -eq 0 ] || return
pascal@17928 824 fi
pascal@21542 825 cp $file $(basename $file .exe).exe
pascal@21542 826 du -h $PWD/$(basename $file .exe).exe
pascal@17635 827 }
pascal@17635 828
pascal@17635 829 fdpxe()
pascal@17635 830 {
pascal@17924 831 if [ -z "$1" ]; then
pascal@20771 832 $DIALOG --clear --title " Create a SliTaz Web boot floppy " \
pascal@17924 833 --yes-label "Create floppy" --yesno \
pascal@17635 834 "\nBoot your operating system from the internet and enjoy a full system
pascal@17635 835 working entirely in RAM with speed and stability in mind. The Linux Kernel
pascal@17635 836 and the complete SliTaz compressed root filesystem will be loaded into RAM
pascal@17635 837 from the Web using PXE and HTTP protocols.\n\n
pascal@20771 838 Please insert a blank disk in floppy drive.\n" 0 0
pascal@17924 839 [ $? -eq 0 ] || return
pascal@17924 840 fi
pascal@20762 841 gotcdfile '?pxe*' && mkfloppy $file
pascal@17924 842 }
pascal@17924 843
pascal@23946 844 plop()
pascal@23946 845 {
pascal@24011 846 gotcdfile 'plop*'
pascal@23946 847 if [ -z "$1" ]; then
pascal@23946 848 $DIALOG --clear --title " Create $(basename $file .exe).exe ? " \
pascal@23946 849 --yes-label "Install" --yesno \
pascal@23946 850 "\nBoot your operating system from a USB disk without BIOS support.\n" 0 0
pascal@23946 851 [ $? -eq 0 ] || return
pascal@23946 852 fi
pascal@23946 853 cp $file $(basename $file .exe).exe
pascal@23946 854 du -h $PWD/$(basename $file .exe).exe
pascal@23946 855 }
pascal@23946 856
pascal@23946 857 fdplop()
pascal@23946 858 {
pascal@23946 859 if [ -z "$1" ]; then
pascal@23946 860 $DIALOG --clear --title " Create a Plop boot floppy " \
pascal@23946 861 --yes-label "Create floppy" --yesno \
pascal@23946 862 "\nBoot your operating system from a USB disk without BIOS support.\n\n
pascal@23946 863 Please insert a blank disk in floppy drive.\n" 0 0
pascal@23946 864 [ $? -eq 0 ] || return
pascal@23946 865 fi
pascal@24011 866 gotcdfile 'plop*' && mkfloppy $file
pascal@23946 867 }
pascal@23946 868
pascal@17924 869 menuitem()
pascal@17924 870 {
pascal@17924 871 [ "$3" ] && shift
pascal@17924 872 echo -en "\"$1\" \"$2\""
pascal@17635 873 }
pascal@17635 874
pascal@17635 875 gotposixovl()
pascal@17635 876 {
pascal@19425 877 mount.posixovl 2>&1 | grep -qi usage && gotcdfile 'rootfs*.gz' &&
pascal@19425 878 menuitem "$@"
pascal@17635 879 }
pascal@17635 880
pascal@17635 881 gotposixovlzip()
pascal@17635 882 {
pascal@17635 883 [ "$(which zip)" ] && gotposixovl "$1" "$2"
pascal@17635 884 }
pascal@17635 885
pascal@23820 886 noinit()
pascal@23820 887 {
pascal@23820 888 [ $0 = /init.exe ] || menuitem "$@"
pascal@23820 889 }
pascal@23820 890
pascal@23820 891 initx()
pascal@23820 892 {
pascal@23820 893 [ $0 = /init.exe ] && menuitem "$@"
pascal@23820 894 }
pascal@23820 895
pascal@17635 896 xfile()
pascal@17635 897 {
pascal@24164 898 for i in $1; do
pascal@24164 899 [ "$(which $i)" ] && menuitem "$@" && break
pascal@24164 900 done
pascal@17635 901 }
pascal@17635 902
pascal@23820 903 initxfile()
pascal@23820 904 {
pascal@23820 905 [ $0 = /init.exe ] && xfile "$@"
pascal@23820 906 }
pascal@23820 907
pascal@17635 908 cdfile()
pascal@17635 909 {
pascal@17924 910 gotcdfile "$1" && menuitem "$@"
pascal@17635 911 }
pascal@17635 912
pascal@19425 913 gottazusb()
pascal@19425 914 {
pascal@19425 915 gotcdfile 'rootfs*.gz' && xfile tazusb "$@"
pascal@19425 916 }
pascal@19425 917
pascal@17659 918 isbzImage()
pascal@17659 919 {
pascal@17659 920 [ $(get 514 $file 4) -eq 1400005704 ] &&
pascal@17659 921 [ $(($(get 529 $file 1) & 1)) -eq 1 ]
pascal@17659 922 }
pascal@17659 923
pascal@17635 924 cdfilex()
pascal@17635 925 {
pascal@17924 926 gotcdfile "$1" && [ "$(which kexec)" ] && isbzImage && menuitem "$@"
pascal@17635 927 }
pascal@17635 928
pascal@17635 929 cdfilef()
pascal@17635 930 {
pascal@17635 931 [ -e /sys/block/fd0 ] && cdfile "$@"
pascal@17635 932 }
pascal@17635 933
pascal@17635 934 cdexe()
pascal@17635 935 {
pascal@17635 936 gotcdfile "$1" &&
pascal@17635 937 [ $(get 0 $file 2>/dev/null || echo 0) -eq 23117 ] &&
pascal@23970 938 [ $(get 128 $file 2>/dev/null || echo 0) -ne 10 ] &&
pascal@17924 939 menuitem "$@"
pascal@17635 940 }
pascal@17635 941
pascal@17635 942 misspkg()
pascal@17635 943 {
pascal@19029 944 for i in zip kexec-tools posixovl cdrkit cdrkit-isoinfo ; do
pascal@17635 945 [ -d /var/lib/tazpkg/installed/$i/ ] && continue
pascal@17924 946 [ "$1" != "install" ] && menuitem "$@" && return
pascal@17635 947 tazpkg get-install $i
pascal@17635 948 done
pascal@17635 949 }
pascal@17635 950
pascal@23820 951 noinitmisspkg()
pascal@23820 952 {
pascal@23820 953 [ $0 = /init.exe ] || misspkg "$@"
pascal@23820 954 }
pascal@23820 955
pascal@17635 956 missing()
pascal@17635 957 {
pascal@17635 958 misspkg install
pascal@17635 959 }
pascal@17635 960
pascal@17635 961 ishybrid()
pascal@17635 962 {
pascal@18670 963 [ $(get 510 "$ISO") -eq 43605 ] || return
pascal@18670 964 C=$((2048*$(get $(((17*2048) + 71)) "$ISO" 4)))
pascal@18670 965 [ $(get $C "$ISO" 4) -eq 1 ] || return
pascal@24177 966 [ $(get $((C+30)) "$ISO" 4) -eq $((0x88AA55)) ] || return
pascal@24177 967 C=$((2048*$(get $((C+40)) "$ISO" 4)))
pascal@24177 968 [ $(get $((C+64)) "$ISO" 4) -eq 1886961915 ] && menuitem "$@"
pascal@17635 969 }
pascal@17635 970
pascal@17635 971 isiso()
pascal@17635 972 {
pascal@18670 973 [ $(get 32769 "$ISO" 4) -eq 808469571 ] && menuitem "$@"
pascal@18140 974 }
pascal@18140 975
pascal@18034 976 burnable()
pascal@18034 977 {
pascal@19510 978 [ "$(sed '/Can wr.*1$/!d' /proc/sys/dev/cdrom/info 2> /dev/null)" ] &&
pascal@19510 979 menuitem "$@"
pascal@18034 980 }
pascal@18034 981
pascal@18034 982 blankable()
pascal@18034 983 {
pascal@19510 984 [ "$(sed '/Can wr.*RW.*1$/!d' /proc/sys/dev/cdrom/info 2> /dev/null)" ] &&
pascal@19510 985 menuitem "$@"
pascal@18034 986 }
pascal@18034 987
pascal@18034 988 burniso()
pascal@18034 989 {
pascal@18034 990 wodim -v speed=$(fgrep "drive speed" /proc/sys/dev/cdrom/info | cut -f3) \
pascal@18034 991 -eject -multi "$ISO"
pascal@18034 992 }
pascal@18034 993
pascal@18034 994 blankcd()
pascal@18034 995 {
pascal@18034 996 wodim -v -blank=fast
pascal@17635 997 }
pascal@17635 998
pascal@18675 999 customsector()
pascal@18675 1000 {
pascal@19324 1001 local c=$(echo $(get 32848 "$ISO" 4))
pascal@24177 1002 hascustomconf $((c+16)) && echo $((c+16)) || echo $c
pascal@18675 1003 }
pascal@18675 1004
pascal@23831 1005 xhascustomconf=hascustomconf
pascal@18675 1006 hascustomconf()
pascal@18675 1007 {
pascal@19324 1008 [ "$(ddq bs=2k skip=${1:-$(customsector)} if="$ISO" | ddq bs=1 count=6)" \
pascal@20892 1009 = "#!boot" ]
pascal@18675 1010 }
pascal@18675 1011
pascal@18675 1012 gotcustomconf()
pascal@18675 1013 {
pascal@18675 1014 hascustomconf && menuitem "$@"
pascal@18675 1015 }
pascal@18675 1016
pascal@19425 1017 hasflavor()
pascal@19425 1018 {
pascal@23946 1019 [ -x /usr/bin/tazlito ] && [ -s $(maybe64 $media/boot/bzImage) ] && menuitem "$@"
pascal@19425 1020 }
pascal@19425 1021
pascal@17635 1022 gotisomd5()
pascal@17635 1023 {
pascal@17635 1024 [ "$(which md5sum 2> /dev/null)" ] &&
pascal@18670 1025 [ $(get 0 "$ISO") -eq 23117 ] &&
pascal@18670 1026 [ $(get 18 "$ISO") -ne 0 ] && menuitem "$@"
pascal@17635 1027 }
pascal@17635 1028
pascal@23970 1029 read_return()
pascal@23970 1030 {
pascal@23970 1031 echo -e "\rPress RETURN to continue."
pascal@23970 1032 read n
pascal@23970 1033 }
pascal@23970 1034
pascal@18675 1035 getcustomconf()
pascal@18675 1036 {
pascal@18675 1037 ddq bs=2k skip=$(customsector) if="$ISO" | while read line; do
pascal@18675 1038 case "$line" in
pascal@18675 1039 \#!boot*) ;;
pascal@18675 1040 append=*) echo ${line#append=} > cmdline && ls -l $PWD/cmdline ;;
pascal@18675 1041 initrd:*) cnt=${line#initrd:}
pascal@24177 1042 { ddq bs=512 count=$((cnt / 512));
pascal@24177 1043 ddq bs=1 count=$((cnt % 512)); } > initrd &&
pascal@18675 1044 ls -l $PWD/initrd
pascal@18675 1045 break ;;
pascal@20771 1046 *) break ;;
pascal@18675 1047 esac
pascal@18675 1048 done
pascal@23970 1049 [ "$1" ] || read_return
pascal@18675 1050 }
pascal@18675 1051
pascal@23956 1052 setcustomconf()
pascal@23956 1053 {
pascal@23970 1054 msg="$(stat -c '%12s %.16z %n' $PWD/cmdline $PWD/initrd 2>/dev/null|sed 'N;s|\n|\\n|')"
pascal@23970 1055 [ "$msg" ] || msg="These files are not found. Your configuration will be cleared.\\n"
pascal@23956 1056 msg="\nUpdate the custom configuration with the files cmdline and initrd\n
pascal@23970 1057 in the current directory $PWD. Any missing file is assumed empty.\n\n$msg"
pascal@23956 1058 [ "$1" ] && echo -e "$msg" ||
pascal@23956 1059 $DIALOG --clear --title " Update custom configuration " \
pascal@23956 1060 --yes-label "Update config" --yesno "$msg\n
pascal@23956 1061 \nAre you sure to do the update ?\n" 0 0
pascal@23956 1062 [ $? -eq 0 ] || return
pascal@23956 1063 ddq bs=2k seek=$(customsector) of="$ISO" count=0
pascal@23956 1064 if [ "$(ls $PWD/cmdline $PWD/inird 2> /dev/null)" ]; then
pascal@23956 1065 rm -f /tmp/custom$$ 2>/dev/null
pascal@23956 1066 [ -s $PWD/cmdline ] &&
pascal@23956 1067 echo "append=$(cat $PWD/cmdline)" >>/tmp/custom$$
pascal@23956 1068 [ -s $PWD/initrd ] &&
pascal@23970 1069 echo "initrd:$(size $PWD/initrd)" >>/tmp/custom$$ &&
pascal@23956 1070 cat $PWD/initrd >>/tmp/custom$$
pascal@23956 1071 echo "#!boot $(md5sum /tmp/custom$$ | sed 's| .*||')" >>"$ISO"
pascal@23956 1072 cat /tmp/custom$$ >>"$ISO"
pascal@23970 1073 dd if=/dev/zero bs=4k count=1 >>"$ISO"
pascal@23956 1074 rm -f /tmp/custom$$
pascal@23956 1075 fi
pascal@23956 1076 }
pascal@23956 1077
pascal@17635 1078 isomd5()
pascal@17635 1079 {
pascal@17635 1080 dotwait "Checking iso image"
pascal@18670 1081 [ "$(ddq if="$ISO" bs=2k skip=16 \
pascal@20892 1082 count=$(($(get 32848 "$ISO" 4)-16)) | md5sum)" = \
pascal@18670 1083 "$(ddq if="$ISO" bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \
pascal@17635 1084 sed 's/ //g') -" ] && echo "OK" || echo "ERROR"
pascal@17635 1085 echo -en "\rChecking iso hybrid boot..."
pascal@18671 1086 n=$(($(get 2 "$ISO")-1+($(get 4 "$ISO")-1)*512))
pascal@17635 1087 if [ $n -lt 40000 -a $n -gt 32768 ]; then
pascal@18670 1088 s=$(get 0 "$ISO" 2 $n | awk '{ i+= $0 } END { print i }')
pascal@24177 1089 [ $(((1+s+$(get $((n+1)) "$ISO" 1)) % 65536)) -eq 0 ] &&
pascal@17635 1090 echo "OK" || echo "ERROR"
pascal@17635 1091 fi
pascal@18675 1092 if hascustomconf; then
pascal@18672 1093 echo -en "\rChecking iso custom config..."
pascal@18672 1094 TMP=/tmp/$(basename $0)$$md5
pascal@18675 1095 md5="$(ddq bs=2k skip=$(customsector) if="$ISO" | while read line; do
pascal@18670 1096 case "$line" in
pascal@18672 1097 \#!boot*) echo ${line#*boot } > $TMP ;;
pascal@18670 1098 append=*) echo $line ;;
pascal@18670 1099 initrd:*) echo $line
pascal@18675 1100 cnt=${line#initrd:}
pascal@18675 1101 ddq bs=512 count=$((cnt / 512))
pascal@18675 1102 ddq bs=1 count=$((cnt % 512))
pascal@18670 1103 break ;;
pascal@20771 1104 *) break ;;
pascal@18670 1105 esac
pascal@18670 1106 done | md5sum | cut -c1-32)"
pascal@20892 1107 [ "$md5" = "$(cat $TMP)" ] && echo "OK" || echo "ERROR"
pascal@18672 1108 rm -f $TMP
pascal@18670 1109 fi
pascal@17635 1110 rm -f /tmp/wait
pascal@23970 1111 [ "$1" ] || read_return
pascal@17635 1112 }
pascal@17635 1113
pascal@17635 1114 usbdev()
pascal@17635 1115 {
pascal@17635 1116 dotwait "Wait 5 seconds for USB devices"
pascal@17635 1117 sleep 5
pascal@17635 1118 rm -f /tmp/wait
pascal@17635 1119 DEV="$(grep -l 1 /sys/block/*/removable | \
pascal@17635 1120 sed 's|/sys/block/\(.*\)/removable|\1|')"
pascal@17635 1121 [ "$DEV" ] || return
pascal@17635 1122 cat > /tmp/dialog$$ <<EOT
pascal@20771 1123 $DIALOG --clear --title " Select your USB key " \
pascal@17635 1124 --menu "\nPlease select the USB key according to its known size.\n\n" \
pascal@18240 1125 0 0 0 \
pascal@17635 1126 $(for i in $DEV ; do
pascal@23946 1127 grep -qs 1 /sys/block/$i/ro ||
pascal@24276 1128 [ $(cat /sys/block/$i/size) -lt 100 ] ||
pascal@17635 1129 echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2> /dev/null)\" "
pascal@17635 1130 done) \
pascal@17635 1131
pascal@17635 1132 EOT
pascal@17635 1133 exec 3>&1
pascal@24276 1134 . /tmp/dialog$$ 2>&1 1>&3 2>/tmp/device$$
pascal@17635 1135 retval=$?
pascal@24276 1136 device=$(cat /tmp/device$$)
pascal@24276 1137 rm -f /tmp/dialog$$ /tmp/device$$
pascal@17635 1138 exec 3>&-
pascal@17635 1139 [ $retval -eq 0 ]
pascal@17635 1140 }
pascal@17635 1141
pascal@17635 1142 tazusbmsg()
pascal@17635 1143 {
pascal@17635 1144 [ "$(which tazusb 2> /dev/null)" ] || return
pascal@17635 1145 echo "You should choose 'USB key read/write installation' to be
pascal@17635 1146 able to save the package updates or your own configuration and data files.\n\n"
pascal@17635 1147 }
pascal@17635 1148
pascal@24279 1149 fixup_gpt()
pascal@24279 1150 {
pascal@24279 1151 quads2bin 1 0 $2 0 | ddq bs=1 seek=$((512+24)) of=$1 # my gpt, alt gpt
pascal@24279 1152 quads2bin 0 | ddq bs=1 seek=$((512+88)) of=$device
pascal@24279 1153 quads2bin $(isohybrid --crc32 $1 1024 $(($(get 596 $1 4)*$(get 592 $1 4)))) | \
pascal@24279 1154 ddq bs=1 seek=$((512+88)) of=$1 # CRC32 partitions
pascal@24279 1155 ddn of=$1 if=$1 bs=512 skip=1 seek=$2 count=1
pascal@24279 1156 ddn of=$1 if=$1 bs=512 skip=2 seek=$(($2-1)) count=1
pascal@24279 1157 quads2bin $2 0 1 0 | ddq bs=1 seek=$(($2*512+24)) of=$1 # my gpt, alt gpt
pascal@24279 1158 quads2bin $(($2-1)) 0 | ddq bs=1 seek=$(($2*512+72)) of=$1
pascal@24279 1159 i=$(get 524 $1 4)
pascal@24279 1160 quads2bin 0 | ddq bs=1 seek=$(($2*512+16)) of=$device
pascal@24279 1161 quads2bin $(isohybrid --crc32 $1 $(($2*512)) $i) | \
pascal@24279 1162 ddq bs=1 seek=$(($2*512+16)) of=$1 # CRC32 header
pascal@24279 1163 quads2bin 0 | ddq bs=1 seek=$((512+16)) of=$device
pascal@24279 1164 quads2bin $(isohybrid --crc32 $1 512 $i) | ddq bs=1 seek=$((512+16)) of=$1 # CRC32 header
pascal@24279 1165 partprobe $1
pascal@24279 1166 }
pascal@24279 1167
pascal@17635 1168 usbbootkey()
pascal@17635 1169 {
pascal@17924 1170 if [ -b "$1" ]; then
pascal@17924 1171 device=$1
pascal@17928 1172 elif [ "$1" ]; then
pascal@17928 1173 echo "Invalid USB key device"
pascal@20771 1174 return 1
pascal@17924 1175 else
pascal@20771 1176 $DIALOG --clear --title " Create a USB boot key " \
pascal@17924 1177 --yes-label "Continue" --yesno \
pascal@17635 1178 "\nThe USB key will be used like a CD-ROM. You will not be able to write
pascal@17635 1179 any data on the boot partition.\n\n
pascal@17635 1180 An extra FAT32 partition will be created with the remaining free space.\n\n
pascal@20771 1181 $(tazusbmsg)Please plug your USB stick in now.\n" 16 70
pascal@17924 1182 [ $? -eq 0 ] || return
pascal@17924 1183 usbdev || return
pascal@23946 1184 fi
pascal@17635 1185
pascal@23946 1186 # perform dd in progress bar
pascal@23951 1187 max=$(($(sectcnt "$ISO")/2048))
pascal@23946 1188 i=0; while [ $i -le $max ]; do
pascal@23946 1189 ddq if="$ISO" bs=1024k count=1 skip=$i seek=$i of=$device
pascal@24177 1190 echo $(((i*100)/max))
pascal@24177 1191 i=$((i+1))
pascal@23956 1192 done | { [ "$1" ] || dialog --gauge \
pascal@23956 1193 " The ISO image transfer can be long. Please wait..." \
pascal@23956 1194 6 70 0 > /dev/tty 2>&1; }
pascal@17635 1195
pascal@23947 1196 # GPT partition + fat32 format for the remaining space
pascal@23951 1197 sectors=$(($(sectcnt $device)-1))
pascal@23951 1198 quads2bin $sectors | ddq bs=1 seek=458 of=$device # pmbr
pascal@24177 1199 quads2bin $((sectors-2)) 0 | ddq bs=1 seek=$((512+48)) of=$device
pascal@24279 1200 uudecode - <<EOT | gunzip | ddn bs=128 seek=9 of=$device # basic data partiton
pascal@23947 1201 begin-base64 644 -
pascal@24279 1202 H4sIAAAAAAACA1u04MLrpzuNXdoPZGzbrjbzOAORwIkhkaGYIZMhmUGBIQXI
pascal@24279 1203 LgFiBYYCIFkEZGeCcT5DHkFzAAqvwhqAAAAA
pascal@23947 1204 ====
pascal@23947 1205 EOT
pascal@24279 1206 ddq if=/dev/urandom bs=16 count=1 seek=73 of=$device # partition uuid
pascal@23951 1207 last=$(sectcnt "$ISO")
pascal@23947 1208 custom=$((4*$(get 32848 $device 4)))
pascal@24177 1209 [ $custom -gt $((last-4)) ] && last=$((custom+4)) # room for cmdline
pascal@24279 1210 quads2bin $last 0 | ddq bs=1 seek=$((1024+128+32)) of=$device # partition first address
pascal@24279 1211 quads2bin $((sectors-2)) 0 | ddq bs=1 seek=$((1024+128+40)) of=$device # partition last address
pascal@24279 1212 fixup_gpt $device $sectors
pascal@24279 1213 [ -b ${device}p2 ] && pdev=${device}p2 || pdev=${device}2
pascal@24279 1214 value=$(cat /sys/block/${device#/dev/}/${pdev#/dev/}/size)
pascal@24279 1215 [ ${#value} -gt 7 -a "$(which mkfs.exfat)" ] && value="exfat" || value="fat32"
pascal@24279 1216 if [ -z "$1" ]; then
pascal@24279 1217 echo -n "$DIALOG --clear --title \" Select the filesystem \" \
pascal@24279 1218 --radiolist \"\\nPlease select the filesystem type to create.\" 14 70 4" > /tmp/dialog$$
pascal@24279 1219 while read type rem; do
pascal@24279 1220 which mkfs.${type/fat32/vfat} > /dev/null || continue
pascal@24279 1221 echo -n " $type \"$rem" >> /tmp/dialog$$
pascal@24279 1222 done <<EOT
pascal@24279 1223 fat32 for a small key" $([ "$value" = "fat32" ] && echo "on" || echo "off")
pascal@24279 1224 exfat for a large key" $([ "$value" = "exfat" ] && echo "on" || echo "off")
pascal@24279 1225 ntfs " off
pascal@24279 1226 ext3 for most linux" off
pascal@24279 1227 ext4 " off
pascal@24279 1228 btrfs for recent linux" off
pascal@24279 1229 xfs
pascal@24279 1230 EOT
pascal@24279 1231 exec 3>&1
pascal@24279 1232 value=$(. /tmp/dialog$$ 2>&1 1>&3)
pascal@24279 1233 retval=$?
pascal@24279 1234 exec 3>&-
pascal@24279 1235 rm -f /tmp/dialog$$
pascal@24279 1236 fi
pascal@24279 1237 homedev=/dev/$(basename /sys/block/${device#/dev/}/${pdev#/dev/})
pascal@24279 1238 case "$value" in
pascal@24279 1239 *fat*) mkfs.${value/fat32/vfat} -n 'SLITAZ HOME' $homedev;;
pascal@24279 1240 *) mkfs.$value -L 'SLITAZ HOME' $homedev;;
pascal@24279 1241 esac > /dev/null 2>&1
pascal@23946 1242
pascal@23946 1243 # update boot/exe crc16
pascal@23950 1244 words2bin 0 | ddq bs=1 seek=18 of=$device
pascal@23950 1245 i=$(($(get 2 $device) - 1 + ($(get 4 $device) - 1)*512))
pascal@23946 1246 i=$(($(od -v -N $i -t u2 -w2 -An $device | \
pascal@23946 1247 awk '{ i+= $0 } END { print (i % 65536) }') \
pascal@24177 1248 + $(get $((i+1)) $device 1)))
pascal@24279 1249 words2bin $(( (-i -1) & 65535 )) | ddq bs=1 seek=18 of=$device
pascal@23947 1250
pascal@23956 1251 [ "$1" ] || $DIALOG --clear --title " Set /home persistent " \
pascal@23947 1252 --yes-label "Continue" --yesno \
pascal@23950 1253 "\nThe USB key will run fully in ram. The datas will be lost after each reboot.\n\n
pascal@23950 1254 This option will mount /home on the USB key vfat during the boot process.\n\n
pascal@23950 1255 Your own data will be saved, but the system stay not upgradable.\n" 16 70
pascal@23947 1256 if [ $? -eq 0 ]; then
pascal@24279 1257 echo -en "$(echo "SliTaz persistent /home" | sed 's|.|&\\0|g')" | ddn bs=8 seek=151 of=$device
pascal@24279 1258 fixup_gpt $device $sectors
pascal@24279 1259 [ "$(ddn bs=512 skip=$custom if=$device | ddn bs=1 count=6)" = "#!boot" ] && return
pascal@24279 1260 mkdir /tmp/mnt$$
pascal@24279 1261 mount $pdev /tmp/mnt$$
pascal@24279 1262 echo -e "keyboard\nlocale\ntimezone" > /tmp/dialog.out$$
pascal@24279 1263 touch /tmp/dialog$$
pascal@24279 1264 if [ -z "$1" ]; then
pascal@24279 1265 cat > /tmp/dialog$$ <<EOT
pascal@24279 1266 $DIALOG --clear --title " Select configuration " \
pascal@24279 1267 --separate-output \
pascal@24279 1268 --cancel-label "Skip" \
pascal@24279 1269 --checklist "Please select the configuration to store." \
pascal@24279 1270 0 0 0 \
pascal@24279 1271 keyboard "kmap=$(cat /etc/keymap.conf)" on \
pascal@24279 1272 locale "lang=${LANG%.UTF*}" on \
pascal@24279 1273 timezone "tz=$(cat /etc/TZ)" on \
pascal@24279 1274 $([ -s /tmp/mnt$$/boot/rootfs.gz ] || cat <<EOM
pascal@24279 1275 network "/etc/network.conf" off \
pascal@24279 1276 ssh "/etc/dropbear" off \
pascal@24279 1277 password "/etc/passwd /etc/*shadow /etc/group" off \
pascal@24279 1278 custom "Your own list of files" off
pascal@24279 1279 EOM
pascal@24279 1280 )
pascal@24279 1281 EOT
pascal@24279 1282 sh /tmp/dialog$$ 2> /tmp/dialog.out$$
pascal@24279 1283 [ $? -eq 0 ] || echo -n "" > /tmp/dialog.out$$
pascal@24279 1284 fi
pascal@24279 1285 data=""; files=""
pascal@24279 1286 while read i ; do
pascal@24279 1287 case "$i" in
pascal@24279 1288 keyboard) data="${data}kmap=$(cat /etc/keymap.conf) ";;
pascal@24279 1289 locale) data="${data}lang=${LANG%.UTF*} " ;;
pascal@24279 1290 timezone) data="${data}tz=$(cat /etc/TZ) " ;;
pascal@24279 1291 network) files="${files} /etc/network.conf" ;;
pascal@24279 1292 ssh) files="${files} /etc/dropbear" ;;
pascal@24279 1293 password) files="${files} /etc/passwd /etc/*shadow /etc/group" ;;
pascal@24279 1294 custom) exec 3>&1
pascal@24279 1295 custom="$($DIALOG --clear --title " Custom files " \
pascal@24279 1296 --inputbox "\nEnter the list of files to save:\n" 10 70 2>&1 1>&3)"
pascal@24279 1297 retval=$?
pascal@24279 1298 exec 3>&-
pascal@24279 1299 [ $retval -eq 0 ] && files="${files} $custom" ;;
pascal@24279 1300 esac
pascal@24279 1301 done < /tmp/dialog.out$$
pascal@24279 1302 rm -f /tmp/dialog$$ /tmp/dialog.out$$
pascal@24279 1303 [ "$data" ] && cat <<EOT | ddn bs=512 seek=$custom of=$device
pascal@24279 1304 #!boot $(echo "append=$data" | md5sum | sed 's/ .*//')
pascal@24279 1305 append=$data
pascal@23947 1306 --
pascal@23947 1307 EOT
pascal@24279 1308 if [ "$files" ]; then
pascal@24279 1309 mkdir /tmp/mnt$$/boot 2> /dev/null
pascal@24279 1310 find $files | cpio -o -H newc | gzip -9 > /tmp/mnt$$/boot/rootfs.gz
pascal@24279 1311 fi
pascal@24279 1312 umount /tmp/mnt$$
pascal@24279 1313 rm -rf /tmp/mnt$$
pascal@23947 1314 fi
pascal@17635 1315 }
pascal@17635 1316
pascal@17635 1317 usbkey()
pascal@17635 1318 {
pascal@20771 1319 $DIALOG --clear --title " Create a SliTaz USB key " \
pascal@17635 1320 --yes-label "Continue" --yesno \
pascal@17635 1321 "\nUnlike a hard drive install, the filesystem is kept in a compressed
pascal@17635 1322 rootfs.gz. The filesystem is loaded entirely into memory upon boot.
pascal@17635 1323 This should increase responsiveness, protect the filesystem against
pascal@17635 1324 accidental corruption and reduce read/writes to the USB drive.
pascal@17635 1325 Once setup, the tazusb utility can rewrite the root filesystem
pascal@20771 1326 with any changes you have made since booting up,
pascal@17635 1327 giving the effective benefits of a hard drive install.\n\n
pascal@17635 1328 /home is mounted on boot using the UUID of your particular flash drive.
pascal@17635 1329 Unlike a device name, the UUID has the benefit of never changing from machine
pascal@17635 1330 to machine.\n\n
pascal@20771 1331 Please plug your USB stick in now.\n" 19 70
pascal@17635 1332 [ $? -eq 0 ] || return
pascal@17635 1333 usbdev || return
pascal@17635 1334 exec 3>&1
pascal@17635 1335 format=`$DIALOG --clear \
pascal@17635 1336 --title " Select the filesystem " \
pascal@17635 1337 --radiolist "\nPlease select the filesystem type to create.\n\n\
pascal@20771 1338 The filesystem creation will erase all the data in the USB key." 14 70 4 \
pascal@17635 1339 "none" "Do not erase the USB key" on \
pascal@17635 1340 "ext3" "Ext3 journaling filesystem" off \
pascal@17635 1341 "ext2" "Ext2 filesystem" off \
pascal@17635 1342 "fat32" "Windows FAT32 filesystem" off \
pascal@17635 1343 2>&1 1>&3`
pascal@17635 1344 retval=$?
pascal@17635 1345 exec 3>&-
pascal@17635 1346 [ $retval -eq 0 ] || return
pascal@17635 1347 [ "$format" != "none" ] && tazusb format $device "SliTaz" $format
pascal@18670 1348 tazusb gen-iso2usb "$ISO" $device
pascal@17635 1349 }
pascal@17635 1350
pascal@17931 1351 flavdata()
pascal@17931 1352 {
pascal@18670 1353 [ $(get 1024 "$ISO") -eq 35615 ] && n=2 || n=$((1+$(get 417 "$ISO" 1)))
pascal@19425 1354 [ $n -eq 4 ] && n=20
pascal@24177 1355 [ $(get $((n*512)) "$ISO") -eq 35615 ] || n=13
pascal@19510 1356 ddq if="$ISO" bs=512 skip=$n count=20 | zcat 2>/dev/null
pascal@17931 1357 }
pascal@17931 1358
pascal@17931 1359 hasflavinfo()
pascal@17931 1360 {
pascal@23946 1361 [ "$(flavdata | ddq bs=1 count=7)" = "0707010" ] && menuitem "$@"
pascal@17931 1362 }
pascal@17931 1363
pascal@17931 1364 showfavinfo()
pascal@17931 1365 {
pascal@17931 1366 mkdir -p /tmp/data
pascal@17931 1367 flavdata | ( cd /tmp/data ; cpio -i )
pascal@17931 1368 file=/tmp/data/info
pascal@17931 1369 cat /tmp/data/*desc > $file
pascal@18627 1370 if [ -s /tmp/data/*receipt ]; then
pascal@18627 1371 echo "=== receipt ==="
pascal@18627 1372 cat /tmp/data/*receipt
pascal@18627 1373 fi >> $file
pascal@17931 1374 for i in /tmp/data/*list* ; do
pascal@17931 1375 echo "=== extra ${i#*list} files"
pascal@17931 1376 cat $i
pascal@17931 1377 done >> $file
pascal@17931 1378 if [ "$1" ]; then
pascal@17931 1379 cat $file
pascal@17931 1380 else
pascal@20771 1381 $DIALOG --clear --title " Flavor info " \
pascal@18240 1382 --textbox $file 0 0
pascal@17931 1383 fi
pascal@17931 1384 rm -rf /tmp/data
pascal@17931 1385 }
pascal@17931 1386
pascal@18626 1387 flavor()
pascal@18626 1388 {
pascal@18626 1389 name="$(flavdata | cpio -t 2> /dev/null | sed 's/.[a-z]*$//;q')"
pascal@18626 1390 echo "Create ${name:=flavor}.flavor..."
pascal@18670 1391 tazlito iso2flavor "$ISO" $name
pascal@18771 1392 ls -l $name.flavor 2> /dev/null && return
pascal@18771 1393 sleep 5
pascal@23970 1394 [ "$1" ] || read_return
pascal@18626 1395 }
pascal@18626 1396
pascal@20892 1397 if [ "$1" = "--build" ]; then #install-begin
pascal@18151 1398 uuencode -m - < ifmem.bin | sed -e '/^ifmemcode$/r/dev/stdin' \
pascal@18151 1399 -e '/^ifmemcode$/d' -i $0
pascal@18140 1400 uuencode -m - < bootloader.bin | sed -e '/^bootloader$/r/dev/stdin' \
pascal@18140 1401 -e '/^bootloader$/d' -e '/install-begin$/,/install-end$/d' -i $0
pascal@18140 1402 exit
pascal@18140 1403 fi #install-end
pascal@18140 1404 parse_isolinux()
pascal@18140 1405 {
pascal@18140 1406 awk 'BEGIN { IGNORECASE=1 }
pascal@18145 1407 function multi(n)
pascal@18145 1408 {
pascal@18145 1409 auto=$n
pascal@18145 1410 for (--n; n < NF; n+=2) {
pascal@18145 1411 s=$n
pascal@18145 1412 if (s ~ /M$/) s = substr(s,0,length(s)-1)
pascal@18145 1413 else s /= 1024
pascal@18145 1414 sizes=int(s) " " sizes
pascal@18145 1415 }
pascal@18145 1416 next
pascal@18145 1417 }
pascal@18140 1418 {
pascal@18140 1419 if ($1 == "LABEL") {
pascal@18140 1420 label=$2
pascal@18140 1421 if (auto == "") auto=label
pascal@18140 1422 }
pascal@18140 1423 if ($1 == "KERNEL" || $1 == "COM32") kernel[label]=$2
pascal@18140 1424 if ($1 == "INITRD") initrd[label]=$2
pascal@18140 1425 if ($1 == "APPEND") {
pascal@18140 1426 i=2
pascal@18145 1427 if (kernel[label] ~ "ifmem.c32") multi(3)
pascal@18140 1428 if (kernel[label] ~ "c32box.c32") {
pascal@18140 1429 if ($2 == "linux") { kernel[label]=$3; i=4 }
pascal@18145 1430 if ($2 == "ifmem") multi(4)
pascal@18140 1431 }
pascal@18140 1432 if (kernel[label] ~ "ifcpu64.c32") { auto=$4; next }
pascal@18140 1433 while (i <= NF) {
pascal@18140 1434 if ($i ~ "^initrd=") initrd[label]=substr($i,8)
pascal@18140 1435 else cmdline[label]=cmdline[label] " " $i
pascal@18140 1436 i++
pascal@18140 1437 }
pascal@18140 1438 }
pascal@18140 1439 }
pascal@18140 1440 END {
pascal@18140 1441 print "KERNEL=\"" kernel[auto] "\""
pascal@18140 1442 print "INITRD=\"" initrd[auto] "\""
pascal@18140 1443 print "CMDLINE=\"" substr(cmdline[auto],2) "\""
pascal@18145 1444 print "SIZES=\"" sizes "\""
pascal@18140 1445 }'
pascal@18140 1446 }
pascal@18140 1447
pascal@18140 1448 locase()
pascal@18140 1449 {
pascal@18140 1450 echo "$1" | tr [A-Z] [a-z]
pascal@18140 1451 }
pascal@18140 1452
pascal@18151 1453 ifmemcode()
pascal@18151 1454 {
pascal@18151 1455 uudecode <<EOT
pascal@18151 1456 ifmemcode
pascal@18151 1457 EOT
pascal@18151 1458 }
pascal@18151 1459
pascal@18140 1460 floppyset()
pascal@18140 1461 {
pascal@19425 1462 gotcdfile 'isolinux.cfg'
pascal@19432 1463 $0 include $file | parse_isolinux > /tmp/var$$
pascal@18140 1464 . /tmp/var$$
pascal@19425 1465 [ -z "$KERNEL" ] && echo "Can't parse isolinux.cfg" && return
pascal@18240 1466 for i in $media/$KERNEL $(dirname $file)/$KERNEL $media/$(locase $KERNEL) \
pascal@18240 1467 $(dirname $file)/$(locase $KERNEL); do
pascal@19433 1468 i="$(ls $i* | sed q)"
pascal@19433 1469 [ -n "$i" ] && KERNEL=$i && break
pascal@18240 1470 done
pascal@20771 1471 rm -f /tmp/var$$
pascal@18240 1472 [ $(get 514 $KERNEL 4) -eq 1400005704 ] || return
pascal@18240 1473 n=$(($(get 497 $KERNEL 1)+1))
pascal@18240 1474 ddq bs=512 count=$n if=$KERNEL of=/tmp/fd$$
pascal@23946 1475 uudecode <<EOT | ddn of=/tmp/fd$$
pascal@18140 1476 bootloader
pascal@18140 1477 EOT
pascal@24177 1478 pos=$((n*512))
pascal@18140 1479 if [ -n "$CMDLINE" ]; then
pascal@18140 1480 echo -n "$CMDLINE" | ddq bs=512 count=1 conv=sync >> /tmp/fd$$
pascal@23946 1481 bytes2bin $n | ddn bs=1 seek=497 of=/tmp/fd$$
pascal@23946 1482 words2bin $pos | ddn bs=1 seek=34 of=/tmp/fd$$
pascal@18240 1483 [ $(get 518 $KERNEL 4) -ge 514 ] &&
pascal@23946 1484 words2bin 32768 9 | ddn bs=1 seek=552 of=/tmp/fd$$
pascal@18140 1485 fi
pascal@18140 1486 syssize=$(echo $(get 500 /tmp/fd$$ 4))
pascal@18240 1487 ddq bs=512 skip=$n if=$KERNEL | cat - /dev/zero | \
pascal@24177 1488 ddq bs=512 count=$(((syssize+31)/32)) conv=sync >> /tmp/fd$$
pascal@23947 1489 base=$(size /tmp/fd$$)
pascal@18140 1490 len=
pascal@18140 1491 if [ "$INITRD" ]; then
pascal@18140 1492 l=0
pascal@18140 1493 for i in ${INITRD//,/ }; do
pascal@18240 1494 for j in $media/$i $(dirname $KERNEL)/$i $media/$(locase $i) \
pascal@18240 1495 $(dirname $KERNEL)/$(locase $i); do
pascal@19433 1496 j="$(ls $j* | sed q)"
pascal@19433 1497 [ -n "$j" ] && i=$j && break
pascal@18240 1498 done
pascal@18240 1499 ddq if=$i >> /tmp/fd$$
pascal@24177 1500 l=$((l+$(size $i)))
pascal@24177 1501 r=$((4 - (l % 4)))
pascal@18140 1502 if [ $r -ne 4 ]; then
pascal@18140 1503 ddq if=/dev/zero bs=1 count=$r >> /tmp/fd$$
pascal@24177 1504 l=$((l + r))
pascal@18140 1505 fi
pascal@18143 1506 case "$i:$INITRD" in
pascal@18143 1507 *rootfs.gz:*rootfs.gz,*) continue # loram
pascal@18140 1508 esac
pascal@18140 1509 len="$len $l"; l=0
pascal@18140 1510 done
pascal@24177 1511 rdadrs=${RDADRS:-$((((syssize*16)+0x1F0000) & -4096))}
pascal@23951 1512 quads2bin $rdadrs | ddn bs=1 seek=536 of=/tmp/fd$$
pascal@18140 1513 fi
pascal@18140 1514 n=$(echo $len | wc -w)
pascal@24177 1515 if [ $((494 - $(get 494 /tmp/fd$$))) -ge $((n * 4)) ]; then
pascal@18140 1516 i=$(($(get 494 /tmp/fd$$)))
pascal@24177 1517 bytes2bin $((i + (n*4) - 256)) | ddn bs=1 \
pascal@23946 1518 seek=496 of=/tmp/fd$$
pascal@18140 1519 else
pascal@24177 1520 i=$((pos + 0x1FC - (n*4)))
pascal@24177 1521 bytes2bin $((i % 256)) $((i / 256)) 252 | ddn bs=1 \
pascal@23946 1522 seek=494 of=/tmp/fd$$
pascal@24177 1523 s=$((i - 2*$(echo "$SIZES" | wc -w)))
pascal@24177 1524 p=$((s - $(ifmemcode | wc -c)))
pascal@23946 1525 ifmemcode | ddn bs=1 seek=$p of=/tmp/fd$$
pascal@23946 1526 words2bin $SIZES | ddn bs=1 seek=$s of=/tmp/fd$$
pascal@24177 1527 bytes2bin 154 $((p%256)) $((p/256)) 0 144 | \
pascal@23946 1528 ddn bs=1 seek=60 of=/tmp/fd$$
pascal@18140 1529 fi
pascal@18140 1530 for r in $len ; do
pascal@23951 1531 quads2bin $r | ddn bs=1 seek=$i of=/tmp/fd$$
pascal@24177 1532 i=$((i + 4))
pascal@18140 1533 done
pascal@18140 1534 split -b 1440k /tmp/fd$$ fd$$
pascal@18140 1535 rm -f /tmp/fd$$
pascal@18140 1536 n=1; i=0; r=0
pascal@18140 1537 set -- $len
pascal@18140 1538 ls fd$$* | while read file ; do
pascal@24177 1539 if [ $i -ge $(($1+base)) ]; then
pascal@24177 1540 base=$(($1+base-i))
pascal@18140 1541 shift
pascal@24177 1542 r=$((r+100)); n=0; i=0
pascal@18140 1543 fi
pascal@18140 1544 ddq of=$file bs=18k seek=80 count=0
pascal@24177 1545 i=$((i+1474560))
pascal@24177 1546 printf "mv %s fd%03d.img\n" $file $((r+n))
pascal@24177 1547 n=$((n+1))
pascal@18140 1548 done | sh
pascal@19029 1549 du -ch $PWD/fd???.img
pascal@18140 1550 }
pascal@18140 1551
pascal@17635 1552 quit()
pascal@17635 1553 {
pascal@18240 1554 umount -d $media
pascal@18240 1555 rmdir $media
pascal@18240 1556 ${1:-exit}
pascal@17635 1557 }
pascal@17635 1558
pascal@19008 1559 infoiso()
pascal@19008 1560 {
pascal@24164 1561 isoinfo -d -i "$ISO" > /tmp/isoinfo$$ 2> /dev/null
pascal@24164 1562 if [ "$(which iso2exe)" ]; then
pascal@19008 1563 echo "----"
pascal@20159 1564 blkid "$ISO" | while read args; do
pascal@20159 1565 set -- $args
pascal@20159 1566 while [ -n "$2" ]; do
pascal@20159 1567 case "$2" in
pascal@20159 1568 *UUID*|PT*) echo $2;;
pascal@20159 1569 esac
pascal@20159 1570 shift
pascal@20159 1571 done
pascal@20159 1572 done
pascal@20159 1573 if ! fdisk -l "$ISO" | grep -q 'valid partition'; then
pascal@20159 1574 fdisk -l "$ISO" | grep heads
pascal@20159 1575 fdisk -l "$ISO" | sed 's/^ *[^ ]* *//;s/ */ /g;$!d'
pascal@20159 1576 fi
pascal@20159 1577 echo "----"
pascal@19008 1578 iso2exe -l "$ISO"
pascal@19008 1579 fi >> /tmp/isoinfo$$
pascal@19008 1580 if [ "$1" ]; then
pascal@19008 1581 cat /tmp/isoinfo$$
pascal@19008 1582 else
pascal@20771 1583 $DIALOG --clear --title " Info ISO " \
pascal@19008 1584 --textbox /tmp/isoinfo$$ 0 0
pascal@24164 1585 files=$(sed '/^custom.*d/!d;s| .*||' /tmp/isoinfo$$)
pascal@24164 1586 if [ "$files" ]; then
pascal@24164 1587 $DIALOG --clear --title " Extract custom files " \
pascal@24164 1588 --defaultno --yesno \
pascal@24164 1589 "Do you want to extract the custom boot files ?\n$files" 7 70
pascal@24164 1590 [ $? -eq 0 ] && for i in $files ; do
pascal@24164 1591 echo "Extract $i ..."
pascal@24164 1592 iso2exe -l "$ISO" $i
pascal@24164 1593 done
pascal@24164 1594 fi
pascal@19008 1595 fi
pascal@19008 1596 rm -f /tmp/isoinfo$$
pascal@19008 1597 }
pascal@19008 1598
pascal@18289 1599 isotitle()
pascal@18289 1600 {
pascal@18778 1601 echo "$(blkid "$ISO" | sed 's/.*LABEL="\([^"]*\).*/\1/') $(stat \
pascal@18778 1602 -c %y $media/.|sed 's/ .*//') $(basename "$ISO")"
pascal@18289 1603 }
pascal@18289 1604
pascal@23820 1605 if [ $0 = /init.exe ]; then
pascal@23820 1606
pascal@23820 1607 case "${ISO##*/}$(getarg mode)" in
pascal@23820 1608 *install*|*INSTALL*) install;;
pascal@23820 1609 *live*|*LIVE*) live;;
pascal@23820 1610 *text*|*TEXT*) text;;
pascal@23820 1611 esac
pascal@23820 1612 dmesg > /tmp/dmesg
pascal@23820 1613
pascal@23820 1614 else
pascal@23820 1615
pascal@20892 1616 if [ "$1" = "include" ]; then
pascal@19432 1617 [ -s "$2" ] && cd $(dirname "$2") && awk -v exe=$0 \
pascal@19432 1618 '{ if ($1 == "include") system(exe " include " $2); else print }' <"$2"
pascal@19432 1619 exit
pascal@19432 1620 fi
pascal@18034 1621 ISO="${1:-/dev/null}"
pascal@23951 1622 while [ -L "$ISO" ]; do
pascal@23951 1623 media="$(readlink "$ISO")"
pascal@23951 1624 case "$media" in
pascal@23951 1625 /*) ISO="$media" ;;
pascal@23951 1626 *) ISO="$(dirname "$ISO")/$media" ;;
pascal@23951 1627 esac
pascal@23951 1628 done
pascal@23951 1629 [ "${ISO:0:1}" != "/" ] && ISO="$(cd $(dirname "$ISO"); echo $PWD/$(basename "$ISO"))"
pascal@17635 1630 [ -z "$(isiso 2> /dev/null)" ] && echo "Usage : $0 file.iso" && exit 1
pascal@18666 1631 media=/tmp/media$$
pascal@18240 1632 mkdir -p $media
pascal@18670 1633 mount -o loop,ro "$ISO" $media
pascal@17635 1634
pascal@20892 1635 if [ "$2" = "list" ]; then
pascal@17928 1636 sed '/^\$(.*") \\/!d;s/^\$(\(.*\)").*/\1"/' $0 | while read line; do
pascal@17928 1637 eval $line
pascal@17928 1638 echo
pascal@17928 1639 done | sed '/^$/d;/"usbkey"/d'
pascal@17928 1640 quit
pascal@17928 1641 fi
pascal@17924 1642 if grep -q "^$2()" $0; then
pascal@17924 1643 exe=$2
pascal@17924 1644 shift 2
pascal@18140 1645 if [ -n "$(eval $(grep "\"$exe\"" $0 | sed \
pascal@18140 1646 '/^\$/!d;s/.(\(.*\)[\t ]*".*"[\t ]*".*/\1/'))" ]; then
pascal@18289 1647 isotitle
pascal@17924 1648 grep "\"$exe\"" $0 | sed '/^\$/!d;s/.*"[\t ]*"\(.*\)".*/\1/'
pascal@18140 1649 echo ----
pascal@17924 1650 $exe "$@"
pascal@17924 1651 fi
pascal@17924 1652 quit
pascal@17924 1653 fi
pascal@23820 1654 fi
pascal@17924 1655
pascal@17635 1656 while true; do
pascal@23820 1657 keymap="$(cat /etc/keymap.conf 2>/dev/null)"
pascal@23820 1658 locale="$(sed '/^LANG=/!d;s/.*=//' /etc/locale.conf 2>/dev/null)"
pascal@17635 1659 cat > /tmp/dialog$$ <<EOT
pascal@24279 1660 $DIALOG --clear --title " $(isotitle) " --menu "" 0 0 0 \
pascal@23820 1661 $(initxfile tazkeymap "tazkeymap" "Select keyboard (${keymap:-none})") \
pascal@23820 1662 $(initxfile tazlocale "tazlocale" "Select locale (${locale:-none})") \
pascal@23820 1663 $(initx "live" "Linux RAM boot (full desktop)") \
pascal@23820 1664 $(initx "text" "Linux RAM boot") \
pascal@17635 1665 $(cdfile 'README*' "readme" "Show the README file") \
pascal@18675 1666 $(gotcustomconf "getcustomconf" "Get custom config") \
pascal@23956 1667 $(noinit "setcustomconf" "Set custom config") \
pascal@17635 1668 $(gotisomd5 "isomd5" "Check the ISO image") \
pascal@17635 1669 $(cdfile 'md5sum*' "md5" "Check the ISO files") \
pascal@17635 1670 $(cdfile 'sha*sum*' "sha" "Check the ISO files") \
pascal@24004 1671 $(menuitem "filepos" "File start sector") \
pascal@24164 1672 $(xfile 'isoinfo iso2exe' "infoiso" "ISO image info") \
pascal@23946 1673 $(cdfilex 'bzImage*' "bootiso" "Boot the ISO image") \
pascal@18034 1674 $(burnable "burniso" "Burn the ISO image") \
pascal@18034 1675 $(blankable "blankcd" "Blank the CD/DVD") \
pascal@17635 1676 $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \
pascal@17635 1677 $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \
pascal@17635 1678 $(gotposixovlzip "inst2zip" "ZIP installation archive (UMSDOS way)") \
pascal@17635 1679 $(gotposixovlzip "insttaz2zip" "ZIP installation archive (TAZUSB way)") \
pascal@19425 1680 $(gottazusb "usbkey" "USB key read/write installation") \
pascal@24279 1681 $(ishybrid "usbbootkey" "USB boot key (kernel not upgradable)") \
paul@17935 1682 $(hasflavinfo "showfavinfo" "Show flavor extra info") \
pascal@19425 1683 $(hasflavor "flavor" "Get flavor file") \
pascal@18140 1684 $(cdfile isolinux.cfg "floppyset" "Boot floppy set") \
pascal@23970 1685 $(cdfile linld.com "tazboot" "Get tazboot.exe Linux loader for DOS") \
pascal@23946 1686 $(cdexe 'bzImage*' "bzimage" "Get linux DOS/EXE file") \
pascal@17635 1687 $(cdexe 'memtest*' "memtest" "Get Memtest86 DOS/EXE file") \
pascal@17635 1688 $(cdfilef 'memtest*' "fdmemtest" "Create a Memtest86 boot floppy") \
pascal@20724 1689 $(cdexe '?pxe*' "pxe" "Get SliTaz Web boot DOS/EXE utility") \
pascal@20724 1690 $(cdfilef '?pxe*' "fdpxe" "Create a SliTaz Web boot floppy") \
pascal@24011 1691 $(cdexe 'plop*' "plop" "Get USB boot DOS/EXE utility") \
pascal@24011 1692 $(cdfilef 'plop*' "fdplop" "Create a USB boot floppy") \
pascal@23820 1693 $(initxfile reboot "restart" "Restart the computer") \
pascal@23820 1694 $(initxfile poweroff "stop" "Power off") \
pascal@23820 1695 $(initx "bootlog" "Linux boot messages") \
pascal@23820 1696 $(initx "shell" "Shell prompt") \
pascal@23820 1697 $(noinitmisspkg "missing" "Install packages to get more options") \
pascal@23820 1698 $(noinit "quit" "Quit this utility")
pascal@17635 1699 EOT
pascal@17635 1700 exec 3>&1
pascal@17635 1701 value=$(. /tmp/dialog$$ 2>&1 1>&3)
pascal@17635 1702 retval=$?
pascal@17635 1703 exec 3>&-
pascal@17635 1704 rm -f /tmp/dialog$$
pascal@23820 1705 [ $retval -ne 0 ] && [ $0 != /init.exe ] && quit
pascal@17635 1706 $value
pascal@17635 1707 done