wok rev 17635
syslinux-tools: add taziso
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Feb 14 18:17:26 2015 +0100 (2015-02-14) |
parents | f940e42dac11 |
children | 77c3484cda94 |
files | syslinux-tools/receipt syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/taziso |
line diff
1.1 --- a/syslinux-tools/receipt Sat Feb 14 17:35:42 2015 +0200 1.2 +++ b/syslinux-tools/receipt Sat Feb 14 18:17:26 2015 +0100 1.3 @@ -21,5 +21,6 @@ 1.4 cp -a $src/iso2exe/isohybrid.exe $fs/usr/share/boot 1.5 cp -a $src/iso2exe/meminfo.exe $fs/usr/share/boot 1.6 cp -a $src/iso2exe/tazboot.exe $fs/usr/share/boot 1.7 + cp -a $src/iso2exe/taziso $fs/usr/bin 1.8 find $fs/usr -exec chown root.root {} \; 1.9 }
2.1 --- a/syslinux/stuff/iso2exe/init Sat Feb 14 17:35:42 2015 +0200 2.2 +++ b/syslinux/stuff/iso2exe/init Sat Feb 14 18:17:26 2015 +0100 2.3 @@ -298,12 +298,12 @@ 2.4 sleep 5 2.5 return 1 2.6 fi 2.7 - dowait "Install root filesystem in /slitaz.." 2.8 + dotwait "Install root filesystem in /slitaz.." 2.9 if [ "$1" ]; then 2.10 if [ -d /media/cdrom/fs ]; then 2.11 ( cd /mnt/slitaz/fs; find | cpio -o -H newc ) | gzip -9 2.12 else 2.13 - ls_r /media/cdrom/boot/rootfs* | xargs cat 2.14 + ls_r /media/cdrom/boot/rootfs*gz | xargs cat 2.15 fi > /mnt/slitaz/boot/rootfs.gz 2.16 tazusbinitfs /mnt/slitaz/boot/rootfs.gz 2.17 initrd=rootfs.gz 2.18 @@ -316,18 +316,18 @@ 2.19 [ -s $(basename $i) ] && continue 2.20 cpio -i $i 2.21 done 2.22 - for i in $(ls_r /media/cdrom/boot/rootfs*); do 2.23 + for i in $(ls_r /media/cdrom/boot/rootfs*gz); do 2.24 mount -o loop,ro $i /sqfs/mnt 2.25 cp -a /sqfs/mnt/. /mnt/slitaz 2.26 umount -d /sqfs/mnt 2.27 done 2.28 else 2.29 - for i in $(ls_r /media/cdrom/boot/rootfs*); do 2.30 + for i in $(ls_r /media/cdrom/boot/rootfs*gz); do 2.31 uncpio $i /mnt/slitaz 2.32 done 2.33 fi 2.34 - cp -a /etc/locale.conf /tmp/slitaz/etc 2> /dev/null 2.35 - cp -a /etc/keymap.conf /tmp/slitaz/etc 2> /dev/null 2.36 + cp -a /etc/locale.conf /mnt/slitaz/etc 2> /dev/null 2.37 + cp -a /etc/keymap.conf /mnt/slitaz/etc 2> /dev/null 2.38 mkinitrd /mnt/slitaz/boot/initrd 2.39 initrd=initrd 2.40 extraargs="mount=$(getuuid) subroot=slitaz" 2.41 @@ -413,7 +413,7 @@ 2.42 if [ -d /media/cdrom/fs ]; then 2.43 cp -a /media/cdrom/fs/. / 2.44 else 2.45 - for i in $(ls_r /media/cdrom/boot/rootfs*); do 2.46 + for i in $(ls_r /media/cdrom/boot/rootfs*gz); do 2.47 uncpio $i 2.48 done 2.49 fi 2.50 @@ -466,8 +466,8 @@ 2.51 2.52 gotcdfile() 2.53 { 2.54 - for i in /media/cdrom/$1 /media/cdrom/*/$1 \ 2.55 - /media/cdrom/*/isolinux/$1 ; do 2.56 + for i in "/media/cdrom/$1" "/media/cdrom/*/$1" \ 2.57 + "/media/cdrom/*/isolinux/$1" ; do 2.58 file=$(ls $i 2> /dev/null | sed q) 2.59 [ -s "$file" ] && break 2.60 done 2.61 @@ -475,14 +475,14 @@ 2.62 2.63 sha() 2.64 { 2.65 - gotcdfile sha*sum* 2.66 + gotcdfile "sha*sum*" 2.67 sha=$(basename $file) 2.68 md5 "${sha%sum*}sum -c ${file#/media/cdrom/}" 2.69 } 2.70 2.71 readme() 2.72 { 2.73 - gotcdfile README* 2.74 + gotcdfile "README*" 2.75 $DIALOG --clear \ 2.76 --title " Readme " \ 2.77 --textbox $file 24 78 2.78 @@ -518,7 +518,7 @@ 2.79 computers. BIOS based memory tests are a quick, cursory check and often 2.80 miss many of the failures that are detected by Memtest86.\n 2.81 " 12 70 2.82 - [ $? -eq 0 ] && gotcdfile memtest* && cp $file /mnt/memtest.exe 2.83 + [ $? -eq 0 ] && gotcdfile "memtest*" && cp $file /mnt/memtest.exe 2.84 } 2.85 2.86 mkfat12() 2.87 @@ -563,12 +563,12 @@ 2.88 miss many of the failures that are detected by Memtest86.\n\n 2.89 Please insert a blank disk in floppy drive.\n 2.90 " 12 70 2.91 - [ $? -eq 0 ] && gotcdfile memtest* && mkfloppy $file 2.92 + [ $? -eq 0 ] && gotcdfile "memtest*" && mkfloppy $file 2.93 } 2.94 2.95 pxe() 2.96 { 2.97 - gotcdfile ?pxe 2.98 + gotcdfile "?pxe" 2.99 $DIALOG --clear \ 2.100 --title " Create $(basename $file).exe ? " \ 2.101 --yes-label "Install" --yesno \ 2.102 @@ -592,7 +592,7 @@ 2.103 from the Web using PXE and HTTP protocols.\n\n 2.104 Please insert a blank disk in floppy drive.\n 2.105 " 12 70 2.106 - [ $? -eq 0 ] && gotcdfile ?pxe && mkfloppy $file 2.107 + [ $? -eq 0 ] && gotcdfile "?pxe" && mkfloppy $file 2.108 } 2.109 2.110 gotposixovl() 2.111 @@ -648,21 +648,24 @@ 2.112 gotisomd5() 2.113 { 2.114 [ "$(which md5sum 2> /dev/null)" ] && 2.115 - [ $(get 18 /dev/loop0) -ne 0 ] && echo -en "\"$1\" \"$2\"" 2.116 + [ $(get 0 /mnt/$ISO) -eq 23117 ] && 2.117 + [ $(get 18 /mnt/$ISO) -ne 0 ] && echo -en "\"$1\" \"$2\"" 2.118 } 2.119 2.120 isomd5() 2.121 { 2.122 dotwait "Checking iso image" 2.123 - [ "$(ddq if=/dev/loop0 bs=2k skip=16 \ 2.124 - count=$(echo $(get 32848 /dev/loop0 4)) | md5sum)" == \ 2.125 - "$(ddq if=/dev/loop0 bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \ 2.126 + [ "$(ddq if=/mnt/$ISO bs=2k skip=16 \ 2.127 + count=$(echo $(get 32848 /mnt/$ISO 4)) | md5sum)" == \ 2.128 + "$(ddq if=/mnt/$ISO bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \ 2.129 sed 's/ //g') -" ] && echo "OK" || echo "ERROR" 2.130 - echo -en "\rChecking iso hybrid boot" 2.131 - n=$(($(get 2 /dev/loop0)-1+($(get 4 /dev/loop0)-1)*512)) 2.132 - s=$(get 0 /dev/loop0 2 $n | awk '{ i+= $0 } END { print i }') 2.133 - [ $(((1+$s+$(get $(($n+1)) /dev/loop0 1)) % 65536)) -eq 0 ] && 2.134 - echo "OK" || echo "ERROR" 2.135 + echo -en "\rChecking iso hybrid boot..." 2.136 + n=$(($(get 2 /mnt/$ISO)-1+($(get 4 /mnt/$ISO)-1)*512)) 2.137 + if [ $n -lt 40000 -a $n -gt 32768 ]; then 2.138 + s=$(get 0 /mnt/$ISO 2 $n | awk '{ i+= $0 } END { print i }') 2.139 + [ $(((1+$s+$(get $(($n+1)) /mnt/$ISO 1)) % 65536)) -eq 0 ] && 2.140 + echo "OK" || echo "ERROR" 2.141 + fi 2.142 rm -f /tmp/wait 2.143 echo -e "\rPress RETURN to continue." 2.144 read n 2.145 @@ -878,12 +881,12 @@ 2.146 2.147 runmemtest() 2.148 { 2.149 - gotcdfile memtest* && dokexec 2.150 + gotcdfile "memtest*" && dokexec 2.151 } 2.152 2.153 runpxe() 2.154 { 2.155 - gotcdfile ?pxe && dokexec 2.156 + gotcdfile "?pxe" && dokexec 2.157 } 2.158 2.159 shell() 2.160 @@ -919,10 +922,10 @@ 2.161 $(xfile tazlocale "tazlocale" "Select locale (${locale:-none})") \ 2.162 $(cdfile boot/bzImage "live" "Linux RAM boot (full desktop)") \ 2.163 "text" "Linux RAM boot" \ 2.164 -$(cdfile README* "readme" "Show the README file") \ 2.165 +$(cdfile "README*" "readme" "Show the README file") \ 2.166 $(gotisomd5 "isomd5" "Check the ISO image") \ 2.167 -$(cdfile md5sum* "md5" "Check the ISO files") \ 2.168 -$(cdfile sha*sum* "sha" "Check the ISO files") \ 2.169 +$(cdfile "md5sum*" "md5" "Check the ISO files") \ 2.170 +$(cdfile "sha*sum*" "sha" "Check the ISO files") \ 2.171 $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \ 2.172 $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \ 2.173 $(xfile tazusb "usbkey" "USB key read/write installation") \ 2.174 @@ -930,12 +933,12 @@ 2.175 $(fddata "fdbootstrap" "Create a floppy bootstrap") \ 2.176 "tazboot" "Get tazboot.exe Linux loader" \ 2.177 $(cdexe boot/bzImage "bzimage" "Get linux DOS/EXE file") \ 2.178 -$(cdexe memtest* "memtest" "Get Memtest86 DOS/EXE file") \ 2.179 -$(cdfilef memtest* "fdmemtest" "Create a Memtest86 boot floppy") \ 2.180 -$(cdfilex memtest* "runmemtest" "Start Memtest86") \ 2.181 -$(cdexe ?pxe "pxe" "Get SliTaz Web boot DOS/EXE utility") \ 2.182 -$(cdfilef ?pxe "fdpxe" "Create a SliTaz Web boot floppy") \ 2.183 -$(cdfilex ?pxe "runpxe" "Start the SliTaz Web boot utility") \ 2.184 +$(cdexe "memtest*" "memtest" "Get Memtest86 DOS/EXE file") \ 2.185 +$(cdfilef "memtest*" "fdmemtest" "Create a Memtest86 boot floppy") \ 2.186 +$(cdfilex "memtest*" "runmemtest" "Start Memtest86") \ 2.187 +$(cdexe "?pxe" "pxe" "Get SliTaz Web boot DOS/EXE utility") \ 2.188 +$(cdfilef "?pxe" "fdpxe" "Create a SliTaz Web boot floppy") \ 2.189 +$(cdfilex "?pxe" "runpxe" "Start the SliTaz Web boot utility") \ 2.190 $(xfile reboot "restart" "Restart the computer") \ 2.191 $(xfile poweroff "stop" "Power off") \ 2.192 "bootlog" "Linux boot messages" \
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/syslinux/stuff/iso2exe/taziso Sat Feb 14 18:17:26 2015 +0100 3.3 @@ -0,0 +1,909 @@ 3.4 +#!/bin/sh 3.5 + 3.6 +[ $(id -u) -eq 0 ] || exec su -c "$0 $@" 3.7 + 3.8 +DIALOG=dialog 3.9 + 3.10 +ddq() 3.11 +{ 3.12 + dd $@ 2> /dev/null 3.13 +} 3.14 + 3.15 +get() 3.16 +{ 3.17 + od -v -j $1 -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An $2 2>/dev/null || 3.18 + hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %d\n\"" $2 3.19 +} 3.20 + 3.21 +bytes2bin() 3.22 +{ 3.23 + for i in $@ ; do 3.24 + printf '\\\\x%02X' $(($i&255)) 3.25 + done | xargs echo -en 3.26 +} 3.27 + 3.28 +words2bin() 3.29 +{ 3.30 + for i in $@ ; do 3.31 + printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255)) 3.32 + done | xargs echo -en 3.33 +} 3.34 + 3.35 +gettazboot() 3.36 +{ 3.37 + echo "Creating $(basename $1) ..." 3.38 + if [ $(get 0 $ISO) -eq 23117 ]; then 3.39 + O=$(($(get 66 $ISO) - 0xC0)) 3.40 + L=$(($(get 20 $ISO) - 0xC0 - $(get 24 $ISO) - $O)) 3.41 + S=$((32+$L)) 3.42 + P=$((($S+511)/512)) 3.43 + E=$((4096-(32*$P))) 3.44 + words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) \ 3.45 + -2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1 3.46 + ddq bs=1 count=$L skip=$(echo $O) if=$ISO >> $1 3.47 + else 3.48 + wget -O $1 http://mirror.slitaz.org/boot/tazboot.exe 3.49 + fi 3.50 +} 3.51 + 3.52 +uncpio() 3.53 +{ 3.54 + [ -s "$1" ] || return 3.55 + echo -en "\n Extracting $(basename $1) ..." 3.56 + case $(get 0 $1) in 3.57 + *35615) ( zcat || gunzip ) ;; 3.58 + *14333) unxz ;; 3.59 + *\ 93) unlzma ;; 3.60 + *) cat ;; 3.61 + esac < $1 | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 ) 3.62 +} 3.63 + 3.64 +dotwait() 3.65 +{ 3.66 + echo -n "${1:-Install filesystem}.." 3.67 + touch /tmp/wait 3.68 + while [ -e /tmp/wait ]; do 3.69 + echo -n "." > /dev/tty 3.70 + sleep 1 3.71 + done & 3.72 +} 3.73 + 3.74 +getuuid() 3.75 +{ 3.76 + dev=$(mount | sed "/ $(echo $mnt | sed 's|/|\\/|g') /!d;s/ .*//;s|/dev/||;q") 3.77 + [ "$dev" ] && 3.78 + blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/" || 3.79 + echo "/dev/hda1" 3.80 +} 3.81 + 3.82 +tazusbinitfs() 3.83 +{ 3.84 + PAD=$(($(stat -c %s $1) % 4)) 3.85 + [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1 3.86 + mkdir -p /tmp/fs$$/etc /tmp/fs$$/lib /tmp/fs$$/home 3.87 + cp -a /etc/locale.conf /tmp/fs$$/etc 2> /dev/null 3.88 + cp -a /etc/keymap.conf /tmp/fs$$/etc 2> /dev/null 3.89 + cat > /tmp/fs$$/init1 <<EOT 3.90 +#!/bin/sh 3.91 +sed -i 's|sbin/init|init2|' /init 3.92 +exec /init 3.93 +EOT 3.94 + cat > /tmp/fs$$/init2 <<EOT 3.95 +#!/bin/sh 3.96 + 3.97 +mount -t proc /proc /proc 3.98 +for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2 3.99 +v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2> /dev/null) 3.100 +mount / -o remount,rw 3.101 +mkdir /mnt/dos 3.102 +rm -f /cmdline 2> /dev/null 3.103 +mount / -o remount,ro 3.104 +mnt=/mnt/dos/\${v#*/} 3.105 +dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q') 3.106 +echo "Mount \$dev in /mnt/dos for \$v..." | tee -a /run/boot.log 3.107 +mount \$dev /mnt/dos 3.108 +if [ ! -d /mnt/dos/slitaz ]; then 3.109 + umount /mnt/dos 2> /dev/null 3.110 + (blkid /dev/[sh]d* || blkid) | while read dev line; do 3.111 + case "\$line" in 3.112 + *ntfs*|*vfat*|*msdos*) ;; 3.113 + *) continue ;; 3.114 + esac 3.115 + mount \${dev%:} /mnt/dos 3.116 + [ -d /mnt/dos/slitaz ] && break 3.117 + umount /mnt/dos 3.118 + done 3.119 +fi 3.120 +mount.posixovl -F \$mnt -- -oallow_other -odefault_permissions -osuid 3.121 +mount --bind \$mnt /home 3.122 +umount /proc 3.123 +exec /sbin/init 3.124 +EOT 3.125 + chmod 755 /tmp/fs$$/init? 3.126 + ( cd /tmp/fs$$ ; find * | cpio -o -H newc ) | gzip -9 >> $1 3.127 + rm -rf /tmp/fs$$ 3.128 +} 3.129 + 3.130 +mkinitrd() 3.131 +{ 3.132 + echo -en "\nCreating $(basename $1) " 3.133 + fs=/tmp/fs$$ 3.134 + for i in bin lib dev proc tmp mnt etc ; do 3.135 + mkdir -p $fs/$i 3.136 + done 3.137 + for i in /dev/console /dev/null /dev/tty /dev/tty0 /dev/tty1 /dev/tty2 \ 3.138 + /dev/fuse /dev/hd* /dev/sd* ; do 3.139 + cp -a $2$i $fs/dev/ 3.140 + done 3.141 + for i in /bin/busybox $(which mount.posixovl) $(which blkid); do 3.142 + cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \ 3.143 + sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') $fs/lib 3.144 + cp $i $fs/bin 3.145 + done 3.146 + cp -a /lib/ld-* $fs/lib 3.147 + for i in $(busybox | sed '/Current/,$!d'); do 3.148 + [ -e $fs/bin/${i%,} ] || ln -s busybox $fs/bin/${i%,} 3.149 + done 3.150 + ln -s /proc/mounts $fs/etc/mtab 3.151 + sed 's/ .*//' /proc/modules | while read mod ; do 3.152 + find /lib/modules/ | grep $mod.ko | \ 3.153 + sed 's|.*|cp & $fs/lib|' | sh 3.154 + done 3.155 + cat > $fs/init <<EOT 3.156 +#!/bin/sh 3.157 + 3.158 +arg() 3.159 +{ 3.160 + grep -q \$1 /proc/cmdline && 3.161 + val="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" < /proc/cmdline)" && 3.162 + echo "\$2 \$val" 3.163 +} 3.164 + 3.165 +mount -t proc /proc /proc 3.166 + arg debug "shell" && debug=true && set -x 3.167 +for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2 3.168 +arg mount "Mount device" 3.169 +mount \$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q') /mnt 3.170 +arg subroot "Change root to directory" 3.171 +if [ -d /mnt/\$val ]; then 3.172 + umount /mnt 2> /dev/null 3.173 + (blkid /dev/[sh]d* || blkid) | while read dev line; do 3.174 + case "\$line" in 3.175 + *ntfs*|*vfat*|*msdos*) ;; 3.176 + *) continue ;; 3.177 + esac 3.178 + mount \${dev%:} /mnt 3.179 + [ -d /mnt/\$val ] && break 3.180 + umount /mnt 3.181 + done 3.182 +fi 3.183 +mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid 3.184 +mount --bind /mnt /mnt/\$val/mnt/dos 3.185 +mount -o size=0 -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val 3.186 +LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q) 3.187 +export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib 3.188 + [ "$debug" = "true" ] && sh 3.189 +umount /proc 3.190 +exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init 3.191 +EOT 3.192 + chmod +x $fs/init 3.193 + ( cd $fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null 3.194 + rm -rf $fs /tmp/wait 3.195 +} 3.196 + 3.197 +ls_r() 3.198 +{ 3.199 + ls -r $@ 2> /dev/null || ls $@ 3.200 +} 3.201 + 3.202 +doinstall() 3.203 +{ 3.204 + mkdir -p $mnt/slitaz/boot $mnt/slitaz/mnt/dos 3.205 + if ! mount.posixovl -F $mnt/slitaz -- \ 3.206 + -oallow_other -odefault_permissions -osuid; then 3.207 + echo "Can't install SliTaz. Abort." 3.208 + sleep 5 3.209 + return 1 3.210 + fi 3.211 + dotwait "Install root filesystem in /slitaz.." 3.212 + if [ "$1" ]; then 3.213 + ls_r /media/cdrom/boot/rootfs*gz | \ 3.214 + xargs cat > $mnt/slitaz/boot/rootfs.gz 3.215 + tazusbinitfs $mnt/slitaz/boot/rootfs.gz 3.216 + initrd=rootfs.gz 3.217 + extraargs="/home=$(getuuid)/slitaz rdinit=/init1" 3.218 + else 3.219 + for i in $(ls_r /media/cdrom/boot/rootfs*gz); do 3.220 + uncpio $i $mnt/slitaz 3.221 + done 3.222 + for i in $packages_list; do 3.223 + tazpkg get-install $i --root=$mnt/slitaz 3.224 + done 3.225 + for i in $packages_dir/*.tazpkg; do 3.226 + [ -s "$i" ] && 3.227 + tazpkg install $i --root=$mnt/slitaz 3.228 + done 3.229 + cp -a /etc/locale.conf $mnt/slitaz/etc 2> /dev/null 3.230 + cp -a /etc/keymap.conf $mnt/slitaz/etc 2> /dev/null 3.231 + mkinitrd $mnt/slitaz/boot/initrd $mnt/slitaz 3.232 + initrd=initrd 3.233 + extraargs="mount=$(getuuid) subroot=slitaz" 3.234 + fi 3.235 + echo -en "\nInstall boot files..." 3.236 + for i in /media/cdrom/boot/bzImage /media/cdrom/boot/*pxe* \ 3.237 + /media/cdrom/boot/isolinux/he* /media/cdrom/boot/isolinux/opt* \ 3.238 + /media/cdrom/README /media/cdrom/boot/memtest* ; do 3.239 + [ -s $i ] && cp $i $mnt/slitaz/boot 3.240 + done 3.241 + for i in $mnt/slitaz/boot/memtest $mnt/slitaz/boot/*pxe* ; do 3.242 + [ $(get 0 $i 2> /dev/null || echo 0) -eq 23117 ] && 3.243 + mv $i $i.exe 3.244 + done 3.245 + gettazboot $mnt/slitaz/boot/tazboot.exe 3.246 + unix2dos > $mnt/slitaz/boot/tazboot.cmd <<EOT 3.247 +kernel=/slitaz/boot/bzimage 3.248 +initrd=/slitaz/boot/$initrd 3.249 +rw root=/dev/null $extraargs autologin 3.250 +EOT 3.251 + unix2dos $mnt/slitaz/boot/he* $mnt/slitaz/boot/opt* \ 3.252 + $mnt/slitaz/boot/README 3.253 + [ -d $mnt/slitaz/usr/sbin -a ! -x $mnt/slitaz/usr/sbin/mount.posixovl ] && 3.254 + cp $(which mount.posixovl) $mnt/slitaz/usr/sbin 3.255 + rm -f /tmp/wait 3.256 + umount $mnt/slitaz 3.257 + return 0 3.258 +} 3.259 + 3.260 +windev() 3.261 +{ 3.262 + DEV="$(blkid | grep -iE "(msdos|vfat|ntfs)" | sed 's/:.*//;s|/dev/||')" 3.263 + [ "$DEV" ] || return 3.264 + cat > /tmp/dialog$$ <<EOT 3.265 +$DIALOG --clear \ 3.266 + --title " Select your Windows partition " \ 3.267 + --menu "\nPlease select the Windows partition according to its known size. 3.268 +The datas will be kept untouched.\n" \ 3.269 + 17 70 8 \ 3.270 + $(for i in $DEV ; do 3.271 + label="$(blkid | sed "/$i:/!d;s/.*://;s/[^ ]*UUID=[^ ]* //g;s/LABEL=//")" 3.272 + echo -n "/dev/$i \"$(($(cat /sys/block/*/$i/size)/2048))MB $label\" " 3.273 + done) 3.274 +EOT 3.275 + exec 3>&1 3.276 + [ $? -eq 0 ] || return 3.277 + device=$(. /tmp/dialog$$ 2>&1 1>&3) 3.278 + exec 3>&- 3.279 + rm -f /tmp/dialog$$ 3.280 + mnt=/tmp/mnt$$ 3.281 + mkdir -p $mnt && mount $device $mnt 3.282 +} 3.283 + 3.284 +extra_packages() 3.285 +{ 3.286 + packages_list= 3.287 + packages_dir= 3.288 + $DIALOG --clear \ 3.289 + --title " Extra packages " \ 3.290 + --defaultno --yesno \ 3.291 +" 3.292 +Do you want to add extra packages ? 3.293 +" 7 70 3.294 + [ $? -eq 0 ] || return 3.295 + [ -s /var/lib/tazpkg/packages.txt ] || tazpkg recharge 3.296 + if [ -s /media/cdrom/boot/vmlinuz-$(uname -r) ]; then 3.297 + cat > /tmp/dialog$$ <<EOT 3.298 +$DIALOG --clear \ 3.299 + --title " Select the packages " \ 3.300 + --separate-output \ 3.301 + --cancel-label "Skip" \ 3.302 + --checklist "Please select the packages you want to install. Try with the first letter." \ 3.303 + 23 78 20 \\ 3.304 +EOT 3.305 + awk -F\| '{ printf "%s \"%s\" off ",$1,$3 }' \ 3.306 + /var/lib/tazpkg/packages.desc >> /tmp/dialog$$ 3.307 + sh /tmp/dialog$$ 2> /tmp/dialog.out$$ 3.308 + [ $? -eq 0 ] && packages_list="$(cat /tmp/dialog.out$$)" 3.309 + fi 3.310 + cat > /tmp/dialog$$ <<EOT 3.311 +$DIALOG --clear \ 3.312 + --title "Please select the directory with every custom packages to install." \ 3.313 + --cancel-label "Skip" \ 3.314 + --dselect $PWD 13 78 3.315 +EOT 3.316 + sh /tmp/dialog$$ 2> /tmp/dialog.out$$ 3.317 + [ $? -eq 0 ] && packages_dir="$(cat /tmp/dialog.out$$)" 3.318 + rm -f /tmp/dialog$$ /tmp/dialog.out$$ 3.319 +} 3.320 + 3.321 +_install() 3.322 +{ 3.323 + extra_packages 3.324 + $DIALOG --clear \ 3.325 + --title " SliTaz UMSDOS way installation " \ 3.326 + --yes-label "Install" --yesno \ 3.327 +"\nSliTaz will be installed in the subdirectory \\slitaz of the current 3.328 +DOS/Windows partition. You will see your files from /mnt/dos.\n\n 3.329 +You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n 3.330 +To uninstall SliTaz, you have only to remove this directory. 3.331 +The file \\boot.ini or \\config.sys may be modified too.\n\n 3.332 +SliTaz may run slowly on 'UMSDOS way' installation due to the 3.333 +posixovl filesystem. The 'TAZUSB way' installation runs faster.\n\n 3.334 +To do a traditional installation with disk partitioning, 3.335 +start SliTaz Live with 'SliTaz RAM boot' menu.\n 3.336 +" 19 70 3.337 + [ $? -eq 0 ] || return 3.338 + doinstall 3.339 +} 3.340 + 3.341 +readtazbootconf() 3.342 +{ 3.343 + kernel="$(sed '/^kernel=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)" 3.344 + initrd="$(sed '/^initrd=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)" 3.345 + cmdline="$(sed '/^kernel=/d;/^initrd=/d' $mnt/slitaz/boot/tazboot.cmd)" 3.346 +} 3.347 + 3.348 +bootinstalled() 3.349 +{ 3.350 + [ "$(which kexec)" ] || return 3.351 + [ -x $mnt/slitaz$1 ] || return 3.352 + [ -s $mnt/slitaz/boot/tazboot.cmd ] || return 3.353 + readtazbootconf 3.354 + kexec -l $kernel --initrd $initrd --command-line "$cmdline" --atags 3.355 + umount $mnt 3.356 + rm -rf $mnt 3.357 + umount -d /media/cdrom 3.358 + kexec -e 3.359 +} 3.360 + 3.361 +mkzip() 3.362 +{ 3.363 + device= 3.364 + packages_list= 3.365 + packages_dir= 3.366 + mnt=/tmp/mnt$$ 3.367 + mkdir -p $mnt 3.368 + $1 || return 3.369 + wget -O $mnt/slitaz/boot/grldr http://mirror.slitaz.org/boot/grldr 3.370 + readtazbootconf 3.371 + cat > $mnt/slitaz/menu.lst <<EOT 3.372 +title SliTaz 3.373 + kernel $kernel $cmdline 3.374 + initrd $initrd 3.375 + 3.376 +EOT 3.377 + while read file title; do 3.378 + file=$(ls $mnt/slitaz/boot/*file* 2> /dev/null) 3.379 + [ -s "$file" ] && cat >> $mnt/slitaz/menu.lst <<EOT 3.380 +title $title 3.381 + kernel $file 3.382 + 3.383 +EOT 3.384 + done <<EOT 3.385 +memtest MemTest 3.386 +pxe Web boot 3.387 +EOT 3.388 + cat > $mnt/slitaz/install.txt <<EOT 3.389 +For NT/2000/XP users: 3.390 + 3.391 +1- Move the files grldr and menu.lst into the root directory 3.392 + 3.393 +C:\\> copy \\slitaz\\boot\\grldr \\ 3.394 +C:\\> copy \\slitaz\\boot\\menu.lst \\ 3.395 + 3.396 +2- Remove boot.ini attributes 3.397 + 3.398 +C:\\> attrib -r -h -s boot.ini 3.399 + 3.400 +3- Append the following line to boot.init 3.401 + 3.402 +C:\\grldr="slitaz" 3.403 + 3.404 +4- Restore boot.ini attributes 3.405 + 3.406 +C:\\> attrib +r +h +s boot.ini 3.407 + 3.408 +See http://diddy.boot-land.net/grub4dos/files/README_GRUB4DOS.txt 3.409 +EOT 3.410 + ( cd $mnt ; zip -r9 $(basename $ISO .iso) slitaz ) 3.411 + mv $mnt/*.zip . 3.412 +} 3.413 + 3.414 +install() 3.415 +{ 3.416 + windev || return 3.417 + packages_list= 3.418 + packages_dir= 3.419 + _install && bootinstalled /sbin/init 3.420 + umount $mnt 3.421 + rm -rf $mnt 3.422 +} 3.423 + 3.424 +inst2zip() 3.425 +{ 3.426 + mkzip _install 3.427 +} 3.428 + 3.429 +_installtaz() 3.430 +{ 3.431 + $DIALOG --clear \ 3.432 + --title " SliTaz TAZUSB way installation " \ 3.433 + --yes-label "Install" --yesno \ 3.434 +"\nSliTaz will be installed in the subdirectory \\slitaz of the current 3.435 +DOS/Windows partition. You will see your files from /mnt/dos.\n\n 3.436 +You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n 3.437 +To uninstall SliTaz, you have only to remove this directory. 3.438 +The file \\boot.ini or \\config.sys may be modified too.\n\n 3.439 +The filesystem is loaded entirely into memory upon boot to 3.440 +increase responsiveness. Only /home lands on hard disk.\n\n 3.441 +To do a traditional installation with disk partitioning, 3.442 +start SliTaz Live with 'SliTaz RAM boot' menu.\n 3.443 +" 19 70 3.444 + [ $? -eq 0 ] || return 3.445 + doinstall tazusblike 3.446 +} 3.447 + 3.448 +installtaz() 3.449 +{ 3.450 + windev || return 3.451 + packages_list= 3.452 + packages_dir= 3.453 + _installtaz && bootinstalled /boot/bzimage 3.454 + umount $mnt 3.455 + rm -rf $mnt 3.456 +} 3.457 + 3.458 +insttaz2zip() 3.459 +{ 3.460 + mkzip _installtaz 3.461 +} 3.462 + 3.463 +bootiso() 3.464 +{ 3.465 + for i in $(ls_r /media/cdrom/boot/rootfs*gz); do 3.466 + grep -q ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64 3.467 + cat $i 3.468 + n=$((4 - ($(stat -c %s $i) % 4))) 3.469 + [ $n -eq 4 ] || dd if=/dev/zero bs=1 count=$n 3.470 + done > /tmp/initrd$$ 3.471 + kernel=/media/cdrom/boot/bzImage 3.472 + grep -q ' lm ' /proc/cpuinfo && [ -s ${kernel}64 ] && kernel=${kernel}64 3.473 + . /etc/locale.conf 3.474 + kexec -l $kernel --initrd /tmp/initrd$$ --atags --command-line \ 3.475 + "root=/dev/null autologin lang=$LANG kmap=$(cat /etc/keymap.conf)" 3.476 + umount -d /media/cdrom 3.477 + kexec -e 3.478 +} 3.479 + 3.480 +tazboot() 3.481 +{ 3.482 + $DIALOG --clear \ 3.483 + --title " SliTaz bootloader for DOS " \ 3.484 + --yes-label "Install" --yesno \ 3.485 +"\nThe file TAZBOOT.EXE will be created in the top directory. It supports 3.486 +any linux kernel, multiple initramfs, a kernel command line and 3.487 +an ISO image file loopback (retrieves files from an ISO file).\n\n 3.488 +Usage: tazboot.exe [[@commands]|[kernel=<bzimage>] 3.489 +[initrd=<rootfs>[,<rootfs2>...]] [bootfrom=<isofile>] cmdline args ...]\n\n 3.490 +Defaults: tazboot @tazboot.cmd or tazboot kernel=bzImage auto\n\n\ 3.491 +Examples for tazboot.cmd:\n\n\ 3.492 + bootfrom=\\isos\\slitaz-4.0.iso\n\ 3.493 + kernel=boot/bzImage\n\ 3.494 + initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\ 3.495 + rw root=/dev/null autologin\n\n\ 3.496 + kernel=\\slitaz\\vmlinuz root=/dev/sda5 ro\n\n 3.497 +Unlike GRUB4DOS, it doesn't require unfragmented ISO image files.\n 3.498 +" 24 78 3.499 + [ $? -eq 0 ] || return 3.500 + gettazboot tazboot.exe 3.501 +} 3.502 + 3.503 +md5() 3.504 +{ 3.505 + dotwait "Checking files" 3.506 + ( cd /media/cdrom ; ${1:-md5sum -c md5sum*} ) > /tmp/data 3.507 + rm -f /tmp/wait 3.508 + $DIALOG --clear \ 3.509 + --title " Checked files " \ 3.510 + --textbox /tmp/data 24 78 3.511 + rm -f /tmp/data 3.512 +} 3.513 + 3.514 +gotcdfile() 3.515 +{ 3.516 + for i in "/media/cdrom/$1" "/media/cdrom/*/$1" \ 3.517 + "/media/cdrom/*/isolinux/$1" ; do 3.518 + file=$(ls $i 2> /dev/null | sed q) 3.519 + [ -s "$file" ] && break 3.520 + done 3.521 +} 3.522 + 3.523 +sha() 3.524 +{ 3.525 + gotcdfile 'sha*sum*' 3.526 + sha=$(basename $file) 3.527 + md5 "${sha%sum*}sum -c ${file#/media/cdrom/}" 3.528 +} 3.529 + 3.530 +readme() 3.531 +{ 3.532 + gotcdfile 'README*' 3.533 + $DIALOG --clear \ 3.534 + --title " Readme " \ 3.535 + --textbox $file 24 78 3.536 +} 3.537 + 3.538 +bzimage() 3.539 +{ 3.540 + $DIALOG --clear \ 3.541 + --title " Create linux.exe ? " \ 3.542 + --yes-label "Install" --yesno \ 3.543 +"\nLinux.exe launches the linux kernel under DOS (in real mode only). 3.544 +The cmdline arguments are supported except initrd=, 3.545 +vga= (you can try 'rdev -v') and mem= (partially). 3.546 +\nExample:\nC:\\> linux.exe root=/dev/hda2 ro panic=60\n 3.547 +" 12 70 3.548 + [ $? -eq 0 ] || return 3.549 + cp /media/cdrom/boot/bzImage linux.exe 3.550 +} 3.551 + 3.552 +memtest() 3.553 +{ 3.554 + $DIALOG --clear \ 3.555 + --title " Create memtest.exe ? " \ 3.556 + --yes-label "Install" --yesno \ 3.557 +"\nMemtest86 is a thorough, stand alone memory test for x86 architecture 3.558 +computers. BIOS based memory tests are a quick, cursory check and often 3.559 +miss many of the failures that are detected by Memtest86.\n 3.560 +" 12 70 3.561 + [ $? -eq 0 ] && gotcdfile 'memtest*' && cp $file memtest.exe 3.562 +} 3.563 + 3.564 +mkfat12() 3.565 +{ 3.566 + [ $(($(get 0 $1) - 0x5A4D)) -eq 0 ] || return 3.567 + J=$(($(get 3 $1 1) + 0x02)) 3.568 + R=$((1 + $(get 497 $1 1) + 1 + ($(get 500 $1)-1)/32)) 3.569 + [ $R -lt 2500 ] || return 3.570 + [ $((($(get 500 $1)-1) & 31)) -lt 30 ] && 3.571 + ddq if=$file bs=32 count=1 seek=$(($R*16 - 1)) of=/dev/fd0 3.572 + G="18 0 2 0 0 0 0 0" 3.573 + [ $J -gt 25 ] || G="" 3.574 + F=0 3.575 + for i in 1 2 3; do 3.576 + F=$((((2880-$R-$F-$F)*3+1023)/1024)) 3.577 + done 3.578 + bytes2bin 0xEB $J 0x90 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 \ 3.579 + 0 2 2 $(($R%256)) $(($R/256)) 2 64 0 64 11 0xF0 $F 0 \ 3.580 + $G | ddq bs=1 of=/dev/fd0 3.581 + ddq if=/dev/zero bs=512 count=$((4+$F+$F)) seek=$R of=/dev/fd0 3.582 + for i in $R $(($R+$F)) ; do 3.583 + bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0 3.584 + done 3.585 + echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0 3.586 +} 3.587 + 3.588 +mkfloppy() 3.589 +{ 3.590 + dotwait "Create a $(basename $1) boot floppy" 3.591 + ddq if=$1 of=/dev/fd0 3.592 + mkfat12 $1 3.593 + rm -f /tmp/wait 3.594 +} 3.595 + 3.596 +fdmemtest() 3.597 +{ 3.598 + $DIALOG --clear \ 3.599 + --title " Create a Memtest86 boot floppy " \ 3.600 + --yes-label "Create floppy" --yesno \ 3.601 +"\nMemtest86 is a thorough, stand alone memory test for x86 architecture 3.602 +computers. BIOS based memory tests are a quick, cursory check and often 3.603 +miss many of the failures that are detected by Memtest86.\n\n 3.604 +Please insert a blank disk in floppy drive.\n 3.605 +" 12 70 3.606 + [ $? -eq 0 ] && gotcdfile 'memtest*' && mkfloppy $file 3.607 +} 3.608 + 3.609 +pxe() 3.610 +{ 3.611 + gotcdfile '?pxe' 3.612 + $DIALOG --clear \ 3.613 + --title " Create $(basename $file).exe ? " \ 3.614 + --yes-label "Install" --yesno \ 3.615 +"\nBoot your operating system from the internet and enjoy a full system 3.616 +working entirely in RAM with speed and stability in mind. The Linux Kernel 3.617 +and the complete SliTaz compressed root filesystem will be loaded into RAM 3.618 +from the Web using PXE and HTTP protocols.\n 3.619 +" 12 70 3.620 + [ $? -eq 0 ] || return 3.621 + cp $file $(basename $file).exe 3.622 +} 3.623 + 3.624 +fdpxe() 3.625 +{ 3.626 + $DIALOG --clear \ 3.627 + --title " Create a SliTaz Web boot floppy " \ 3.628 + --yes-label "Create floppy" --yesno \ 3.629 +"\nBoot your operating system from the internet and enjoy a full system 3.630 +working entirely in RAM with speed and stability in mind. The Linux Kernel 3.631 +and the complete SliTaz compressed root filesystem will be loaded into RAM 3.632 +from the Web using PXE and HTTP protocols.\n\n 3.633 +Please insert a blank disk in floppy drive.\n 3.634 +" 12 70 3.635 + [ $? -eq 0 ] && gotcdfile '?pxe' && mkfloppy $file 3.636 +} 3.637 + 3.638 +gotposixovl() 3.639 +{ 3.640 + mount.posixovl 2>&1 | grep -qi usage && 3.641 + echo -en "\"$1\" \"$2\"" 3.642 +} 3.643 + 3.644 +gotposixovlzip() 3.645 +{ 3.646 + [ "$(which zip)" ] && gotposixovl "$1" "$2" 3.647 +} 3.648 + 3.649 +xfile() 3.650 +{ 3.651 + [ "$(which $1)" ] && echo -en "\"$2\" \"$3\"" 3.652 +} 3.653 + 3.654 +cdfile() 3.655 +{ 3.656 + gotcdfile "$1" && echo -en "\"$2\" \"$3\"" 3.657 +} 3.658 + 3.659 +cdfilex() 3.660 +{ 3.661 + [ "$(which kexec)" ] && cdfile "$@" 3.662 +} 3.663 + 3.664 +cdfilef() 3.665 +{ 3.666 + [ -e /sys/block/fd0 ] && cdfile "$@" 3.667 +} 3.668 + 3.669 +cdexe() 3.670 +{ 3.671 + gotcdfile "$1" && 3.672 + [ $(get 0 $file 2>/dev/null || echo 0) -eq 23117 ] && 3.673 + echo -en "\"$2\" \"$3\"" 3.674 +} 3.675 + 3.676 +misspkg() 3.677 +{ 3.678 + for i in zip kexec-tools posixovl ; do 3.679 + [ -d /var/lib/tazpkg/installed/$i/ ] && continue 3.680 + [ "$1" != "install" ] && 3.681 + echo -en "\"$1\" \"$2\"" && return 3.682 + tazpkg get-install $i 3.683 + done 3.684 +} 3.685 + 3.686 +missing() 3.687 +{ 3.688 + misspkg install 3.689 +} 3.690 + 3.691 +ishybrid() 3.692 +{ 3.693 + C=$((2048*$(get $(((17*2048) + 71)) $ISO 4))) 3.694 + [ $(get $C $ISO 4) -eq 1 ] || return 3.695 + [ $(get $(($C+30)) $ISO 4) -eq $((0x88AA55)) ] || return 3.696 + C=$((2048*$(get $(($C+40)) $ISO 4))) 3.697 + [ $(get $(($C+64)) $ISO 4) -eq 1886961915 ] && 3.698 + echo -en "\"$1\" \"$2\"" 3.699 +} 3.700 + 3.701 +isiso() 3.702 +{ 3.703 + [ $(get 32769 $ISO 4) -eq 808469571 ] && 3.704 + echo -en "\"$1\" \"$2\"" 3.705 +} 3.706 + 3.707 +gotisomd5() 3.708 +{ 3.709 + [ "$(which md5sum 2> /dev/null)" ] && 3.710 + [ $(get 0 $ISO) -eq 23117 ] && 3.711 + [ $(get 18 $ISO) -ne 0 ] && echo -en "\"$1\" \"$2\"" 3.712 +} 3.713 + 3.714 +isomd5() 3.715 +{ 3.716 + dotwait "Checking iso image" 3.717 + [ "$(ddq if=$ISO bs=2k skip=16 \ 3.718 + count=$(echo $(get 32848 $ISO 4)) | md5sum)" == \ 3.719 + "$(ddq if=$ISO bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \ 3.720 + sed 's/ //g') -" ] && echo "OK" || echo "ERROR" 3.721 + echo -en "\rChecking iso hybrid boot..." 3.722 + n=$(($(get 2 $ISO)-1+($(get 4 $ISO)-1)*512)) 3.723 + if [ $n -lt 40000 -a $n -gt 32768 ]; then 3.724 + s=$(get 0 $ISO 2 $n | awk '{ i+= $0 } END { print i }') 3.725 + [ $(((1+$s+$(get $(($n+1)) $ISO 1)) % 65536)) -eq 0 ] && 3.726 + echo "OK" || echo "ERROR" 3.727 + fi 3.728 + rm -f /tmp/wait 3.729 + echo -e "\rPress RETURN to continue." 3.730 + read n 3.731 +} 3.732 + 3.733 +usbdev() 3.734 +{ 3.735 + dotwait "Wait 5 seconds for USB devices" 3.736 + sleep 5 3.737 + rm -f /tmp/wait 3.738 + DEV="$(grep -l 1 /sys/block/*/removable | \ 3.739 + sed 's|/sys/block/\(.*\)/removable|\1|')" 3.740 + grep -qs 1 /sys/block/$DEV/ro && return 3.741 + [ "$DEV" ] || return 3.742 + cat > /tmp/dialog$$ <<EOT 3.743 +$DIALOG --clear \ 3.744 + --title " Select your USB key " \ 3.745 + --menu "\nPlease select the USB key according to its known size.\n\n" \ 3.746 + 14 70 4 \ 3.747 + $(for i in $DEV ; do 3.748 + echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2> /dev/null)\" " 3.749 + done) \ 3.750 + 3.751 +EOT 3.752 + exec 3>&1 3.753 + device=$(. /tmp/dialog$$ 2>&1 1>&3) 3.754 + rm -f /tmp/dialog$$ 3.755 + retval=$? 3.756 + exec 3>&- 3.757 + rm -f /tmp/dialog$$ 3.758 + [ $retval -eq 0 ] 3.759 +} 3.760 + 3.761 +tazusbmsg() 3.762 +{ 3.763 + [ "$(which tazusb 2> /dev/null)" ] || return 3.764 + echo "You should choose 'USB key read/write installation' to be 3.765 +able to save the package updates or your own configuration and data files.\n\n" 3.766 +} 3.767 + 3.768 +usbbootkey() 3.769 +{ 3.770 + $DIALOG --clear \ 3.771 + --title " Create a USB boot key " \ 3.772 + --yes-label "Continue" --yesno \ 3.773 +"\nThe USB key will be used like a CD-ROM. You will not be able to write 3.774 +any data on the boot partition.\n\n 3.775 +An extra FAT32 partition will be created with the remaining free space.\n\n 3.776 +$(tazusbmsg)Please plug your USB stick in now.\n 3.777 +" 16 70 3.778 + [ $? -eq 0 ] || return 3.779 + usbdev || return 3.780 + 3.781 + # perform dd in progess bar 3.782 + max=$(($(stat -c %s $ISO)/2048)) 3.783 + i=0; ddq if=$ISO bs=1024k | ( 3.784 + while ddq bs=1024k count=1 ; do 3.785 + i=$(($i + 1)) 3.786 + [ $i -gt $max ] && break 3.787 + echo $((($i*100)/$max)) | dialog --gauge \ 3.788 + " The ISO image transfer can be long. Please wait..." \ 3.789 + 6 70 0 > /dev/tty 2>&1 3.790 + done ) > $device 3.791 + 3.792 + # partition + fat32 format for the remining space 3.793 + get 446 $device 2 12 | xargs echo | { read dx cx ol oh ll lh 3.794 + if [ $dx -eq $((0x3F17)) ]; then 3.795 + cx=$(($cx & 0xFF00)) 3.796 + ofs=$(($ll+($lh<<16))) 3.797 + n=$(($(cat /sys/block/${device#/dev/}/size)-$ofs)) 3.798 + m=$(($cx+($n/8))) 3.799 + [ $m -gt $((0x3FF00)) ] && m=$((0x3FF00)) 3.800 + m=$((($m & 0xFF00)+(($m>>16)<<6))) 3.801 + words2bin 0 $((0x101+$cx)) 0x3F0B $((32+$m)) \ 3.802 + $ll $lh $(($n & 0xFFFF)) $(($n >> 16)) | \ 3.803 + ddq bs=1 seek=446 of=$device 3.804 + if [ "$(which mkdosfs 2> /dev/null)" ]; then 3.805 + losetup -o $((512*$ofs)) /dev/loop2 $device 3.806 + mkdosfs -n "SLITAZ BOOT" /dev/loop2 3.807 + words2bin $(($ofs & 0xFFFF)) $(($ofs >> 16)) | \ 3.808 + ddq bs=1 seek=28 of=/dev/loop2 3.809 + losetup -d /dev/loop2 3.810 + fi 3.811 + fi ; } 3.812 +} 3.813 + 3.814 +usbkey() 3.815 +{ 3.816 + $DIALOG --clear \ 3.817 + --title " Create a SliTaz USB key " \ 3.818 + --yes-label "Continue" --yesno \ 3.819 +"\nUnlike a hard drive install, the filesystem is kept in a compressed 3.820 +rootfs.gz. The filesystem is loaded entirely into memory upon boot. 3.821 +This should increase responsiveness, protect the filesystem against 3.822 +accidental corruption and reduce read/writes to the USB drive. 3.823 +Once setup, the tazusb utility can rewrite the root filesystem 3.824 +with any changes you have made since booting up, 3.825 +giving the effective benefits of a hard drive install.\n\n 3.826 +/home is mounted on boot using the UUID of your particular flash drive. 3.827 +Unlike a device name, the UUID has the benefit of never changing from machine 3.828 +to machine.\n\n 3.829 +Please plug your USB stick in now.\n 3.830 +" 19 70 3.831 + [ $? -eq 0 ] || return 3.832 + usbdev || return 3.833 + exec 3>&1 3.834 + format=`$DIALOG --clear \ 3.835 + --title " Select the filesystem " \ 3.836 + --radiolist "\nPlease select the filesystem type to create.\n\n\ 3.837 +The filesystem creation will erase all the data \ 3.838 +in the USB key." 14 70 4 \ 3.839 + "none" "Do not erase the USB key" on \ 3.840 + "ext3" "Ext3 journaling filesystem" off \ 3.841 + "ext2" "Ext2 filesystem" off \ 3.842 + "fat32" "Windows FAT32 filesystem" off \ 3.843 + 2>&1 1>&3` 3.844 + retval=$? 3.845 + exec 3>&- 3.846 + [ $retval -eq 0 ] || return 3.847 + [ "$format" != "none" ] && tazusb format $device "SliTaz" $format 3.848 + tazusb gen-iso2usb $ISO $device 3.849 +} 3.850 + 3.851 +dokexec() 3.852 +{ 3.853 + kexec -l $file 3.854 + umount -d /media/cdrom 3.855 + kexec -e 3.856 +} 3.857 + 3.858 +runmemtest() 3.859 +{ 3.860 + gotcdfile 'memtest*' && dokexec 3.861 +} 3.862 + 3.863 +runpxe() 3.864 +{ 3.865 + gotcdfile '?pxe' && dokexec 3.866 +} 3.867 + 3.868 +quit() 3.869 +{ 3.870 + umount -d /media/cdrom 3.871 + exit 3.872 +} 3.873 + 3.874 +ISO="$1" 3.875 +[ -z "$(isiso 2> /dev/null)" ] && echo "Usage : $0 file.iso" && exit 1 3.876 +mount -o loop,ro $ISO /media/cdrom 3.877 + 3.878 +while true; do 3.879 + cat > /tmp/dialog$$ <<EOT 3.880 +$DIALOG --clear \ 3.881 + --title " SliTaz ISO tool " \ 3.882 + --menu "" 23 70 17 \ 3.883 +$(cdfile 'README*' "readme" "Show the README file") \ 3.884 +$(gotisomd5 "isomd5" "Check the ISO image") \ 3.885 +$(cdfile 'md5sum*' "md5" "Check the ISO files") \ 3.886 +$(cdfile 'sha*sum*' "sha" "Check the ISO files") \ 3.887 +$(cdfilex boot/bzImage "bootiso" "Boot the ISO image") \ 3.888 +$(gotposixovl "install" "Hard disk installation (UMSDOS way)") \ 3.889 +$(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \ 3.890 +$(gotposixovlzip "inst2zip" "ZIP installation archive (UMSDOS way)") \ 3.891 +$(gotposixovlzip "insttaz2zip" "ZIP installation archive (TAZUSB way)") \ 3.892 +$(xfile tazusb "usbkey" "USB key read/write installation") \ 3.893 +$(ishybrid "usbbootkey" "USB boot key (read only)") \ 3.894 + "tazboot" "Get tazboot.exe Linux loader" \ 3.895 +$(cdexe boot/bzImage "bzimage" "Get linux DOS/EXE file") \ 3.896 +$(cdexe 'memtest*' "memtest" "Get Memtest86 DOS/EXE file") \ 3.897 +$(cdfilef 'memtest*' "fdmemtest" "Create a Memtest86 boot floppy") \ 3.898 +$(cdfilex 'memtest*' "runmemtest" "Start Memtest86") \ 3.899 +$(cdexe '?pxe' "pxe" "Get SliTaz Web boot DOS/EXE utility") \ 3.900 +$(cdfilef '?pxe' "fdpxe" "Create a SliTaz Web boot floppy") \ 3.901 +$(cdfilex '?pxe' "runpxe" "Start the SliTaz Web boot utility") \ 3.902 +$(misspkg "missing" "Install packages to get more options") \ 3.903 + "quit" "Quit this utility" 3.904 +EOT 3.905 + exec 3>&1 3.906 + value=$(. /tmp/dialog$$ 2>&1 1>&3) 3.907 + retval=$? 3.908 + exec 3>&- 3.909 + rm -f /tmp/dialog$$ 3.910 + [ $retval -eq 0 ] || continue 3.911 + $value 3.912 +done