# HG changeset patch # User Pascal Bellard # Date 1423934246 -3600 # Node ID 65c5ea249c9a22f46087ebcae79f2cf094750338 # Parent f940e42dac11ccd30c6fd62beaeb7a8826b4a77f syslinux-tools: add taziso diff -r f940e42dac11 -r 65c5ea249c9a syslinux-tools/receipt --- a/syslinux-tools/receipt Sat Feb 14 17:35:42 2015 +0200 +++ b/syslinux-tools/receipt Sat Feb 14 18:17:26 2015 +0100 @@ -21,5 +21,6 @@ cp -a $src/iso2exe/isohybrid.exe $fs/usr/share/boot cp -a $src/iso2exe/meminfo.exe $fs/usr/share/boot cp -a $src/iso2exe/tazboot.exe $fs/usr/share/boot + cp -a $src/iso2exe/taziso $fs/usr/bin find $fs/usr -exec chown root.root {} \; } diff -r f940e42dac11 -r 65c5ea249c9a syslinux/stuff/iso2exe/init --- a/syslinux/stuff/iso2exe/init Sat Feb 14 17:35:42 2015 +0200 +++ b/syslinux/stuff/iso2exe/init Sat Feb 14 18:17:26 2015 +0100 @@ -298,12 +298,12 @@ sleep 5 return 1 fi - dowait "Install root filesystem in /slitaz.." + dotwait "Install root filesystem in /slitaz.." if [ "$1" ]; then if [ -d /media/cdrom/fs ]; then ( cd /mnt/slitaz/fs; find | cpio -o -H newc ) | gzip -9 else - ls_r /media/cdrom/boot/rootfs* | xargs cat + ls_r /media/cdrom/boot/rootfs*gz | xargs cat fi > /mnt/slitaz/boot/rootfs.gz tazusbinitfs /mnt/slitaz/boot/rootfs.gz initrd=rootfs.gz @@ -316,18 +316,18 @@ [ -s $(basename $i) ] && continue cpio -i $i done - for i in $(ls_r /media/cdrom/boot/rootfs*); do + for i in $(ls_r /media/cdrom/boot/rootfs*gz); do mount -o loop,ro $i /sqfs/mnt cp -a /sqfs/mnt/. /mnt/slitaz umount -d /sqfs/mnt done else - for i in $(ls_r /media/cdrom/boot/rootfs*); do + for i in $(ls_r /media/cdrom/boot/rootfs*gz); do uncpio $i /mnt/slitaz done fi - cp -a /etc/locale.conf /tmp/slitaz/etc 2> /dev/null - cp -a /etc/keymap.conf /tmp/slitaz/etc 2> /dev/null + cp -a /etc/locale.conf /mnt/slitaz/etc 2> /dev/null + cp -a /etc/keymap.conf /mnt/slitaz/etc 2> /dev/null mkinitrd /mnt/slitaz/boot/initrd initrd=initrd extraargs="mount=$(getuuid) subroot=slitaz" @@ -413,7 +413,7 @@ if [ -d /media/cdrom/fs ]; then cp -a /media/cdrom/fs/. / else - for i in $(ls_r /media/cdrom/boot/rootfs*); do + for i in $(ls_r /media/cdrom/boot/rootfs*gz); do uncpio $i done fi @@ -466,8 +466,8 @@ gotcdfile() { - for i in /media/cdrom/$1 /media/cdrom/*/$1 \ - /media/cdrom/*/isolinux/$1 ; do + for i in "/media/cdrom/$1" "/media/cdrom/*/$1" \ + "/media/cdrom/*/isolinux/$1" ; do file=$(ls $i 2> /dev/null | sed q) [ -s "$file" ] && break done @@ -475,14 +475,14 @@ sha() { - gotcdfile sha*sum* + gotcdfile "sha*sum*" sha=$(basename $file) md5 "${sha%sum*}sum -c ${file#/media/cdrom/}" } readme() { - gotcdfile README* + gotcdfile "README*" $DIALOG --clear \ --title " Readme " \ --textbox $file 24 78 @@ -518,7 +518,7 @@ computers. BIOS based memory tests are a quick, cursory check and often miss many of the failures that are detected by Memtest86.\n " 12 70 - [ $? -eq 0 ] && gotcdfile memtest* && cp $file /mnt/memtest.exe + [ $? -eq 0 ] && gotcdfile "memtest*" && cp $file /mnt/memtest.exe } mkfat12() @@ -563,12 +563,12 @@ miss many of the failures that are detected by Memtest86.\n\n Please insert a blank disk in floppy drive.\n " 12 70 - [ $? -eq 0 ] && gotcdfile memtest* && mkfloppy $file + [ $? -eq 0 ] && gotcdfile "memtest*" && mkfloppy $file } pxe() { - gotcdfile ?pxe + gotcdfile "?pxe" $DIALOG --clear \ --title " Create $(basename $file).exe ? " \ --yes-label "Install" --yesno \ @@ -592,7 +592,7 @@ from the Web using PXE and HTTP protocols.\n\n Please insert a blank disk in floppy drive.\n " 12 70 - [ $? -eq 0 ] && gotcdfile ?pxe && mkfloppy $file + [ $? -eq 0 ] && gotcdfile "?pxe" && mkfloppy $file } gotposixovl() @@ -648,21 +648,24 @@ gotisomd5() { [ "$(which md5sum 2> /dev/null)" ] && - [ $(get 18 /dev/loop0) -ne 0 ] && echo -en "\"$1\" \"$2\"" + [ $(get 0 /mnt/$ISO) -eq 23117 ] && + [ $(get 18 /mnt/$ISO) -ne 0 ] && echo -en "\"$1\" \"$2\"" } isomd5() { dotwait "Checking iso image" - [ "$(ddq if=/dev/loop0 bs=2k skip=16 \ - count=$(echo $(get 32848 /dev/loop0 4)) | md5sum)" == \ - "$(ddq if=/dev/loop0 bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \ + [ "$(ddq if=/mnt/$ISO bs=2k skip=16 \ + count=$(echo $(get 32848 /mnt/$ISO 4)) | md5sum)" == \ + "$(ddq if=/mnt/$ISO bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \ sed 's/ //g') -" ] && echo "OK" || echo "ERROR" - echo -en "\rChecking iso hybrid boot" - n=$(($(get 2 /dev/loop0)-1+($(get 4 /dev/loop0)-1)*512)) - s=$(get 0 /dev/loop0 2 $n | awk '{ i+= $0 } END { print i }') - [ $(((1+$s+$(get $(($n+1)) /dev/loop0 1)) % 65536)) -eq 0 ] && - echo "OK" || echo "ERROR" + echo -en "\rChecking iso hybrid boot..." + n=$(($(get 2 /mnt/$ISO)-1+($(get 4 /mnt/$ISO)-1)*512)) + if [ $n -lt 40000 -a $n -gt 32768 ]; then + s=$(get 0 /mnt/$ISO 2 $n | awk '{ i+= $0 } END { print i }') + [ $(((1+$s+$(get $(($n+1)) /mnt/$ISO 1)) % 65536)) -eq 0 ] && + echo "OK" || echo "ERROR" + fi rm -f /tmp/wait echo -e "\rPress RETURN to continue." read n @@ -878,12 +881,12 @@ runmemtest() { - gotcdfile memtest* && dokexec + gotcdfile "memtest*" && dokexec } runpxe() { - gotcdfile ?pxe && dokexec + gotcdfile "?pxe" && dokexec } shell() @@ -919,10 +922,10 @@ $(xfile tazlocale "tazlocale" "Select locale (${locale:-none})") \ $(cdfile boot/bzImage "live" "Linux RAM boot (full desktop)") \ "text" "Linux RAM boot" \ -$(cdfile README* "readme" "Show the README file") \ +$(cdfile "README*" "readme" "Show the README file") \ $(gotisomd5 "isomd5" "Check the ISO image") \ -$(cdfile md5sum* "md5" "Check the ISO files") \ -$(cdfile sha*sum* "sha" "Check the ISO files") \ +$(cdfile "md5sum*" "md5" "Check the ISO files") \ +$(cdfile "sha*sum*" "sha" "Check the ISO files") \ $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \ $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \ $(xfile tazusb "usbkey" "USB key read/write installation") \ @@ -930,12 +933,12 @@ $(fddata "fdbootstrap" "Create a floppy bootstrap") \ "tazboot" "Get tazboot.exe Linux loader" \ $(cdexe boot/bzImage "bzimage" "Get linux DOS/EXE file") \ -$(cdexe memtest* "memtest" "Get Memtest86 DOS/EXE file") \ -$(cdfilef memtest* "fdmemtest" "Create a Memtest86 boot floppy") \ -$(cdfilex memtest* "runmemtest" "Start Memtest86") \ -$(cdexe ?pxe "pxe" "Get SliTaz Web boot DOS/EXE utility") \ -$(cdfilef ?pxe "fdpxe" "Create a SliTaz Web boot floppy") \ -$(cdfilex ?pxe "runpxe" "Start the SliTaz Web boot utility") \ +$(cdexe "memtest*" "memtest" "Get Memtest86 DOS/EXE file") \ +$(cdfilef "memtest*" "fdmemtest" "Create a Memtest86 boot floppy") \ +$(cdfilex "memtest*" "runmemtest" "Start Memtest86") \ +$(cdexe "?pxe" "pxe" "Get SliTaz Web boot DOS/EXE utility") \ +$(cdfilef "?pxe" "fdpxe" "Create a SliTaz Web boot floppy") \ +$(cdfilex "?pxe" "runpxe" "Start the SliTaz Web boot utility") \ $(xfile reboot "restart" "Restart the computer") \ $(xfile poweroff "stop" "Power off") \ "bootlog" "Linux boot messages" \ diff -r f940e42dac11 -r 65c5ea249c9a syslinux/stuff/iso2exe/taziso --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/syslinux/stuff/iso2exe/taziso Sat Feb 14 18:17:26 2015 +0100 @@ -0,0 +1,909 @@ +#!/bin/sh + +[ $(id -u) -eq 0 ] || exec su -c "$0 $@" + +DIALOG=dialog + +ddq() +{ + dd $@ 2> /dev/null +} + +get() +{ + od -v -j $1 -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An $2 2>/dev/null || + hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %d\n\"" $2 +} + +bytes2bin() +{ + for i in $@ ; do + printf '\\\\x%02X' $(($i&255)) + done | xargs echo -en +} + +words2bin() +{ + for i in $@ ; do + printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255)) + done | xargs echo -en +} + +gettazboot() +{ + echo "Creating $(basename $1) ..." + if [ $(get 0 $ISO) -eq 23117 ]; then + O=$(($(get 66 $ISO) - 0xC0)) + L=$(($(get 20 $ISO) - 0xC0 - $(get 24 $ISO) - $O)) + S=$((32+$L)) + P=$((($S+511)/512)) + E=$((4096-(32*$P))) + words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) \ + -2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1 + ddq bs=1 count=$L skip=$(echo $O) if=$ISO >> $1 + else + wget -O $1 http://mirror.slitaz.org/boot/tazboot.exe + fi +} + +uncpio() +{ + [ -s "$1" ] || return + echo -en "\n Extracting $(basename $1) ..." + case $(get 0 $1) in + *35615) ( zcat || gunzip ) ;; + *14333) unxz ;; + *\ 93) unlzma ;; + *) cat ;; + esac < $1 | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 ) +} + +dotwait() +{ + echo -n "${1:-Install filesystem}.." + touch /tmp/wait + while [ -e /tmp/wait ]; do + echo -n "." > /dev/tty + sleep 1 + done & +} + +getuuid() +{ + dev=$(mount | sed "/ $(echo $mnt | sed 's|/|\\/|g') /!d;s/ .*//;s|/dev/||;q") + [ "$dev" ] && + blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/" || + echo "/dev/hda1" +} + +tazusbinitfs() +{ + PAD=$(($(stat -c %s $1) % 4)) + [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1 + mkdir -p /tmp/fs$$/etc /tmp/fs$$/lib /tmp/fs$$/home + cp -a /etc/locale.conf /tmp/fs$$/etc 2> /dev/null + cp -a /etc/keymap.conf /tmp/fs$$/etc 2> /dev/null + cat > /tmp/fs$$/init1 < /tmp/fs$$/init2 < /dev/null ; done; sleep 2 +v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2> /dev/null) +mount / -o remount,rw +mkdir /mnt/dos +rm -f /cmdline 2> /dev/null +mount / -o remount,ro +mnt=/mnt/dos/\${v#*/} +dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q') +echo "Mount \$dev in /mnt/dos for \$v..." | tee -a /run/boot.log +mount \$dev /mnt/dos +if [ ! -d /mnt/dos/slitaz ]; then + umount /mnt/dos 2> /dev/null + (blkid /dev/[sh]d* || blkid) | while read dev line; do + case "\$line" in + *ntfs*|*vfat*|*msdos*) ;; + *) continue ;; + esac + mount \${dev%:} /mnt/dos + [ -d /mnt/dos/slitaz ] && break + umount /mnt/dos + done +fi +mount.posixovl -F \$mnt -- -oallow_other -odefault_permissions -osuid +mount --bind \$mnt /home +umount /proc +exec /sbin/init +EOT + chmod 755 /tmp/fs$$/init? + ( cd /tmp/fs$$ ; find * | cpio -o -H newc ) | gzip -9 >> $1 + rm -rf /tmp/fs$$ +} + +mkinitrd() +{ + echo -en "\nCreating $(basename $1) " + fs=/tmp/fs$$ + for i in bin lib dev proc tmp mnt etc ; do + mkdir -p $fs/$i + done + for i in /dev/console /dev/null /dev/tty /dev/tty0 /dev/tty1 /dev/tty2 \ + /dev/fuse /dev/hd* /dev/sd* ; do + cp -a $2$i $fs/dev/ + done + for i in /bin/busybox $(which mount.posixovl) $(which blkid); do + cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \ + sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') $fs/lib + cp $i $fs/bin + done + cp -a /lib/ld-* $fs/lib + for i in $(busybox | sed '/Current/,$!d'); do + [ -e $fs/bin/${i%,} ] || ln -s busybox $fs/bin/${i%,} + done + ln -s /proc/mounts $fs/etc/mtab + sed 's/ .*//' /proc/modules | while read mod ; do + find /lib/modules/ | grep $mod.ko | \ + sed 's|.*|cp & $fs/lib|' | sh + done + cat > $fs/init < /dev/null ; done; sleep 2 +arg mount "Mount device" +mount \$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q') /mnt +arg subroot "Change root to directory" +if [ -d /mnt/\$val ]; then + umount /mnt 2> /dev/null + (blkid /dev/[sh]d* || blkid) | while read dev line; do + case "\$line" in + *ntfs*|*vfat*|*msdos*) ;; + *) continue ;; + esac + mount \${dev%:} /mnt + [ -d /mnt/\$val ] && break + umount /mnt + done +fi +mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid +mount --bind /mnt /mnt/\$val/mnt/dos +mount -o size=0 -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val +LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q) +export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib + [ "$debug" = "true" ] && sh +umount /proc +exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init +EOT + chmod +x $fs/init + ( cd $fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null + rm -rf $fs /tmp/wait +} + +ls_r() +{ + ls -r $@ 2> /dev/null || ls $@ +} + +doinstall() +{ + mkdir -p $mnt/slitaz/boot $mnt/slitaz/mnt/dos + if ! mount.posixovl -F $mnt/slitaz -- \ + -oallow_other -odefault_permissions -osuid; then + echo "Can't install SliTaz. Abort." + sleep 5 + return 1 + fi + dotwait "Install root filesystem in /slitaz.." + if [ "$1" ]; then + ls_r /media/cdrom/boot/rootfs*gz | \ + xargs cat > $mnt/slitaz/boot/rootfs.gz + tazusbinitfs $mnt/slitaz/boot/rootfs.gz + initrd=rootfs.gz + extraargs="/home=$(getuuid)/slitaz rdinit=/init1" + else + for i in $(ls_r /media/cdrom/boot/rootfs*gz); do + uncpio $i $mnt/slitaz + done + for i in $packages_list; do + tazpkg get-install $i --root=$mnt/slitaz + done + for i in $packages_dir/*.tazpkg; do + [ -s "$i" ] && + tazpkg install $i --root=$mnt/slitaz + done + cp -a /etc/locale.conf $mnt/slitaz/etc 2> /dev/null + cp -a /etc/keymap.conf $mnt/slitaz/etc 2> /dev/null + mkinitrd $mnt/slitaz/boot/initrd $mnt/slitaz + initrd=initrd + extraargs="mount=$(getuuid) subroot=slitaz" + fi + echo -en "\nInstall boot files..." + for i in /media/cdrom/boot/bzImage /media/cdrom/boot/*pxe* \ + /media/cdrom/boot/isolinux/he* /media/cdrom/boot/isolinux/opt* \ + /media/cdrom/README /media/cdrom/boot/memtest* ; do + [ -s $i ] && cp $i $mnt/slitaz/boot + done + for i in $mnt/slitaz/boot/memtest $mnt/slitaz/boot/*pxe* ; do + [ $(get 0 $i 2> /dev/null || echo 0) -eq 23117 ] && + mv $i $i.exe + done + gettazboot $mnt/slitaz/boot/tazboot.exe + unix2dos > $mnt/slitaz/boot/tazboot.cmd < /tmp/dialog$$ <&1 + [ $? -eq 0 ] || return + device=$(. /tmp/dialog$$ 2>&1 1>&3) + exec 3>&- + rm -f /tmp/dialog$$ + mnt=/tmp/mnt$$ + mkdir -p $mnt && mount $device $mnt +} + +extra_packages() +{ + packages_list= + packages_dir= + $DIALOG --clear \ + --title " Extra packages " \ + --defaultno --yesno \ +" +Do you want to add extra packages ? +" 7 70 + [ $? -eq 0 ] || return + [ -s /var/lib/tazpkg/packages.txt ] || tazpkg recharge + if [ -s /media/cdrom/boot/vmlinuz-$(uname -r) ]; then + cat > /tmp/dialog$$ <> /tmp/dialog$$ + sh /tmp/dialog$$ 2> /tmp/dialog.out$$ + [ $? -eq 0 ] && packages_list="$(cat /tmp/dialog.out$$)" + fi + cat > /tmp/dialog$$ < /tmp/dialog.out$$ + [ $? -eq 0 ] && packages_dir="$(cat /tmp/dialog.out$$)" + rm -f /tmp/dialog$$ /tmp/dialog.out$$ +} + +_install() +{ + extra_packages + $DIALOG --clear \ + --title " SliTaz UMSDOS way installation " \ + --yes-label "Install" --yesno \ +"\nSliTaz will be installed in the subdirectory \\slitaz of the current +DOS/Windows partition. You will see your files from /mnt/dos.\n\n +You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n +To uninstall SliTaz, you have only to remove this directory. +The file \\boot.ini or \\config.sys may be modified too.\n\n +SliTaz may run slowly on 'UMSDOS way' installation due to the +posixovl filesystem. The 'TAZUSB way' installation runs faster.\n\n +To do a traditional installation with disk partitioning, +start SliTaz Live with 'SliTaz RAM boot' menu.\n +" 19 70 + [ $? -eq 0 ] || return + doinstall +} + +readtazbootconf() +{ + kernel="$(sed '/^kernel=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)" + initrd="$(sed '/^initrd=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)" + cmdline="$(sed '/^kernel=/d;/^initrd=/d' $mnt/slitaz/boot/tazboot.cmd)" +} + +bootinstalled() +{ + [ "$(which kexec)" ] || return + [ -x $mnt/slitaz$1 ] || return + [ -s $mnt/slitaz/boot/tazboot.cmd ] || return + readtazbootconf + kexec -l $kernel --initrd $initrd --command-line "$cmdline" --atags + umount $mnt + rm -rf $mnt + umount -d /media/cdrom + kexec -e +} + +mkzip() +{ + device= + packages_list= + packages_dir= + mnt=/tmp/mnt$$ + mkdir -p $mnt + $1 || return + wget -O $mnt/slitaz/boot/grldr http://mirror.slitaz.org/boot/grldr + readtazbootconf + cat > $mnt/slitaz/menu.lst < /dev/null) + [ -s "$file" ] && cat >> $mnt/slitaz/menu.lst < $mnt/slitaz/install.txt < copy \\slitaz\\boot\\grldr \\ +C:\\> copy \\slitaz\\boot\\menu.lst \\ + +2- Remove boot.ini attributes + +C:\\> attrib -r -h -s boot.ini + +3- Append the following line to boot.init + +C:\\grldr="slitaz" + +4- Restore boot.ini attributes + +C:\\> attrib +r +h +s boot.ini + +See http://diddy.boot-land.net/grub4dos/files/README_GRUB4DOS.txt +EOT + ( cd $mnt ; zip -r9 $(basename $ISO .iso) slitaz ) + mv $mnt/*.zip . +} + +install() +{ + windev || return + packages_list= + packages_dir= + _install && bootinstalled /sbin/init + umount $mnt + rm -rf $mnt +} + +inst2zip() +{ + mkzip _install +} + +_installtaz() +{ + $DIALOG --clear \ + --title " SliTaz TAZUSB way installation " \ + --yes-label "Install" --yesno \ +"\nSliTaz will be installed in the subdirectory \\slitaz of the current +DOS/Windows partition. You will see your files from /mnt/dos.\n\n +You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n +To uninstall SliTaz, you have only to remove this directory. +The file \\boot.ini or \\config.sys may be modified too.\n\n +The filesystem is loaded entirely into memory upon boot to +increase responsiveness. Only /home lands on hard disk.\n\n +To do a traditional installation with disk partitioning, +start SliTaz Live with 'SliTaz RAM boot' menu.\n +" 19 70 + [ $? -eq 0 ] || return + doinstall tazusblike +} + +installtaz() +{ + windev || return + packages_list= + packages_dir= + _installtaz && bootinstalled /boot/bzimage + umount $mnt + rm -rf $mnt +} + +insttaz2zip() +{ + mkzip _installtaz +} + +bootiso() +{ + for i in $(ls_r /media/cdrom/boot/rootfs*gz); do + grep -q ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64 + cat $i + n=$((4 - ($(stat -c %s $i) % 4))) + [ $n -eq 4 ] || dd if=/dev/zero bs=1 count=$n + done > /tmp/initrd$$ + kernel=/media/cdrom/boot/bzImage + grep -q ' lm ' /proc/cpuinfo && [ -s ${kernel}64 ] && kernel=${kernel}64 + . /etc/locale.conf + kexec -l $kernel --initrd /tmp/initrd$$ --atags --command-line \ + "root=/dev/null autologin lang=$LANG kmap=$(cat /etc/keymap.conf)" + umount -d /media/cdrom + kexec -e +} + +tazboot() +{ + $DIALOG --clear \ + --title " SliTaz bootloader for DOS " \ + --yes-label "Install" --yesno \ +"\nThe file TAZBOOT.EXE will be created in the top directory. It supports +any linux kernel, multiple initramfs, a kernel command line and +an ISO image file loopback (retrieves files from an ISO file).\n\n +Usage: tazboot.exe [[@commands]|[kernel=] +[initrd=[,...]] [bootfrom=] cmdline args ...]\n\n +Defaults: tazboot @tazboot.cmd or tazboot kernel=bzImage auto\n\n\ +Examples for tazboot.cmd:\n\n\ + bootfrom=\\isos\\slitaz-4.0.iso\n\ + kernel=boot/bzImage\n\ + initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\ + rw root=/dev/null autologin\n\n\ + kernel=\\slitaz\\vmlinuz root=/dev/sda5 ro\n\n +Unlike GRUB4DOS, it doesn't require unfragmented ISO image files.\n +" 24 78 + [ $? -eq 0 ] || return + gettazboot tazboot.exe +} + +md5() +{ + dotwait "Checking files" + ( cd /media/cdrom ; ${1:-md5sum -c md5sum*} ) > /tmp/data + rm -f /tmp/wait + $DIALOG --clear \ + --title " Checked files " \ + --textbox /tmp/data 24 78 + rm -f /tmp/data +} + +gotcdfile() +{ + for i in "/media/cdrom/$1" "/media/cdrom/*/$1" \ + "/media/cdrom/*/isolinux/$1" ; do + file=$(ls $i 2> /dev/null | sed q) + [ -s "$file" ] && break + done +} + +sha() +{ + gotcdfile 'sha*sum*' + sha=$(basename $file) + md5 "${sha%sum*}sum -c ${file#/media/cdrom/}" +} + +readme() +{ + gotcdfile 'README*' + $DIALOG --clear \ + --title " Readme " \ + --textbox $file 24 78 +} + +bzimage() +{ + $DIALOG --clear \ + --title " Create linux.exe ? " \ + --yes-label "Install" --yesno \ +"\nLinux.exe launches the linux kernel under DOS (in real mode only). +The cmdline arguments are supported except initrd=, +vga= (you can try 'rdev -v') and mem= (partially). +\nExample:\nC:\\> linux.exe root=/dev/hda2 ro panic=60\n +" 12 70 + [ $? -eq 0 ] || return + cp /media/cdrom/boot/bzImage linux.exe +} + +memtest() +{ + $DIALOG --clear \ + --title " Create memtest.exe ? " \ + --yes-label "Install" --yesno \ +"\nMemtest86 is a thorough, stand alone memory test for x86 architecture +computers. BIOS based memory tests are a quick, cursory check and often +miss many of the failures that are detected by Memtest86.\n +" 12 70 + [ $? -eq 0 ] && gotcdfile 'memtest*' && cp $file memtest.exe +} + +mkfat12() +{ + [ $(($(get 0 $1) - 0x5A4D)) -eq 0 ] || return + J=$(($(get 3 $1 1) + 0x02)) + R=$((1 + $(get 497 $1 1) + 1 + ($(get 500 $1)-1)/32)) + [ $R -lt 2500 ] || return + [ $((($(get 500 $1)-1) & 31)) -lt 30 ] && + ddq if=$file bs=32 count=1 seek=$(($R*16 - 1)) of=/dev/fd0 + G="18 0 2 0 0 0 0 0" + [ $J -gt 25 ] || G="" + F=0 + for i in 1 2 3; do + F=$((((2880-$R-$F-$F)*3+1023)/1024)) + done + bytes2bin 0xEB $J 0x90 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 \ + 0 2 2 $(($R%256)) $(($R/256)) 2 64 0 64 11 0xF0 $F 0 \ + $G | ddq bs=1 of=/dev/fd0 + ddq if=/dev/zero bs=512 count=$((4+$F+$F)) seek=$R of=/dev/fd0 + for i in $R $(($R+$F)) ; do + bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0 + done + echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0 +} + +mkfloppy() +{ + dotwait "Create a $(basename $1) boot floppy" + ddq if=$1 of=/dev/fd0 + mkfat12 $1 + rm -f /tmp/wait +} + +fdmemtest() +{ + $DIALOG --clear \ + --title " Create a Memtest86 boot floppy " \ + --yes-label "Create floppy" --yesno \ +"\nMemtest86 is a thorough, stand alone memory test for x86 architecture +computers. BIOS based memory tests are a quick, cursory check and often +miss many of the failures that are detected by Memtest86.\n\n +Please insert a blank disk in floppy drive.\n +" 12 70 + [ $? -eq 0 ] && gotcdfile 'memtest*' && mkfloppy $file +} + +pxe() +{ + gotcdfile '?pxe' + $DIALOG --clear \ + --title " Create $(basename $file).exe ? " \ + --yes-label "Install" --yesno \ +"\nBoot your operating system from the internet and enjoy a full system +working entirely in RAM with speed and stability in mind. The Linux Kernel +and the complete SliTaz compressed root filesystem will be loaded into RAM +from the Web using PXE and HTTP protocols.\n +" 12 70 + [ $? -eq 0 ] || return + cp $file $(basename $file).exe +} + +fdpxe() +{ + $DIALOG --clear \ + --title " Create a SliTaz Web boot floppy " \ + --yes-label "Create floppy" --yesno \ +"\nBoot your operating system from the internet and enjoy a full system +working entirely in RAM with speed and stability in mind. The Linux Kernel +and the complete SliTaz compressed root filesystem will be loaded into RAM +from the Web using PXE and HTTP protocols.\n\n +Please insert a blank disk in floppy drive.\n +" 12 70 + [ $? -eq 0 ] && gotcdfile '?pxe' && mkfloppy $file +} + +gotposixovl() +{ + mount.posixovl 2>&1 | grep -qi usage && + echo -en "\"$1\" \"$2\"" +} + +gotposixovlzip() +{ + [ "$(which zip)" ] && gotposixovl "$1" "$2" +} + +xfile() +{ + [ "$(which $1)" ] && echo -en "\"$2\" \"$3\"" +} + +cdfile() +{ + gotcdfile "$1" && echo -en "\"$2\" \"$3\"" +} + +cdfilex() +{ + [ "$(which kexec)" ] && cdfile "$@" +} + +cdfilef() +{ + [ -e /sys/block/fd0 ] && cdfile "$@" +} + +cdexe() +{ + gotcdfile "$1" && + [ $(get 0 $file 2>/dev/null || echo 0) -eq 23117 ] && + echo -en "\"$2\" \"$3\"" +} + +misspkg() +{ + for i in zip kexec-tools posixovl ; do + [ -d /var/lib/tazpkg/installed/$i/ ] && continue + [ "$1" != "install" ] && + echo -en "\"$1\" \"$2\"" && return + tazpkg get-install $i + done +} + +missing() +{ + misspkg install +} + +ishybrid() +{ + C=$((2048*$(get $(((17*2048) + 71)) $ISO 4))) + [ $(get $C $ISO 4) -eq 1 ] || return + [ $(get $(($C+30)) $ISO 4) -eq $((0x88AA55)) ] || return + C=$((2048*$(get $(($C+40)) $ISO 4))) + [ $(get $(($C+64)) $ISO 4) -eq 1886961915 ] && + echo -en "\"$1\" \"$2\"" +} + +isiso() +{ + [ $(get 32769 $ISO 4) -eq 808469571 ] && + echo -en "\"$1\" \"$2\"" +} + +gotisomd5() +{ + [ "$(which md5sum 2> /dev/null)" ] && + [ $(get 0 $ISO) -eq 23117 ] && + [ $(get 18 $ISO) -ne 0 ] && echo -en "\"$1\" \"$2\"" +} + +isomd5() +{ + dotwait "Checking iso image" + [ "$(ddq if=$ISO bs=2k skip=16 \ + count=$(echo $(get 32848 $ISO 4)) | md5sum)" == \ + "$(ddq if=$ISO bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \ + sed 's/ //g') -" ] && echo "OK" || echo "ERROR" + echo -en "\rChecking iso hybrid boot..." + n=$(($(get 2 $ISO)-1+($(get 4 $ISO)-1)*512)) + if [ $n -lt 40000 -a $n -gt 32768 ]; then + s=$(get 0 $ISO 2 $n | awk '{ i+= $0 } END { print i }') + [ $(((1+$s+$(get $(($n+1)) $ISO 1)) % 65536)) -eq 0 ] && + echo "OK" || echo "ERROR" + fi + rm -f /tmp/wait + echo -e "\rPress RETURN to continue." + read n +} + +usbdev() +{ + dotwait "Wait 5 seconds for USB devices" + sleep 5 + rm -f /tmp/wait + DEV="$(grep -l 1 /sys/block/*/removable | \ + sed 's|/sys/block/\(.*\)/removable|\1|')" + grep -qs 1 /sys/block/$DEV/ro && return + [ "$DEV" ] || return + cat > /tmp/dialog$$ < /dev/null)\" " + done) \ + +EOT + exec 3>&1 + device=$(. /tmp/dialog$$ 2>&1 1>&3) + rm -f /tmp/dialog$$ + retval=$? + exec 3>&- + rm -f /tmp/dialog$$ + [ $retval -eq 0 ] +} + +tazusbmsg() +{ + [ "$(which tazusb 2> /dev/null)" ] || return + echo "You should choose 'USB key read/write installation' to be +able to save the package updates or your own configuration and data files.\n\n" +} + +usbbootkey() +{ + $DIALOG --clear \ + --title " Create a USB boot key " \ + --yes-label "Continue" --yesno \ +"\nThe USB key will be used like a CD-ROM. You will not be able to write +any data on the boot partition.\n\n +An extra FAT32 partition will be created with the remaining free space.\n\n +$(tazusbmsg)Please plug your USB stick in now.\n +" 16 70 + [ $? -eq 0 ] || return + usbdev || return + + # perform dd in progess bar + max=$(($(stat -c %s $ISO)/2048)) + i=0; ddq if=$ISO bs=1024k | ( + while ddq bs=1024k count=1 ; do + i=$(($i + 1)) + [ $i -gt $max ] && break + echo $((($i*100)/$max)) | dialog --gauge \ + " The ISO image transfer can be long. Please wait..." \ + 6 70 0 > /dev/tty 2>&1 + done ) > $device + + # partition + fat32 format for the remining space + get 446 $device 2 12 | xargs echo | { read dx cx ol oh ll lh + if [ $dx -eq $((0x3F17)) ]; then + cx=$(($cx & 0xFF00)) + ofs=$(($ll+($lh<<16))) + n=$(($(cat /sys/block/${device#/dev/}/size)-$ofs)) + m=$(($cx+($n/8))) + [ $m -gt $((0x3FF00)) ] && m=$((0x3FF00)) + m=$((($m & 0xFF00)+(($m>>16)<<6))) + words2bin 0 $((0x101+$cx)) 0x3F0B $((32+$m)) \ + $ll $lh $(($n & 0xFFFF)) $(($n >> 16)) | \ + ddq bs=1 seek=446 of=$device + if [ "$(which mkdosfs 2> /dev/null)" ]; then + losetup -o $((512*$ofs)) /dev/loop2 $device + mkdosfs -n "SLITAZ BOOT" /dev/loop2 + words2bin $(($ofs & 0xFFFF)) $(($ofs >> 16)) | \ + ddq bs=1 seek=28 of=/dev/loop2 + losetup -d /dev/loop2 + fi + fi ; } +} + +usbkey() +{ + $DIALOG --clear \ + --title " Create a SliTaz USB key " \ + --yes-label "Continue" --yesno \ +"\nUnlike a hard drive install, the filesystem is kept in a compressed +rootfs.gz. The filesystem is loaded entirely into memory upon boot. +This should increase responsiveness, protect the filesystem against +accidental corruption and reduce read/writes to the USB drive. +Once setup, the tazusb utility can rewrite the root filesystem +with any changes you have made since booting up, +giving the effective benefits of a hard drive install.\n\n +/home is mounted on boot using the UUID of your particular flash drive. +Unlike a device name, the UUID has the benefit of never changing from machine +to machine.\n\n +Please plug your USB stick in now.\n +" 19 70 + [ $? -eq 0 ] || return + usbdev || return + exec 3>&1 + format=`$DIALOG --clear \ + --title " Select the filesystem " \ + --radiolist "\nPlease select the filesystem type to create.\n\n\ +The filesystem creation will erase all the data \ +in the USB key." 14 70 4 \ + "none" "Do not erase the USB key" on \ + "ext3" "Ext3 journaling filesystem" off \ + "ext2" "Ext2 filesystem" off \ + "fat32" "Windows FAT32 filesystem" off \ + 2>&1 1>&3` + retval=$? + exec 3>&- + [ $retval -eq 0 ] || return + [ "$format" != "none" ] && tazusb format $device "SliTaz" $format + tazusb gen-iso2usb $ISO $device +} + +dokexec() +{ + kexec -l $file + umount -d /media/cdrom + kexec -e +} + +runmemtest() +{ + gotcdfile 'memtest*' && dokexec +} + +runpxe() +{ + gotcdfile '?pxe' && dokexec +} + +quit() +{ + umount -d /media/cdrom + exit +} + +ISO="$1" +[ -z "$(isiso 2> /dev/null)" ] && echo "Usage : $0 file.iso" && exit 1 +mount -o loop,ro $ISO /media/cdrom + +while true; do + cat > /tmp/dialog$$ <&1 + value=$(. /tmp/dialog$$ 2>&1 1>&3) + retval=$? + exec 3>&- + rm -f /tmp/dialog$$ + [ $retval -eq 0 ] || continue + $value +done