wok diff syslinux/stuff/iso2exe/init @ rev 23820
syslinux: merge init.exe & taziso
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu May 28 08:35:55 2020 +0000 (2020-05-28) |
parents | 3f40a3c71c48 |
children | c2a80ff9499e |
line diff
1.1 --- a/syslinux/stuff/iso2exe/init Mon May 25 18:40:12 2020 +0000 1.2 +++ b/syslinux/stuff/iso2exe/init Thu May 28 08:35:55 2020 +0000 1.3 @@ -1,97 +1,14 @@ 1.4 #!/bin/sh 1.5 1.6 -DIALOG=dialog 1.7 - 1.8 -ddq() 1.9 -{ 1.10 - dd $@ 2>/dev/null 1.11 -} 1.12 - 1.13 -get() 1.14 -{ 1.15 - od -v -j $1 -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An $2 2>/dev/null || 1.16 - hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %u\n\"" $2 1.17 -} 1.18 - 1.19 getarg() 1.20 { 1.21 sed "/$1=/!d;s/.*$1=\\([^ ]*\\).*/\\1/" /proc/cmdline 1.22 } 1.23 1.24 -clear() 1.25 +myget() 1.26 { 1.27 - echo -e "\x1B[1;1H\x1B[J" 1.28 -} 1.29 - 1.30 -xless() 1.31 -{ 1.32 - [ $(wc -l < "$1") -gt 22 ] && 1.33 - sed 's/..3.;4.m/===/g;$s/.*/&\n---\nPress q to continue/' "$1" | less || 1.34 - { cat "$1" 1.35 - [ "$2" ] || return 1.36 - echo -e "$2" 1.37 - read n 1.38 - } 1.39 -} 1.40 - 1.41 -tinydialog() 1.42 -{ 1.43 - clear 1.44 - label="" 1.45 - while [ "$1" ]; do 1.46 - case "$1" in 1.47 - --title) title=" \x1B[30;47m$2\x1B[37;40m\n" 1.48 - echo -e $title; shift;; 1.49 - --yes-label) label="$2"; shift;; 1.50 - --textbox) 1.51 - xless "$2" "\nPress RETURN to continue." 1.52 - break;; 1.53 - --gauge) 1.54 - t=" " 1.55 - echo -e "$t$2\n" 1.56 - while read pct; do 1.57 - s=" " 1.58 - s="$s$pct%$s" 1.59 - pct=$((($pct*63)/100)) 1.60 - echo -en "\r$t\x1B[30;47m$(echo "$s" | cut -c-$pct)\x1B[37;40m$(echo "$s" | cut -c$(($pct+1))-)" 1.61 - done 1.62 - break;; 1.63 - --yesno) 1.64 - while true; do 1.65 - clear 1.66 - echo "$2" | sed 's/\\n\\n/\\n/g;s/\\n/\n/g' 1.67 - echo -en " <- 1:${label:-Yes} 2:Cancel\r" 1.68 - read x 1.69 - case "$x" in 1.70 - ''|Y*|y*|1) return 0;; 1.71 - N*|n*|2|0) return 1;; 1.72 - esac 1.73 - done;; 1.74 - --menu|--radiolist) 1.75 - [ "$1" = "--menu" ] && shft=2 || shft=3 1.76 - label="" 1.77 - [ "$2" ] && label="\n$2" 1.78 - shift 5 1.79 - echo -e "$title$label\n0 Cancel" > /tmp/data 1.80 - n=1 1.81 - while [ "$1" ]; do 1.82 - eval key_$n='$1' 1.83 - echo "$((n++)) $2" 1.84 - shift $shft 1.85 - done >> /tmp/data 1.86 - while ! grep -q "^$n " /tmp/data; do 1.87 - clear 1.88 - xless /tmp/data 1.89 - echo -en "\n <- Enter the selection number\r" 1.90 - read n 1.91 - done 2>/dev/null 1.92 - rm -f /tmp/data 1.93 - [ $n -eq 0 ] && return 1 1.94 - eval echo -n \$key_$n 1>&2 1.95 - return 0;; 1.96 - esac 1.97 - shift 1.98 - done 1.99 + od -v -j $1 -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An $2 2>/dev/null || 1.100 + hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %u\n\"" $2 1.101 } 1.102 1.103 mount_proc() 1.104 @@ -109,56 +26,31 @@ 1.105 umount /proc 1.106 } 1.107 1.108 -bytes2bin() 1.109 +checkmagic() 1.110 { 1.111 - for i in $@; do 1.112 - printf '\\\\x%02X' $(($i&255)) 1.113 - done | xargs echo -en 1.114 + [ -s $1 ] && [ $(getarg magic) = $(myget 18 $1 2) ] 1.115 } 1.116 1.117 -words2bin() 1.118 -{ 1.119 - for i in $@; do 1.120 - printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255)) 1.121 - done | xargs echo -en 1.122 -} 1.123 - 1.124 -gettazboot() 1.125 -{ 1.126 - echo -e "\nCreating $(basename $1) ..." 1.127 - S=$((32+HEADERSZ)) 1.128 - P=$((($S+511)/512)) 1.129 - E=$((4096-(32*$P))) 1.130 - words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 -16 \ 1.131 - -2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1 1.132 - uudecode - >> $1 << EOT 1.133 -HEADERCODE 1.134 -EOT 1.135 - gotcdfile linld.com 1.136 - ddq if=$file >> $1 1.137 -} 1.138 - 1.139 -checkmagic() 1.140 -{ 1.141 - [ -s $1 ] && [ $(getarg magic) = $(get 18 $1 2) ] 1.142 -} 1.143 - 1.144 +media=/media/cdrom 1.145 +mnt=/mnt 1.146 getiso() 1.147 { 1.148 - mkdir -p /media/cdrom 1.149 + mkdir -p $media 1.150 for dev in /sys/block/?d?/?d??*; do 1.151 - mount /dev/$(basename $dev) /mnt 1.152 - if checkmagic /mnt/$ISO; then 1.153 - mount -o loop,ro /mnt/$ISO /media/cdrom 1.154 + mount /dev/$(basename $dev) $mnt 1.155 + if checkmagic $mnt/$ISO; then 1.156 + mount -o loop,ro $mnt/$ISO $media 1.157 echo "Found $ISO on $(basename $dev)" 1.158 + ISO=$mnt/$ISO 1.159 return 0 1.160 fi 1.161 - umount /mnt 1.162 + umount $mnt 1.163 done 2>/dev/null 1.164 return 1 1.165 } 1.166 1.167 -uncpio() 1.168 +uncpio=uncpio64 1.169 +uncpio64() 1.170 { 1.171 i=$1 1.172 sed 's|$| |' /proc/cpuinfo | grep ' lm ' && [ -s ${i}64 ] && i=${i}64 1.173 @@ -172,875 +64,34 @@ 1.174 esac < $i | ( cd ${2:-/}; cpio -idmu > /dev/null 2>&1 ) 1.175 } 1.176 1.177 -dotwait() 1.178 -{ 1.179 - echo -n "${1:-Install filesystem}.." 1.180 - echo -n > /tmp/wait 1.181 - while [ -e /tmp/wait ]; do 1.182 - echo -n "." > /dev/tty0 1.183 - sleep 1 1.184 - done & 1.185 -} 1.186 - 1.187 -getuuid() 1.188 -{ 1.189 - dev=$(mount | sed '/ \/mnt /!d;s/ .*//;s|/dev/||;q') 1.190 - blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/" 1.191 -} 1.192 - 1.193 -tazusbinitfs() 1.194 -{ 1.195 - PAD=$(($(stat -c %s $1) % 4)) 1.196 - [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1 1.197 - mkdir -p /tmp/fs/etc /tmp/fs/lib /tmp/fs/home 1.198 - cp /etc/keymap.conf /etc/locale.conf /tmp/fs/etc 2>/dev/null 1.199 - cat > /tmp/fs/init1 <<EOT 1.200 -#!/bin/sh 1.201 -sed -i 's|sbin/init|init2|' /init 1.202 -exec /init 1.203 -EOT 1.204 - cat > /tmp/fs/init2 <<EOT 1.205 -#!/bin/sh 1.206 - 1.207 -mount -t proc /proc /proc 1.208 -for i in /lib/modules/*.ko*; do insmod \$i 2>/dev/null; done; sleep 2 1.209 -v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2>/dev/null) 1.210 -mount / -o remount,rw 1.211 -mkdir /mnt/dos 1.212 -rm -f /cmdline 2>/dev/null 1.213 -mount / -o remount,ro 1.214 -mnt=/mnt/dos/\${v#*/} 1.215 -dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q') 1.216 -echo "Mount \$dev in /mnt/dos for \$v..." | tee -a /run/boot.log 1.217 -mount \$dev /mnt/dos 1.218 -mount.posixovl -F \$mnt -- -oallow_other -odefault_permissions -osuid 1.219 -mount --bind \$mnt /home 1.220 -mount -o size=0,ro -t tmpfs tmpfs \$mnt 1.221 -umount /proc 1.222 -exec /sbin/init 1.223 -EOT 1.224 - chmod 755 /tmp/fs/init? 1.225 - cp -a /tmp/fs/* / 1.226 - ln -s /sqfs/bin/gzip /bin 2>/dev/null 1.227 - ( cd /tmp/fs; find * | cpio -o -H newc ) | gzip -9 >> $1 1.228 -} 1.229 - 1.230 -mkinitrd() 1.231 -{ 1.232 - echo 1.233 - dotwait "Creating $(basename $1) " 1.234 - for i in bin lib dev proc tmp mnt etc; do 1.235 - mkdir -p /tmp/fs/$i 1.236 - done 1.237 - for i in /dev/console /dev/null /dev/tty /dev/tty[012] /dev/fuse /dev/[hs]d*; do 1.238 - cp -a $i /tmp/fs$i 1.239 - done 1.240 - for i in /bin/busybox $(which mount.posixovl) $(which blkid); do 1.241 - cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \ 1.242 - sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') /tmp/fs/lib 1.243 - cp $i /tmp/fs/bin 1.244 - done 1.245 - cp -a /sqfs/lib/ld-* /tmp/fs/lib 2>/dev/null || 1.246 - cp -a /lib/ld-* /tmp/fs/lib 1.247 - for i in $(busybox | sed '/Current/,$!d'); do 1.248 - [ -e /tmp/fs/bin/${i%,} ] || ln -s busybox /tmp/fs/bin/${i%,} 1.249 - done 1.250 - ln -s /proc/mounts /tmp/fs/etc/mtab 1.251 - sed 's/ .*//' /proc/modules | while read mod; do 1.252 - find /lib/modules/ | grep $mod.ko | \ 1.253 - sed 's|.*|cp & /tmp/fs/lib|' | sh 1.254 - done 1.255 - cat > /tmp/fs/init <<EOT 1.256 -#!/bin/sh 1.257 - 1.258 -arg() 1.259 -{ 1.260 - grep -q \$1 /proc/cmdline && 1.261 - val="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" < /proc/cmdline)" && 1.262 - echo "\$2 \$val" 1.263 -} 1.264 - 1.265 -mount -t proc /proc /proc 1.266 -for i in /lib/*.ko*; do insmod \$i 2>/dev/null; done; sleep 2 1.267 -arg mount "Mount device" 1.268 -mount \$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q') /mnt 1.269 -arg subroot "Change root to directory" 1.270 -mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid 1.271 -mount --bind /mnt /mnt/\$val/mnt/dos 1.272 -mount -o size=0,ro -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val 1.273 -LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q) 1.274 -export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib 1.275 -umount /proc 1.276 -exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init 1.277 -EOT 1.278 - chmod +x /tmp/fs/init 1.279 - ( cd /tmp/fs; find * | cpio -o -H newc ) | lzma e $1 -si 2>/dev/null 1.280 - rm -rf /tmp/fs /tmp/wait 1.281 -} 1.282 - 1.283 -is_loram() 1.284 -{ 1.285 - [ -s /lib/modules/squashfs.ko* ] 1.286 -} 1.287 - 1.288 -ls_r() 1.289 -{ 1.290 - ls -r $@ 2>/dev/null || ls $@ 1.291 -} 1.292 - 1.293 -doinstall() 1.294 -{ 1.295 - mkdir -p /mnt/slitaz/boot /mnt/slitaz/mnt/dos 1.296 - if ! mount.posixovl -F /mnt/slitaz -- \ 1.297 - -oallow_other -odefault_permissions -osuid; then 1.298 - echo "Can't install SliTaz. Abort." 1.299 - sleep 5 1.300 - return 1 1.301 - fi 1.302 - dotwait "Install root filesystem in /slitaz.." 1.303 - if [ "$1" ]; then 1.304 - if [ -d /media/cdrom/fs ]; then 1.305 - ( cd /mnt/slitaz/fs; find | cpio -o -H newc ) | gzip -9 1.306 - else 1.307 - ls_r /media/cdrom/boot/rootfs* | xargs cat 1.308 - fi > /mnt/slitaz/boot/rootfs.gz 1.309 - tazusbinitfs /mnt/slitaz/boot/rootfs.gz 1.310 - initrd=rootfs.gz 1.311 - extraargs="/home=$(getuuid)/slitaz rdinit=/init1" 1.312 - else 1.313 - if [ -d /media/cdrom/fs ]; then 1.314 - cp -a /media/cdrom/fs/. /mnt/slitaz 1.315 - elif is_loram; then 1.316 - for i in $(ls_r /media/cdrom/boot/rootfs*); do 1.317 - losetup -o 124 /dev/loop7 $i 1.318 - mount -t squashfs -o ro /dev/loop7 /sqfs/mnt 1.319 - cp -a /sqfs/mnt/. /mnt/slitaz 1.320 - umount /sqfs/mnt 1.321 - losetup -d /dev/loop7 1.322 - done 1.323 - else 1.324 - for i in $(ls_r /media/cdrom/boot/rootfs*); do 1.325 - uncpio $i /mnt/slitaz 1.326 - done 1.327 - fi 1.328 - mkinitrd /mnt/slitaz/boot/initrd 1.329 - initrd=initrd 1.330 - extraargs="mount=$(getuuid) subroot=slitaz" 1.331 - fi 1.332 - echo -en "\nInstall boot files..." 1.333 - for i in /media/cdrom/boot/bzImage /media/cdrom/boot/*pxe* \ 1.334 - /media/cdrom/boot/isolinux/he* /media/cdrom/boot/isolinux/opt* \ 1.335 - /media/cdrom/README /media/cdrom/boot/memtest*; do 1.336 - [ -s $i ] && cp $i /mnt/slitaz/boot 1.337 - done 1.338 - for i in /mnt/slitaz/boot/memtest /mnt/slitaz/boot/*pxe; do 1.339 - [ $(get 0 $i 2>/dev/null || echo 0) -eq 23117 ] && 1.340 - mv $i $i.exe 1.341 - done 1.342 - cp /etc/keymap.conf /etc/locale.conf /mnt/slitaz/etc 2>/dev/null 1.343 - gettazboot /mnt/slitaz/boot/tazboot.exe 1.344 - unix2dos > /mnt/slitaz/boot/tazboot.cmd <<EOT 1.345 -image=/slitaz/boot/bzimage 1.346 -initrd=/slitaz/boot/$initrd 1.347 -$extraargs autologin 1.348 -EOT 1.349 - uudecode - <<EOT | gunzip > /mnt/slitaz/boot/slitaz.pif 1.350 -begin-base64 644 - 1.351 -H4sIAAAAAAACA8XPxUHGMBTA8X9ecb/glgFwv+FO23zeI+7ucMFhCjZgEEZh 1.352 -Ctzd4Rf3PFbtQHGLG9BmfmZqdlE/tSmw2LfePzOzWDK0OsQXpPHvFGfZBmL5 1.353 -f3Zns98NuG1BbTrbWj0OFMypSKfT4kYCurKuRleWlBEth2qUTYFBKjg746pI 1.354 -2nZaIT/v9vWwbeuqi9fPznLlSPFLLuK22/0lLT09/BDhXgWKO1f9aLKxOObE 1.355 -EhLuVvO4FksSwaH5qbHpvkle0TyzND82NK+doRVeZgGGbIw0XD2QwV9SnAN/ 1.356 -ACxDxwMAAA== 1.357 -==== 1.358 -EOT 1.359 - unix2dos /mnt/slitaz/boot/he* /mnt/slitaz/boot/opt* \ 1.360 - /mnt/slitaz/boot/README 1.361 - [ -d /mnt/slitaz/usr/sbin -a ! -x /mnt/slitaz/usr/sbin/mount.posixovl ] && 1.362 - cp $(which mount.posixovl) /mnt/slitaz/usr/sbin 1.363 - rm -f /tmp/wait 1.364 -false && 1.365 - [ -s /mnt/boot.ini ] && ! grep -qs tazboot /mnt/boot.ini && 1.366 - echo "Update boot.ini ..." && unix2dos >> /mnt/boot.ini <<EOT 1.367 -C:\\slitaz\\boot\\tazboot.exe="SliTaz" 1.368 -EOT 1.369 -false && 1.370 - grep -qis menuitem /mnt/config.sys && ! grep -qi tazboot /mnt/config.sys && 1.371 - echo "Update config.sys ..." && 1.372 - sed -i 's/menudefault/menuitem SLITAZ, SliTaz\r\n&/' /mnt/config.sys && 1.373 - unix2dos >> /mnt/config.sys <<EOT 1.374 -[SLITAZ] 1.375 -install=\\slitaz\\boot\\tazboot.exe 1.376 -EOT 1.377 - return 0 1.378 -} 1.379 - 1.380 -install() 1.381 -{ 1.382 - $DIALOG --clear --title " SliTaz UMSDOS way installation " \ 1.383 - --yes-label "Install" --yesno \ 1.384 -"\nSliTaz will be installed in the subdirectory \\slitaz of the current 1.385 -DOS/Windows partition. You will see your files from /mnt/dos.\n\n 1.386 -You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n 1.387 -To uninstall SliTaz, you have only to remove this directory. 1.388 -The file \\boot.ini or \\config.sys may be modified too.\n\n 1.389 -SliTaz may run slowly on the 'UMSDOS way' installation due to the 1.390 -posixovl filesystem. The 'TAZUSB way' installation runs faster.\n\n 1.391 -To do a traditional installation with disk partitioning, 1.392 -start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70 1.393 - [ $? -eq 0 ] || return 1.394 - doinstall || return 1.395 - [ -x /mnt/slitaz/sbin/init ] || return 1.396 - umount -d /media/cdrom 1.397 - umount_proc 1.398 - exec chroot /mnt/slitaz /sbin/init 1.399 -} 1.400 - 1.401 -installtaz() 1.402 -{ 1.403 - $DIALOG --clear --title " SliTaz TAZUSB way installation " \ 1.404 - --yes-label "Install" --yesno \ 1.405 -"\nSliTaz will be installed in the subdirectory \\slitaz of the current 1.406 -DOS/Windows partition. You will see your files from /mnt/dos.\n\n 1.407 -You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n 1.408 -To uninstall SliTaz, you have only to remove this directory. 1.409 -The file \\boot.ini or \\config.sys may be modified too.\n\n 1.410 -The filesystem is loaded entirely into memory upon boot to 1.411 -increase responsiveness. Only /home lands on the hard disk.\n\n 1.412 -To do a traditional installation with disk partitioning, 1.413 -start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70 1.414 - [ $? -eq 0 ] || return 1.415 - doinstall tazusblike || return 1.416 - dotwait 1.417 - if [ -d /media/cdrom/fs ]; then 1.418 - cp -a /media/cdrom/fs/. / 1.419 - else 1.420 - for i in $(ls_r /media/cdrom/boot/rootfs*); do 1.421 - uncpio $i 1.422 - done 1.423 - fi 1.424 - cp /tmp/fs/etc/* /etc 2>/dev/null 1.425 - echo "/home=$(getuuid)/slitaz" > /cmdline 1.426 - rm -f /tmp/wait 1.427 - [ -x /init1 ] || return 1.428 - umount -d /media/cdrom 1.429 - umount /mnt/slitaz 1.430 - rm -f /dev/cdrom 1.431 - umount /mnt 1.432 - mkdir /mnt/dos 1.433 - umount_proc 1.434 - exec /init1 1.435 -} 1.436 - 1.437 -tazboot() 1.438 -{ 1.439 - $DIALOG --clear --title " SliTaz bootloader for DOS " \ 1.440 - --yes-label "Install" --yesno \ 1.441 -"\nThe file TAZBOOT.EXE will be created in the top directory. It supports 1.442 -any linux kernel, multiple initramfs, and a kernel command line.\n\n 1.443 -Usage: tazboot.exe [[@commands]|[image=<bzimage>] 1.444 -[initrd=<rootfs>[,<rootfs2>...]] cmdline args ...]\n\n 1.445 -Defaults: tazboot @tazboot.cmd or tazboot image=bzImage auto\n\n\ 1.446 -Examples for tazboot.cmd:\n\n\ 1.447 - image=boot/bzImage\n\ 1.448 - initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\ 1.449 - autologin\n\n\ 1.450 - image=\\slitaz\\vmlinuz root=/dev/sda5 ro\n" 24 78 1.451 - [ $? -eq 0 ] || return 1.452 - gettazboot /mnt/tazboot.exe 1.453 -} 1.454 - 1.455 -md5() 1.456 -{ 1.457 - dotwait "Checking files" 1.458 - ( cd /media/cdrom; ${1:-md5sum -c md5sum*} | sort ) > /tmp/data 1.459 - rm -f /tmp/wait 1.460 - $DIALOG --clear --title " Checked files " --textbox /tmp/data 24 78 1.461 - rm -f /tmp/data 1.462 -} 1.463 - 1.464 -gotcdfile() 1.465 -{ 1.466 - for i in "/media/cdrom/$1" "/media/cdrom/*/$1" \ 1.467 - "/media/cdrom/*/isolinux/$1"; do 1.468 - file=$(ls $i 2>/dev/null | sed q) 1.469 - [ -s "$file" ] && break 1.470 - done 1.471 -} 1.472 - 1.473 -sha() 1.474 -{ 1.475 - gotcdfile "sha*sum*" 1.476 - sha=$(basename $file) 1.477 - md5 "${sha%sum*}sum -c ${file#/media/cdrom/}" 1.478 -} 1.479 - 1.480 -readme() 1.481 -{ 1.482 - gotcdfile "README*" 1.483 - $DIALOG --clear --title " Readme " --textbox $file 24 78 1.484 -} 1.485 +tty0=tty0 1.486 1.487 bootlog() 1.488 { 1.489 - $DIALOG --clear --title " Linux boot messages " \ 1.490 + dialog --clear --title " Linux boot messages " \ 1.491 --textbox /tmp/dmesg 24 78 1.492 } 1.493 1.494 -bzimage() 1.495 -{ 1.496 - $DIALOG --clear --title " Create linux.exe ? " \ 1.497 - --yes-label "Install" --yesno \ 1.498 -"\nLinux.exe launches the linux kernel under DOS (in real mode only). 1.499 -The cmdline arguments are supported except initrd=, 1.500 -vga= (you can try 'rdev -v') and mem= (partially). 1.501 -\nExample:\nC:\\> linux.exe root=/dev/hda2 ro panic=60\n 1.502 -" 12 70 1.503 - [ $? -eq 0 ] || return 1.504 - cp /media/cdrom/boot/bzImage /mnt/linux.exe 1.505 -} 1.506 - 1.507 -memtest() 1.508 -{ 1.509 - $DIALOG --clear --title " Create memtest.exe ? " \ 1.510 - --yes-label "Install" --yesno \ 1.511 -"\nMemtest86 is a thorough, stand alone memory test for x86 architecture 1.512 -computers. BIOS based memory tests are a quick, cursory check and often 1.513 -miss many of the failures that are detected by Memtest86.\n" 12 70 1.514 - [ $? -eq 0 ] && gotcdfile "memtest*" && cp $file /mnt/memtest.exe 1.515 -} 1.516 - 1.517 -mkfat12() 1.518 -{ 1.519 - [ $(($(get 0 $1) - 0x5A4D)) -eq 0 ] || return 1.520 - J=$(($(get 3 $1 1) + 0x02)) 1.521 - R=$((1 + $(get 497 $1 1) + 1 + ($(get 500 $1)-1)/32)) 1.522 - [ $R -lt 2500 ] || return 1.523 - [ $((($(get 500 $1)-1) & 31)) -lt 30 ] && 1.524 - ddq if=$file bs=32 count=1 seek=$(($R*16 - 1)) of=/dev/fd0 1.525 - G="18 0 2 0 0 0 0 0" 1.526 - [ $J -gt 25 ] || G="" 1.527 - F=0 1.528 - for i in 1 2 3; do 1.529 - F=$((((2880-$R-$F-$F)*3+1023)/1024)) 1.530 - done 1.531 - bytes2bin 0xEB $J 0x90 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 \ 1.532 - 0 2 2 $(($R%256)) $(($R/256)) 2 64 0 64 11 0xF0 $F 0 \ 1.533 - $G | ddq bs=1 of=/dev/fd0 1.534 - ddq if=/dev/zero bs=512 count=$((4+$F+$F)) seek=$R of=/dev/fd0 1.535 - for i in $R $(($R+$F)); do 1.536 - bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0 1.537 - done 1.538 - echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0 1.539 -} 1.540 - 1.541 -mkfloppy() 1.542 -{ 1.543 - dotwait "Create a $(basename $1 .exe) boot floppy" 1.544 - ddq if=$1 of=/dev/fd0 1.545 - mkfat12 $1 1.546 - rm -f /tmp/wait 1.547 -} 1.548 - 1.549 -fdmemtest() 1.550 -{ 1.551 - $DIALOG --clear --title " Create a Memtest86 boot floppy " \ 1.552 - --yes-label "Create floppy" --yesno \ 1.553 -"\nMemtest86 is a thorough, stand alone memory test for x86 architecture 1.554 -computers. BIOS based memory tests are a quick, cursory check and often 1.555 -miss many of the failures that are detected by Memtest86.\n\n 1.556 -Please insert a blank disk in floppy drive.\n" 12 70 1.557 - [ $? -eq 0 ] && gotcdfile "memtest*" && mkfloppy $file 1.558 -} 1.559 - 1.560 -pxe() 1.561 -{ 1.562 - gotcdfile "?pxe*" 1.563 - $DIALOG --clear --title " Create $(basename $file .exe).exe ? " \ 1.564 - --yes-label "Install" --yesno \ 1.565 -"\nBoot your operating system from the internet and enjoy a full system 1.566 -working entirely in RAM with speed and stability in mind. The Linux Kernel 1.567 -and the complete SliTaz compressed root filesystem will be loaded into RAM 1.568 -from the Web using PXE and HTTP protocols.\n" 12 70 1.569 - [ $? -eq 0 ] || return 1.570 - cp $file /mnt/$(basename $file .exe).exe 1.571 -} 1.572 - 1.573 -fdpxe() 1.574 -{ 1.575 - $DIALOG --clear --title " Create a SliTaz Web boot floppy " \ 1.576 - --yes-label "Create floppy" --yesno \ 1.577 -"\nBoot your operating system from the internet and enjoy a full system 1.578 -working entirely in RAM with speed and stability in mind. The Linux Kernel 1.579 -and the complete SliTaz compressed root filesystem will be loaded into RAM 1.580 -from the Web using PXE and HTTP protocols.\n\n 1.581 -Please insert a blank disk in floppy drive.\n" 12 70 1.582 - [ $? -eq 0 ] && gotcdfile "?pxe*" && mkfloppy $file 1.583 -} 1.584 - 1.585 gotposixovl() 1.586 { 1.587 mount.posixovl 2>&1 | grep -qi usage && 1.588 echo -en "\"$1\" \"$2\"" 1.589 } 1.590 1.591 -xfile() 1.592 -{ 1.593 - [ "$(which $1)" ] && echo -en "\"$2\" \"$3\"" 1.594 -} 1.595 - 1.596 -cdfile() 1.597 -{ 1.598 - gotcdfile "$1" && echo -en "\"$2\" \"$3\"" 1.599 -} 1.600 - 1.601 -isbzImage() 1.602 -{ 1.603 - [ $(get 514 $file 4) -eq 1400005704 ] && 1.604 - [ $(($(get 529 $file 1) & 1)) -eq 1 ] 1.605 -} 1.606 - 1.607 -cdfilex() 1.608 -{ 1.609 - gotcdfile "$1" && 1.610 - [ "$(which kexec)" ] && 1.611 - isbzImage && 1.612 - echo -en "\"$2\" \"$3\"" 1.613 -} 1.614 - 1.615 -cdfilef() 1.616 -{ 1.617 - [ -e /sys/block/fd0 ] && cdfile "$@" 1.618 -} 1.619 - 1.620 -cdexe() 1.621 -{ 1.622 - gotcdfile "$1" && 1.623 - [ $(get 0 $file 2>/dev/null || echo 0) -eq 23117 ] && 1.624 - echo -en "\"$2\" \"$3\"" 1.625 -} 1.626 - 1.627 -fddata() 1.628 -{ 1.629 - [ -e /sys/block/fd0 ] && 1.630 - [ $(get 26 /mnt/$ISO 1 2>/dev/null || echo 0) -ne 0 ] && 1.631 - echo -en "\"$1\" \"$2\"" 1.632 -} 1.633 - 1.634 -ishybrid() 1.635 -{ 1.636 - [ $(get 510 $ISO 2>/dev/null || echo 0) -eq 43605 ] || return 1.637 - C=$((2048*$(get $(((17*2048) + 71)) /mnt/$ISO 4))) 1.638 - [ $(get $C /mnt/$ISO 4) -eq 1 ] || return 1.639 - [ $(get $(($C+30)) /mnt/$ISO 4) -eq $((0x88AA55)) ] || return 1.640 - C=$((2048*$(get $(($C+40)) /mnt/$ISO 4))) 1.641 - [ $(get $(($C+64)) /mnt/$ISO 4) -eq 1886961915 ] && 1.642 - echo -en "\"$1\" \"$2\"" 1.643 -} 1.644 - 1.645 -burnable() 1.646 -{ 1.647 - [ "$(sed '/Can wr.*1$/!d' /proc/sys/dev/cdrom/info 2>/dev/null)" ] && 1.648 - [ "$(which wodim)" ] && echo -en "\"$1\" \"$2\"" 1.649 -} 1.650 - 1.651 -blankable() 1.652 -{ 1.653 - [ "$(sed '/Can wr.*RW.*1$/!d' /proc/sys/dev/cdrom/info 2>/dev/null)" ] && 1.654 - [ "$(which wodim)" ] && echo -en "\"$1\" \"$2\"" 1.655 -} 1.656 - 1.657 -burniso() 1.658 -{ 1.659 - wodim -v speed=$(fgrep "drive speed" /proc/sys/dev/cdrom/info | cut -f3) \ 1.660 - -eject -multi "$ISO" 1.661 -} 1.662 - 1.663 -blankcd() 1.664 -{ 1.665 - wodim -v -blank=fast 1.666 -} 1.667 - 1.668 -customsector() 1.669 -{ 1.670 - echo $(get 32848 "/mnt/$ISO" 4) 1.671 -} 1.672 - 1.673 -hascustomconf() 1.674 -{ 1.675 - [ "$(ddq bs=2k skip=$(customsector) if="/mnt/$ISO" | ddq bs=1 count=6)" \ 1.676 - = "#!boot" ] 1.677 -} 1.678 - 1.679 -gotcustomconf() 1.680 -{ 1.681 - hascustomconf && echo -en "\"$1\" \"$2\"" 1.682 -} 1.683 - 1.684 -getcustomconf() 1.685 -{ 1.686 - cd ${1:-/mnt} 1.687 - ddq bs=2k skip=$(customsector) if="/mnt/$ISO" | while read line; do 1.688 - case "$line" in 1.689 - \#!boot*);; 1.690 - append=*) echo ${line#append=} > cmdline && ls -l cmdline;; 1.691 - initrd:*) cnt=${line#initrd:} 1.692 - { ddq bs=512 count=$(($cnt / 512)); 1.693 - ddq bs=1 count=$(($cnt % 512)); } > initrd && 1.694 - ls -l initrd 1.695 - break;; 1.696 - *) break;; 1.697 - esac 1.698 - done 1.699 - cd - > /dev/null 1.700 - [ -z "$1" ] && echo -e "\rPress RETURN to continue." && read n 1.701 -} 1.702 - 1.703 -gotisomd5() 1.704 -{ 1.705 - [ "$(which md5sum 2>/dev/null)" ] && 1.706 - [ $(get 0 /mnt/$ISO) -eq 23117 ] && 1.707 - [ $(get 18 /mnt/$ISO) -ne 0 ] && echo -en "\"$1\" \"$2\"" 1.708 -} 1.709 - 1.710 -isomd5() 1.711 -{ 1.712 - dotwait "Checking iso image" 1.713 - [ "$(ddq if=/mnt/$ISO bs=2k skip=16 \ 1.714 - count=$(($(get 32848 /mnt/$ISO 4)-16)) | md5sum)" = \ 1.715 - "$(ddq if=/mnt/$ISO bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \ 1.716 - sed 's/ //g') -" ] && echo "OK" || echo "ERROR" 1.717 - echo -en "\rChecking iso hybrid boot..." 1.718 - n=$(($(get 2 /mnt/$ISO)-1+($(get 4 /mnt/$ISO)-1)*512)) 1.719 - if [ $n -lt 40000 -a $n -gt 32768 ]; then 1.720 - s=$(get 0 /mnt/$ISO 2 $n | awk '{ i+= $0 } END { print i }') 1.721 - [ $(((1+$s+$(get $(($n+1)) /mnt/$ISO 1)) % 65536)) -eq 0 ] && 1.722 - echo "OK" || echo "ERROR" 1.723 - fi 1.724 - if hascustomconf; then 1.725 - echo -en "\rChecking iso custom config..." 1.726 - TMP=/tmp/$(basename $0)$$md5 1.727 - md5="$(ddq bs=2k skip=$(customsector) if=/mnt/$ISO | while read line; do 1.728 - case "$line" in 1.729 - \#!boot*) echo ${line#*boot } > $TMP;; 1.730 - append=*) echo $line;; 1.731 - initrd:*) echo $line 1.732 - cnt=${line#initrd:} 1.733 - ddq bs=512 count=$((cnt / 512)) 1.734 - ddq bs=1 count=$((cnt % 512)) 1.735 - break;; 1.736 - *) break;; 1.737 - esac 1.738 - done | md5sum | cut -c1-32)" 1.739 - [ "$md5" = "$(cat $TMP)" ] && echo "OK" || echo "ERROR" 1.740 - rm -f $TMP 1.741 - fi 1.742 - rm -f /tmp/wait 1.743 - echo -e "\rPress RETURN to continue." 1.744 - read n 1.745 -} 1.746 - 1.747 -if [ "$1" = "--build" ]; then #install-begin 1.748 - cp $0 $0.tmp 1.749 - uuencode -m - < header.com | sed -e '/^HEADERCODE$/r/dev/stdin' \ 1.750 - -e "s|HEADERSZ|$(stat -c %s header.com)|" -e '/^HEADERCODE$/d' -i $0.tmp 1.751 - uuencode -m - < ifmem.bin | sed -e 's|^[ \t]*||;s|[ \t]*###.*||' \ 1.752 - -e 's| *;;|;;|;s|\t\t*|\t|g' \ 1.753 - -e '/^ifmemcode$/r/dev/stdin' -e '/^ifmemcode$/d' -i $0.tmp 1.754 - uuencode -m - < bootloader.bin | sed -e '/^bootloader$/r/dev/stdin' \ 1.755 - -e '/^bootloader$/d' -e '/install-begin$/,/install-end$/d' -i $0.tmp 1.756 - mv -f $0.tmp $0; exit 1.757 -fi #install-end 1.758 -parse_isolinux() 1.759 -{ 1.760 - awk 'BEGIN { IGNORECASE=1 } 1.761 -function multi(n) 1.762 -{ 1.763 - auto=$n 1.764 - for (--n; n < NF; n+=2) { 1.765 - s=$n 1.766 - if (s ~ /M$/) s = substr(s,0,length(s)-1) 1.767 - else s /= 1024 1.768 - sizes=int(s) " " sizes 1.769 - } 1.770 - next 1.771 -} 1.772 -{ 1.773 - if ($1 == "LABEL") { 1.774 - label=$2 1.775 - if (auto == "") auto=label 1.776 - } 1.777 - if ($1 == "KERNEL" || $1 == "COM32") kernel[label]=$2 1.778 - if ($1 == "INITRD") initrd[label]=$2 1.779 - if ($1 == "APPEND") { 1.780 - i=2 1.781 - if (kernel[label] ~ "ifmem.c32") multi(3) 1.782 - if (kernel[label] ~ "c32box.c32") { 1.783 - if ($2 == "linux") { kernel[label]=$3; i=4 } 1.784 - if ($2 == "ifmem") multi(4) 1.785 - } 1.786 - if (kernel[label] ~ "ifcpu64.c32") { auto=$4; next } 1.787 - while (i <= NF) { 1.788 - if ($i ~ "^initrd=") initrd[label]=substr($i,8) 1.789 - else cmdline[label]=cmdline[label] " " $i 1.790 - i++ 1.791 - } 1.792 - } 1.793 -} 1.794 -END { 1.795 - print "KERNEL=\"" kernel[auto] "\"" 1.796 - print "INITRD=\"" initrd[auto] "\"" 1.797 - print "CMDLINE=\"" substr(cmdline[auto],2) "\"" 1.798 - print "SIZES=\"" sizes "\"" 1.799 -}' 1.800 -} 1.801 - 1.802 -locase() 1.803 -{ 1.804 - echo "$1" | tr [A-Z] [a-z] 1.805 -} 1.806 - 1.807 -ifmemcode() 1.808 -{ 1.809 - uudecode <<EOT 1.810 -ifmemcode 1.811 -EOT 1.812 -} 1.813 - 1.814 -floppyset() 1.815 -{ 1.816 - gotcdfile isolinux.cfg 1.817 - parse_isolinux < $file > /tmp/var$$ 1.818 - . /tmp/var$$ 1.819 - for i in /media/cdrom/$KERNEL $(dirname $file)/$KERNEL /media/cdrom/$(locase $KERNEL) \ 1.820 - $(dirname $file)/$(locase $KERNEL); do 1.821 - [ -s $i ] && KERNEL=$i && break 1.822 - done 1.823 - rm -f /tmp/var$$ 1.824 - [ $(get 514 $KERNEL 4) -eq 1400005704 ] || return 1.825 - n=$(($(get 497 $KERNEL 1)+1)) 1.826 - ddq bs=512 count=$n if=$KERNEL of=/tmp/fd$$ 1.827 - uudecode <<EOT | ddq of=/tmp/fd$$ conv=notrunc 1.828 -bootloader 1.829 -EOT 1.830 - pos=$(($n*512)) 1.831 - if [ -n "$CMDLINE" ]; then 1.832 - echo -n "$CMDLINE" | ddq bs=512 count=1 conv=sync >> /tmp/fd$$ 1.833 - bytes2bin $n | ddq conv=notrunc \ 1.834 - bs=1 seek=497 count=1 of=/tmp/fd$$ 1.835 - words2bin $pos | ddq conv=notrunc \ 1.836 - bs=1 seek=34 count=2 of=/tmp/fd$$ 1.837 - [ $(get 518 $KERNEL 4) -ge 514 ] && 1.838 - words2bin 32768 9 | ddq conv=notrunc \ 1.839 - bs=1 seek=552 count=4 of=/tmp/fd$$ 1.840 - fi 1.841 - syssize=$(echo $(get 500 /tmp/fd$$ 4)) 1.842 - ddq bs=512 skip=$n if=$KERNEL | cat - /dev/zero | \ 1.843 - ddq bs=512 count=$((($syssize+31)/32)) conv=sync >> /tmp/fd$$ 1.844 - base=$(stat -c %s /tmp/fd$$) 1.845 - len= 1.846 - if [ "$INITRD" ]; then 1.847 - l=0 1.848 - for i in ${INITRD//,/ }; do 1.849 - for j in /media/cdrom/$i $(dirname $KERNEL)/$i /media/cdrom/$(locase $i) \ 1.850 - $(dirname $KERNEL)/$(locase $i); do 1.851 - [ -s $j ] && i=$j && break 1.852 - done 1.853 - ddq if=$i >> /tmp/fd$$ 1.854 - l=$(($l+$(stat -c %s $i))) 1.855 - r=$((4 - ($l % 4))) 1.856 - if [ $r -ne 4 ]; then 1.857 - ddq if=/dev/zero bs=1 count=$r >> /tmp/fd$$ 1.858 - l=$(($l + $r)) 1.859 - fi 1.860 - case "$i:$INITRD" in 1.861 - *rootfs.gz:*rootfs.gz,*) continue ### loram 1.862 - esac 1.863 - len="$len $l"; l=0 1.864 - done 1.865 - rdadrs=${RDADRS:-$(((($syssize*16)+0x1F0000) & -4096))} 1.866 - words2bin $(($rdadrs & 0xFFFF)) $(($rdadrs >> 16)) | ddq \ 1.867 - conv=notrunc bs=1 seek=536 count=4 of=/tmp/fd$$ 1.868 - fi 1.869 - n=$(echo $len | wc -w) 1.870 - if [ $((494 - $(get 494 /tmp/fd$$))) -ge $(($n * 4)) ]; then 1.871 - i=$(($(get 494 /tmp/fd$$))) 1.872 - bytes2bin $(($i + ($n*4) - 256)) | ddq bs=1 conv=notrunc \ 1.873 - seek=496 count=1 of=/tmp/fd$$ 1.874 - else 1.875 - i=$(($pos + 0x1FC - ($n*4))) 1.876 - bytes2bin $(($i % 256)) $((i / 256)) 252 | ddq bs=1 \ 1.877 - conv=notrunc seek=494 count=3 of=/tmp/fd$$ 1.878 - s=$(($i - 2*$(echo "$SIZES" | wc -w))) 1.879 - p=$(($s - $(ifmemcode | wc -c))) 1.880 - ifmemcode | ddq bs=1 conv=notrunc seek=$p of=/tmp/fd$$ 1.881 - words2bin $SIZES | ddq bs=1 conv=notrunc seek=$s of=/tmp/fd$$ 1.882 - bytes2bin 154 $(($p%256)) $(($p/256)) 0 144 | \ 1.883 - ddq bs=1 conv=notrunc seek=60 of=/tmp/fd$$ 1.884 - fi 1.885 - for r in $len; do 1.886 - words2bin $(($r & 0xFFFF)) $(($r >> 16)) | ddq conv=notrunc \ 1.887 - bs=1 seek=$i count=4 of=/tmp/fd$$ 1.888 - i=$(($i + 4)) 1.889 - done 1.890 - split -b 1440k /tmp/fd$$ fd$$ 1.891 - rm -f /tmp/fd$$ 1.892 - n=1; i=0; r=0 1.893 - set -- $len 1.894 - ls fd$$* | while read file; do 1.895 - if [ $i -gt $(($1+$base)) ]; then 1.896 - shift 1.897 - r=$(($r+100)); n=0; i=0; base=0 1.898 - fi 1.899 - ddq of=$file bs=18k seek=80 count=0 1.900 - i=$(($i+1474560)) 1.901 - printf "mv %s fd%03d.img\n" $file $(($r+$n)) 1.902 - n=$(($n+1)) 1.903 - done | sh 1.904 - ls fd???.img 1.905 - mv fd???.img /mnt 1.906 -} 1.907 - 1.908 -fdbootstrap() 1.909 -{ 1.910 - sz=$((512 * $(echo $(get 26 /mnt/$ISO 1)))) 1.911 - $DIALOG --clear --title " Create a floppy bootstrap " \ 1.912 - --yes-label "Continue" --yesno \ 1.913 -"\nThe floppy will install a driver to access the ISO file 1.914 -on your hard disk and will emulate a CD-ROM during the boot process.\n\n 1.915 -Please insert a floppy in drive now.\n" 10 70 1.916 - [ $? -eq 0 ] || return 1.917 - ddq if=/mnt/$ISO of=/tmp/bootiso bs=1 count=512 \ 1.918 - skip=$(( $(get 64 /mnt/$ISO) - $sz )) 1.919 - echo "$ISO" | ddq of=/tmp/bootiso bs=512 seek=1 count=1 1.920 - ddq if=/mnt/$ISO of=/tmp/bootiso bs=1 count=$sz seek=2 \ 1.921 - skip=$(( $(get 64 /mnt/$ISO) - $sz + 512 )) 1.922 - mkfloppy /tmp/bootiso 1.923 - rm -f /tmp/bootiso 1.924 -} 1.925 - 1.926 -usbdev() 1.927 -{ 1.928 - dotwait "Wait 5 seconds for USB devices" 1.929 - sleep 5 1.930 - rm -f /tmp/wait 1.931 - DEV="$(grep -l 1 /sys/block/*/removable | \ 1.932 - sed 's|/sys/block/\(.*\)/removable|\1|')" 1.933 - grep -qs 1 /sys/block/$DEV/ro && return 1.934 - [ "$DEV" ] || return 1.935 - cat > /tmp/dialog <<EOT 1.936 -$DIALOG --clear --title " Select your USB key " \ 1.937 - --menu "\nPlease select the USB key according to its known size.\n\n" \ 1.938 - 14 70 4 \ 1.939 - $(for i in $DEV; do 1.940 - echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2>/dev/null)\" " 1.941 - done) 1.942 -EOT 1.943 - exec 3>&1 1.944 - device=$(. /tmp/dialog 2>&1 1>&3) 1.945 - retval=$? 1.946 - exec 3>&- 1.947 - [ $retval -eq 0 ] 1.948 -} 1.949 - 1.950 -tazusbmsg() 1.951 -{ 1.952 - [ "$(which tazusb 2>/dev/null)" ] || return 1.953 - echo "You should choose 'USB key read/write installation' to be 1.954 -able to save the package updates or your own configuration and data files.\n\n" 1.955 -} 1.956 - 1.957 -usbbootkey() 1.958 -{ 1.959 - $DIALOG --clear --title " Create a USB boot key " \ 1.960 - --yes-label "Continue" --yesno \ 1.961 -"\nThe USB key will be used like a CD-ROM. You will not be able to write 1.962 -any data on the boot partition.\n\n 1.963 -An extra FAT32 partition will be created with the remaining free space.\n\n 1.964 -$(tazusbmsg)Please plug your USB stick in now.\n" 16 70 1.965 - [ $? -eq 0 ] || return 1.966 - usbdev || return 1.967 - 1.968 - ### perform dd in progress bar 1.969 - max=$(($(cat /sys/block/loop0/size)/2048)) 1.970 - i=0; ddq if=/mnt/$ISO bs=1024k | ( 1.971 - while ddq bs=1024k count=1; do 1.972 - i=$(($i + 1)) 1.973 - [ $i -gt $max ] && break 1.974 - echo $((($i*100)/$max)) | dialog --gauge \ 1.975 - " The ISO image transfer can be long. Please wait..." \ 1.976 - 6 70 0 > /dev/tty0 2>&1 1.977 - done ) > $device 1.978 - 1.979 - ### partition + fat32 format for the remaining space 1.980 - for p in 0 16; do 1.981 - get $((450+$p)) $device 2 12 | xargs echo | { 1.982 - read dx cx ol oh ll lh 1.983 - [ $dx -eq $((0x3F17)) ] || continue 1.984 - cx=$(($cx & 0xFF00)) 1.985 - ofs=$(($ll+($lh<<16))) 1.986 - n=$(($(cat /sys/block/${device#/dev/}/size)-$ofs)) 1.987 - m=$(($cx+($n/8))) 1.988 - [ $m -gt $((0x3FF00)) ] && m=$((0x3FF00)) 1.989 - m=$((($m & 0xFF00)+(($m>>16)<<6))) 1.990 - words2bin 0 $((0x101+$cx)) 0x3F0B $((32+$m)) \ 1.991 - $ll $lh $(($n & 0xFFFF)) $(($n >> 16)) | \ 1.992 - ddq bs=1 seek=$((462-$p)) of=$device 1.993 - if [ "$(which mkdosfs 2>/dev/null)" ]; then 1.994 - losetup -o $((512*$ofs)) /dev/loop2 $device 1.995 - mkdosfs -n "SLITAZ BOOT" /dev/loop2 1.996 - words2bin $(($ofs & 0xFFFF)) $(($ofs >> 16)) | \ 1.997 - ddq bs=1 seek=28 of=/dev/loop2 1.998 - sync 1.999 - losetup -d /dev/loop2 1.1000 - fi 1.1001 - } 1.1002 - done 1.1003 -} 1.1004 - 1.1005 -usbkey() 1.1006 -{ 1.1007 - $DIALOG --clear --title " Create a SliTaz USB key " \ 1.1008 - --yes-label "Continue" --yesno \ 1.1009 -"\nUnlike a hard drive install, the filesystem is kept in a compressed 1.1010 -rootfs.gz. The filesystem is loaded entirely into memory upon boot. 1.1011 -This should increase responsiveness, protect the filesystem against 1.1012 -accidental corruption and reduce read/writes to the USB drive. 1.1013 -Once setup, the tazusb utility can rewrite the root filesystem 1.1014 -with any changes you have made since booting up, 1.1015 -giving the effective benefits of a hard drive install.\n\n 1.1016 -/home is mounted on boot using the UUID of your particular flash drive. 1.1017 -Unlike a device name, the UUID has the benefit of never changing from machine 1.1018 -to machine.\n\n 1.1019 -Please plug your USB stick in now.\n" 19 70 1.1020 - [ $? -eq 0 ] || return 1.1021 - usbdev || return 1.1022 - exec 3>&1 1.1023 - format=`$DIALOG --clear --title " Select the filesystem " \ 1.1024 - --radiolist "\nPlease select the filesystem type to create.\n\n\ 1.1025 -The filesystem creation will erase all the data \ 1.1026 -in the USB key." 14 70 4 \ 1.1027 - "none" "Do not erase the USB key" on \ 1.1028 - "ext3" "Ext3 journaling filesystem" off \ 1.1029 - "ext2" "Ext2 filesystem" off \ 1.1030 - "fat32" "Windows FAT32 filesystem" off \ 1.1031 - 2>&1 1>&3` 1.1032 - retval=$? 1.1033 - exec 3>&- 1.1034 - [ $retval -eq 0 ] || return 1.1035 - [ "$format" != "none" ] && tazusb format $device "SliTaz" $format 1.1036 - tazusb gen-iso2usb /mnt/$ISO $device 1.1037 -} 1.1038 +myis_loram() 1.1039 +{ 1.1040 + [ -s /lib/modules/squashfs.ko* ] 1.1041 +} 1.1042 1.1043 mount_loram() 1.1044 { 1.1045 - is_loram || return 1.1046 + myis_loram || return 1.1047 insmod /lib/modules/squashfs.ko* 2>/dev/null 1.1048 - if [ -d /media/cdrom/fs ]; then 1.1049 - ln -s /media/cdrom/fs /sqfs 1.1050 + if [ -d $media/fs ]; then 1.1051 + ln -s $media/fs /sqfs 1.1052 else 1.1053 mkdir /sqfs 1.1054 - losetup -o 124 /dev/loop6 $(ls_r /media/cdrom/boot/rootfs?*.* | sed q) 1.1055 + losetup -o 124 /dev/loop6 $(ls_r $media/boot/rootfs?*.* | sed q) 1.1056 mount -r /dev/loop6 /sqfs 1.1057 fi 1.1058 cp -a /sqfs/dev/fuse /sqfs/dev/tty[12] /sqfs/dev/[hs]d* /dev 1.1059 @@ -1051,7 +102,7 @@ 1.1060 1.1061 umount_loram() 1.1062 { 1.1063 - is_loram || return 1.1064 + myis_loram || return 1.1065 rm /var /usr 1.1066 umount -d /sqfs 1.1067 rmdir /sqfs 2>/dev/null || rm -f /sqfs 1.1068 @@ -1062,15 +113,15 @@ 1.1069 { 1.1070 sync 1.1071 umount_loram 1.1072 - umount -d /media/cdrom 1.1073 + umount -d $media 1.1074 rm -f /dev/cdrom 1.1075 - umount /mnt 1.1076 + umount $mnt 1.1077 umount_proc 1.1078 } 1.1079 1.1080 text() 1.1081 { 1.1082 - uncpio $(ls_r /media/cdrom/boot/rootfs?*.* | sed q) 1.1083 + $uncpio $(ls_r $media/boot/rootfs?*.* | sed q) 1.1084 init= 1.1085 cmdline="$(cat /proc/cmdline)" 1.1086 if hascustomconf; then 1.1087 @@ -1078,7 +129,7 @@ 1.1088 [ -s /tmp/cmdline ] && 1.1089 cmdline="$cmdline $(cat /tmp/cmdline)" && 1.1090 init="$(sed '/rdinit=/!d;s/.*rdinit=\([^ ]*\).*/\1/' < /tmp/cmdline)" 1.1091 - [ -s /tmp/initrd ] && uncpio /tmp/initrd 1.1092 + [ -s /tmp/initrd ] && $uncpio /tmp/initrd 1.1093 fi 1.1094 dosync 1.1095 sed -i 's/ || exit//' /init 1.1096 @@ -1089,8 +140,8 @@ 1.1097 { 1.1098 n=0 1.1099 dotwait "Extract filesystem..." 1.1100 - for i in $(ls_r /media/cdrom/boot/rootfs*); do 1.1101 - [ $((n++)) -eq 0 ] || uncpio $i 1.1102 + for i in $(ls_r $media/boot/rootfs*); do 1.1103 + [ $((n++)) -eq 0 ] || $uncpio $i 1.1104 done 1.1105 rm -f /tmp/wait 1.1106 text 1.1107 @@ -1125,45 +176,6 @@ 1.1108 gotcdfile "?pxe*" && dokexec 1.1109 } 1.1110 1.1111 -flavdata() 1.1112 -{ 1.1113 - [ $(get 1024 /mnt/$ISO) -eq 35615 ] && n=2 || 1.1114 - n=$((1+$(get 417 /mnt/$ISO 1))) 1.1115 - [ $n -eq 4 ] && n=20 1.1116 - [ $(get $(($n*512)) /mnt/$ISO) -eq 35615 ] || n=13 1.1117 - ddq if=/mnt/$ISO bs=512 skip=$n count=20 | zcat 2>/dev/null 1.1118 -} 1.1119 - 1.1120 -hasflavinfo() 1.1121 -{ 1.1122 - [ "$(flavdata | ddq bs=1 count=7)" = "0707010" ] && 1.1123 - echo -en "\"$1\" \"$2\"" 1.1124 -} 1.1125 - 1.1126 -showfavinfo() 1.1127 -{ 1.1128 - mkdir -p /tmp/data 1.1129 - flavdata | ( cd /tmp/data; cpio -i ) 1.1130 - file=/tmp/data/info 1.1131 - cat /tmp/data/*desc > $file 1.1132 - for i in /tmp/data/*list*; do 1.1133 - echo "=== extra ${i#*list} files" 1.1134 - cat $i 1.1135 - done >> $file 1.1136 - $DIALOG --clear --title " Flavor info " --textbox $file 24 78 1.1137 - rm -rf /tmp/data 1.1138 -} 1.1139 - 1.1140 -flavor() 1.1141 -{ 1.1142 - cd /mnt 1.1143 - name="$(flavdata | cpio -t 2>/dev/null | sed 's/.[a-z]*$//;q')" 1.1144 - echo "Create ${name:=flavor}.flavor..." 1.1145 - tazlito iso2flavor "/mnt/$ISO" $name 1.1146 - ls -l $name.flavor 2>/dev/null || sleep 5 1.1147 - cd - > /dev/null 1.1148 -} 1.1149 - 1.1150 shell() 1.1151 { 1.1152 trap text 2 1.1153 @@ -1184,59 +196,6 @@ 1.1154 ISO="$(getarg bootfrom | sed 's/.://;s|\\|/|g')" 1.1155 getiso 2>/dev/null || text 1.1156 mount_loram 1.1157 -case "${ISO##*/}$(getarg mode)" in 1.1158 -*install*|*INSTALL*) install;; 1.1159 -*live*|*LIVE*) live;; 1.1160 -*text*|*TEXT*) text;; 1.1161 -esac 1.1162 -which $DIALOG 2>/dev/null || DIALOG=tinydialog 1.1163 -dmesg > /tmp/dmesg 1.1164 +[ -s /usr/bin/taziso ] || live 1.1165 1.1166 -isotitle="$(blkid /mnt/$ISO | sed 's/.*LABEL="\([^"]*\).*/\1/') $(stat \ 1.1167 - -c %y /media/cdrom | sed 's/ .*//') $(basename $ISO)" 1.1168 -while true; do 1.1169 - trap shell 2 1.1170 - keymap="$(cat /etc/keymap.conf 2>/dev/null)" 1.1171 - locale="$(sed '/^LANG=/!d;s/.*=//' /etc/locale.conf 2>/dev/null)" 1.1172 - cat > /tmp/dialog <<EOT 1.1173 -$DIALOG --clear --title " ${isotitle:-Welcome to Linux} " \ 1.1174 - --menu "" 23 70 17 \ 1.1175 -$(xfile tazkeymap "tazkeymap" "Select keyboard (${keymap:-none})") \ 1.1176 -$(xfile tazlocale "tazlocale" "Select locale (${locale:-none})") \ 1.1177 -$(cdfile boot/bzImage "live" "Linux RAM boot (full desktop)") \ 1.1178 - "text" "Linux RAM boot" \ 1.1179 -$(cdfile "README*" "readme" "Show the README file") \ 1.1180 -$(gotcustomconf "getcustomconf" "Get custom config") \ 1.1181 -$(gotisomd5 "isomd5" "Check the ISO image") \ 1.1182 -$(cdfile "md5sum*" "md5" "Check the ISO files") \ 1.1183 -$(cdfile "sha*sum*" "sha" "Check the ISO files") \ 1.1184 -$(burnable "burniso" "Burn the ISO image") \ 1.1185 -$(blankable "blankcd" "Blank the CD/DVD") \ 1.1186 -$(gotposixovl "install" "Hard disk installation (UMSDOS way)") \ 1.1187 -$(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \ 1.1188 -$(xfile tazusb "usbkey" "USB key read/write installation") \ 1.1189 -$(ishybrid "usbbootkey" "USB boot key (read only)") \ 1.1190 -$(hasflavinfo "showfavinfo" "Show flavor extra info") \ 1.1191 -$(xfile tazlito "flavor" "Get flavor file") \ 1.1192 -$(fddata "fdbootstrap" "Create a floppy bootstrap") \ 1.1193 -$(cdfile isolinux.cfg "floppyset" "Boot floppy set") \ 1.1194 -$(cdfile linld.com "tazboot" "Get tazboot.exe Linux loader") \ 1.1195 -$(cdexe boot/bzImage "bzimage" "Get linux DOS/EXE file") \ 1.1196 -$(cdexe "memtest*" "memtest" "Get Memtest86 DOS/EXE file") \ 1.1197 -$(cdfilef "memtest*" "fdmemtest" "Create a Memtest86 boot floppy") \ 1.1198 -$(:||cdfilex "memtest*" "runmemtest" "Start Memtest86") \ 1.1199 -$(cdexe "?pxe*" "pxe" "Get SliTaz Web boot DOS/EXE utility") \ 1.1200 -$(cdfilef "?pxe*" "fdpxe" "Create a SliTaz Web boot floppy") \ 1.1201 -$(:||cdfilex "?pxe*" "runpxe" "Start the SliTaz Web boot utility") \ 1.1202 -$(xfile reboot "restart" "Restart the computer") \ 1.1203 -$(xfile poweroff "stop" "Power off") \ 1.1204 - "bootlog" "Linux boot messages" \ 1.1205 - "shell" "Shell prompt" 1.1206 -EOT 1.1207 - exec 3>&1 1.1208 - value=$(. /tmp/dialog 2>&1 1>&3) 1.1209 - retval=$? 1.1210 - exec 3>&- 1.1211 - [ $retval -eq 0 ] || continue 1.1212 - $value 1.1213 -done 1.1214 +. /usr/bin/taziso