slitaz-tools rev 474 3.8
bootfloppybox: create floppies from iso
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Mar 28 17:06:09 2010 +0200 (2010-03-28) |
parents | 18e9aa75b89b |
children | 694ff35aa085 |
files | tinyutils/bootfloppybox |
line diff
1.1 --- a/tinyutils/bootfloppybox Sun Mar 28 15:29:38 2010 +0200 1.2 +++ b/tinyutils/bootfloppybox Sun Mar 28 17:06:09 2010 +0200 1.3 @@ -2,7 +2,7 @@ 1.4 # 1.5 # Gtkdialog box for the mount command. Part of SliTaz tools. 1.6 # 1.7 -VERSION=20081121 1.8 +VERSION=20100328 1.9 1.10 # Check if user is root. 1.11 check_root() 1.12 @@ -28,19 +28,32 @@ 1.13 esac 1.14 } 1.15 1.16 +# check or list floppy devices. 1.17 +list_floppy() 1.18 +{ 1.19 + local list 1.20 + list="" 1.21 + for i in /sys/devices/platform/floppy.*/block:*; do 1.22 + [ -d $i ] || continue 1.23 + list="$list ${i#*block:}" 1.24 + done 1.25 + [ -n "$1" ] || echo $list 1.26 + [ -n "$list" ] 1.27 +} 1.28 + 1.29 +# dialog to select the floppy device 1.30 select_floppy() 1.31 { 1.32 DEVICE="$DIALOG --title \" Floppy device \" --backtitle \"Boot Floppy Creation\" --clear --extra-button --extra-label \"Format\" --colors --radiolist \" 1.33 Select boot device 1.34 \" 18 70 50" 1.35 on=on 1.36 - for i in /sys/devices/platform/floppy.*/block:*; do 1.37 - [ -d $i ] || continue 1.38 - DEVICE="$DEVICE /dev/${i#*block:} 'Floppy in ${i#*block:}' $on" 1.39 + for i in $(list_floppy); do 1.40 + DEVICE="$DEVICE /dev/$i 'Floppy in $i' $on" 1.41 on=off 1.42 done 1.43 - DEVICE="$DEVICE floppy \"cdrom image file boot.iso\" $on" 1.44 - DEVICE="$DEVICE cdrom \"floppy image file boot.fd\" off 2>&1 1>&3" 1.45 + DEVICE="$DEVICE floppy \"floppy image file boot.fd\" $on" 1.46 + DEVICE="$DEVICE cdrom \"cdrom image file boot.iso\" off 2>&1 1>&3" 1.47 exec 3>&1 1.48 DEVICE=`eval $DEVICE` 1.49 retval=$? 1.50 @@ -53,6 +66,7 @@ 1.51 fi 1.52 } 1.53 1.54 +# Build menu for grub or grub4dos 1.55 mkmenu() 1.56 { 1.57 if [ "$1" = "grub4dos" ]; then 1.58 @@ -159,6 +173,7 @@ 1.59 EOT 1.60 } 1.61 1.62 +# Install grub or grub4dos on floppy 1.63 install_grub() 1.64 { 1.65 LOOP="" 1.66 @@ -218,6 +233,57 @@ 1.67 esac 1.68 } 1.69 1.70 +# Build /init for floppies from iso image 1.71 +buildinit() 1.72 +{ 1.73 + mv $1/init $1/init.org 1.74 + cat > $1/init <<EOTEOT 1.75 +#!/bin/sh 1.76 + 1.77 +mount -t proc proc /proc 1.78 +total=\$(grep MemTotal /proc/meminfo | sed 's/[^0-9]//g') 1.79 +# the floppy driver may not be included in kernel 1.80 +insmod /lib/modules/*/kernel/drivers/block/floppy.ko.gz 2> /dev/null 1.81 +# loram may put floppy.ko.gz module in /lib 1.82 +insmod /lib/floppy.ko.gz 2> /dev/null 1.83 +umount /proc 1.84 +while read name min num count file md5; do 1.85 + [ -e \$file ] && continue 1.86 + [ \$total -lt \$min ] && break 1.87 + while [ \$count -ne 0 ]; do 1.88 + tmp="\$(dd if=/dev/fd0 count=1 2> /dev/null | md5sum)" 1.89 + echo -n "Insert floppy \$num for \$name and press Enter or Q to skip" 1.90 + while true; do 1.91 + echo -n ":" 1.92 + read -t 10 answer < /dev/tty0 1.93 + case "\$answer" in 1.94 + Q*|q*|A*|a*) break 3;; 1.95 + esac 1.96 + dd if=/dev/fd0 count=1 > /tmp/bs.\$\$ 2> /dev/null 1.97 + [ -s /tmp/bs.\$\$ ] || continue 1.98 + [ "\$(md5sum < /tmp/bs.\$\$)" != "\$tmp" ] || continue 1.99 + rm -f /tmp/bs.\$\$ 1.100 + break 1.101 + done 1.102 + dd if=/dev/fd0 of=/tmp/rootfs.\$num 2> /dev/null || continue 1.103 + cat /tmp/rootfs.\$num >> /tmp/rootfs 1.104 + rm -f /tmp/rootfs.\$num 1.105 + num=\$((\$num+1)) 1.106 + count=\$((\$count-1)) 1.107 + done 1.108 + echo "\$md5 /tmp/rootfs" | md5sum -c || break 1.109 + cpio -idmu < /tmp/rootfs > /dev/null 2>&1 || 1.110 + ( zcat /tmp/rootfs 2> /dev/null || unlzma -c /tmp/rootfs ) | cpio -idmu 1.111 + rm -f /tmp/rootfs* 1.112 +done <<EOT 1.113 +$(while read line; do echo $line; done) 1.114 +EOT 1.115 +mv -f /init.org /init || sh 1.116 +exec /init 1.117 +EOTEOT 1.118 + chmod +x $1/init 1.119 +} 1.120 + 1.121 # write a 32 bits data 1.122 # usage: storelong offset data32 file 1.123 storelong() 1.124 @@ -236,7 +302,8 @@ 1.125 hexdump -e '"" 1/4 "%d" "\n"' 1.126 } 1.127 1.128 -floppyset() 1.129 +# output floppy images set 1.130 +floppysetcat() 1.131 { 1.132 KERNEL="$1" 1.133 INITRD="$2" 1.134 @@ -262,17 +329,17 @@ 1.135 dd if=$KERNEL bs=512 count=1 of=$bs 2> /dev/null 1.136 uudecode <<EOT | dd of=$bs conv=notrunc 2> /dev/null 1.137 begin-base64 644 - 1.138 -v/Sd/GgAkAcxyQYXify7eACO2cU3sQbzpY7ZiSeMRwKg8X2YQAYfxkX4P/qz 1.139 -GFFLdfyXmEHoPgG+AAKATBGAx0QkAJwDdA7oZAG+KAI5HHIuR4scVuhAAV+L 1.140 -NehQAbAgzRCwCM0QTpjNFjwIdAOIBK07NXTy6CoBPAp14oh8/onmsA+/9AH+ 1.141 -TRyxBbSTiUQcsAGJRBSZiVQQiVQYZjHbQ9PjS2YDHWbT62gAEAe/gAAp+5xz 1.142 -AgHfU1Yx2+jaAF65AIC0h/5EHM0VW5133KEaAki/HAKxCThEHHKwMcDNE+oA 1.143 -ACCQsEYoyL65AejCAF3rKYD5E3IEOMF3boD+AnIEOOZ3b4D9UHN5YIH9AAZ0 1.144 -JwZSUVOWtAJQuQYAUbEEwcUEsA8h6ASQJxRAJ+h1AOLusCDNEFnirpjNE2Ex 1.145 -9q2RrZKtUCjIdwKwAZg5+HICifhQUrQCzRNalV5YcpYp9wHxweYJAfM4wXUm 1.146 -iMj+xrEBOOZ1HIj0/sW2ADwTdRKA/VByDbUAYL68AegkAJjNFmGjBABSUWaP 1.147 -BgAACf91nhYHsDEsA7QOuwcAzRA8DXTzw7AN6O//rAjAdfjDWDoASW5zZXJ0 1.148 -IG5leHQgZmxvcHB5IGFuZCBwcmVzcyBhbnkga2V5IHRvIGNvbnRpbnVlLgcN 1.149 +/L+6nWgAkAcGF4n8McC5HQDzq1sfD6mg8X1ABlfFd3ixBvOlZWaPR3gGH8ZF 1.150 ++D/6l1hB6CsBvgACA3QO6HYBWwseKAJ0K1PoUgFe6GcBsCDNELAIzRBO6GYB 1.151 +PAh0A4gErTk2KAJ08Og/ATwKdeCIfP6J5v9MEP9MGL/0AYFNHP+Ax0UwAJyw 1.152 +D7EFtJOJRBywAYlEFJhmmNPgSGYDBWbT6GgAEAe/gAAp+JxzAgHHMdtQVujm 1.153 +AF65AIC0h/5EHM0VWJ133KEaAki/HAKxCThEHHK4k80T6gAAIJCwRijIvtsB 1.154 +6NMAXesjgPkTcgQ4wXdjgP4CcgQ45ndkYIH9AAZ0KgZSUVOWtAJQsQa1BMHF 1.155 +BLAPIegEkCcUQCfojQD+zXXssCDNEOK06JcAmM0TYVJQKMh3ArABmDn4cgKJ 1.156 ++FC0As0TlV5YWnKgT0GAxwJOdfg4wXVFiMj+xrEBOOZ1O4j0/sW2ADou8AFy 1.157 +L4D9UHIqtQBgvt4B/kQMU+g6AFvoQQB1FlKYzRO4AQLNE1rQ1Dpk/nXqRgjk 1.158 +deVhlY7hT4zhiehHdYoWB7AxLAO0DrsHAM0QPA1088OwDejv/6wIwHX4w79s 1.159 +BLFbZQINuA0BZToNdArNFnT0mM0Wju9Hw1g6AEluc2VydCBkaXNrIDEuBw0A 1.160 AA== 1.161 ==== 1.162 EOT 1.163 @@ -332,27 +399,544 @@ 1.164 rm -f $bs 1.165 } 1.166 1.167 +# Create boot floppy set from kernel, initrd & cmdline 1.168 +floppyset() 1.169 +{ 1.170 + floppysetcat $@ | split -b 1440k /dev/stdin floppy$$ 1.171 + i=1 1.172 + ls floppy$$* | while read file ; do 1.173 + output=floppy.$(printf "%03d" $i) 1.174 + cat $file /dev/zero | dd bs=1k count=1440 of=$output conv=sync 2> /dev/null 1.175 + rm -f $file 1.176 + i=$(( $i + 1 )) 1.177 + done 1.178 +} 1.179 + 1.180 +# Create boot floppy set from a SliTaz ISO image 1.181 +floppysetfromiso() 1.182 +{ 1.183 + mkdir /tmp/iso$$ 1.184 + mount -o loop,ro $1 /tmp/iso$$ 1.185 + rootfs="$(ls /tmp/iso$$/boot/rootfs*.gz 2> /dev/null | tail -1)" 1.186 + bzimage=/tmp/iso$$/boot/bzImage 1.187 + if [ -z "$rootfs" -o ! -s $bzimage ]; then 1.188 + umount -d /tmp/iso$$ 1.189 + rm -rf /tmp/iso$$ 1.190 + echo "Not a SliTaz ISO image !" 1.191 + return 1 1.192 + fi 1.193 + mkdir -p /tmp/rootfs$$/fs 1.194 + n=1 1.195 + for i in $(ls /tmp/iso$$/boot/rootfs*.gz | sort -r); do 1.196 + mkdir /tmp/rootfs$$/$n 1.197 + ln -s $i /tmp/rootfs$$/$n 1.198 + n=$(($n + 1)) 1.199 + done 1.200 + echo "Unpack rootfs..." 1.201 + ( zcat $rootfs 2> /dev/null | unlzma -c $rootfs ) | \ 1.202 + ( cd /tmp/rootfs$$/fs ; cpio -idm > /dev/null ) 1.203 + if [ $(unlzma -c $rootfs 2> /dev/null| wc -c) -gt $(stat -c %s $rootfs) ]; then 1.204 + if [ $(du -ck $rootfs $bzimage | awk 'END { print $1 }') -gt 15296 ]; then 1.205 + # The rootfs.gz file is too big, extract a minimum bootfs with busybox stuff 1.206 + echo "Extract bootfs..." 1.207 + mv /tmp/rootfs$$/fs /tmp/rootfs$$/fs0 1.208 + for i in lib bin sbin usr/bin usr/sbin ; do 1.209 + mkdir -p /tmp/rootfs$$/fs/$i 1.210 + done 1.211 + cd /tmp/rootfs$$/fs0 1.212 + dir=$(echo lib/modules/*/kernel/drivers/block) 1.213 + mkdir -p ../fs/$dir 1.214 + [ -f $dir/floppy.ko.gz ] && mv $dir/floppy.ko.gz ../fs/$dir 1.215 + for i in dev init mnt proc sys tmp ; do 1.216 + mv $i ../fs 1.217 + done 1.218 + mv lib/lib[cm][.-]* lib/ld-* ../fs/lib 1.219 + for i in $(bin/busybox | awk '{ if (s) printf "%s",$0 } 1.220 + /Currently/ { s=1 }' | sed 's/,//g'); do 1.221 + for j in bin sbin usr/bin usr/sbin ; do 1.222 + [ -e $j/$i ] && mv $j/$i ../fs/$j/$i 1.223 + done 1.224 + done 1.225 + mv bin/busybox ../fs/bin 1.226 + rm -f ../1/* 1.227 + find | cpio -o -H newc | lzma e ../1/rootfs.gz -si 1.228 + cd - > /dev/null 1.229 + rm -rf /tmp/rootfs$$/fs0 1.230 + else 1.231 + # The rootfs.gz file fit in 15Mb, no need to split it. 1.232 + rm -rf /tmp/rootfs$$/1 1.233 + fi 1.234 + else 1.235 + # This is a loram rootfs.gz, extract loram bootstrap 1.236 + echo "Split loram rootfs..." 1.237 + hexdump -C $rootfs | grep " 30 37 30 37 " | \ 1.238 + while read offset rem; do 1.239 + offset=$((0x$offset / 4)) 1.240 + for i in 1 2 3 4; do 1.241 + tag=$(dd if=$rootfs bs=4 skip=$offset count=2 2> /dev/null) 1.242 + if [ "07070100" != "$tag" ]; then 1.243 + offset=$(($offset + 1)) 1.244 + continue 1.245 + fi 1.246 + dd if=$rootfs skip=$(($offset / 1024)) bs=4k count=1 2> /dev/null | \ 1.247 + dd skip=$(($offset % 1024)) bs=4 of=/tmp/rootfs$$/1/root 2> /dev/null 1.248 + dd if=$rootfs skip=$((1 + ($offset / 1024) )) bs=4k \ 1.249 + >> /tmp/rootfs$$/1/root 2> /dev/null 1.250 + rm -f /tmp/rootfs$$/1/rootfs* 1.251 + break 2 1.252 + done 1.253 + done 1.254 + fi 1.255 + # Create extra rootfs floppies 1.256 + for i in /tmp/rootfs$$/[1-9]*/root* ; do 1.257 + [ -f $i ] || continue 1.258 + echo "Create floppies for rootfs $(basename $(dirname $i) )..." 1.259 + case "$(dd if=$i bs=1 count=4 2> /dev/null)" in 1.260 + 0707) cat $i ;; 1.261 + *) zcat $i 2> /dev/null || unlzma -c $i ;; 1.262 + esac | cpio -t > $(dirname $i)/files.list 1.263 + sed -i '/ blocks$/d' $(dirname $i)/files.list 1.264 + x=$(readlink $i) 1.265 + [ -n "$x" ] || x=$i 1.266 + pad=$(( $(stat -c %s $x ) % 1474560 )) 1.267 + [ $pad -ne 0 ] && pad=$(( 1474560 - $pad )) 1.268 + dd if=/dev/zero bs=1 count=$pad 2> /dev/null | cat $i - | \ 1.269 + split -b 1440k /dev/stdin $(dirname $i)/floppy 1.270 + done 1.271 + selection="$(grep append /tmp/iso$$/boot/isolinux/common.cfg | sed 's/.*append //')" 1.272 + [ -n "$selection" ] || selection="0 slitaz" 1.273 + set -- $selection 1.274 + selection="" 1.275 + while [ -n "$2" ]; do 1.276 + [ ! -d /tmp/rootfs$$/1 -a -z "$4" ] && break 1.277 + case "$1" in 1.278 + *G) selection="$2 $(( ${1%G} * 1024 * 1024 )) $selection" ;; 1.279 + *M) selection="$2 $(( ${1%M} * 1024 )) $selection" ;; 1.280 + *) selection="$2 $1 $selection" ;; 1.281 + esac 1.282 + shift 2 1.283 + done 1.284 + echo "Create /init ..." 1.285 + base=100 1.286 + set -- $selection 1.287 + for i in /tmp/rootfs$$/[1-9]* ; do 1.288 + [ -d $i ] || continue 1.289 + while read file; do 1.290 + [ -e $i/../fs/$file ] && continue 1.291 + [ $(grep -- "$file" $i/../*/files.list | wc -l) -eq 1 ] && 1.292 + break 1.293 + done < $i/files.list 1.294 + printf "%s %s %03d %d %s %s\n" \ 1.295 + $1 $2 $base $(ls $i/floppy* | wc -l) $file \ 1.296 + $(cat $i/floppy* | md5sum - | awk '{print $1}') 1.297 + base=$(($base + 100)) 1.298 + shift 2 1.299 + done | buildinit /tmp/rootfs$$/fs 1.300 + cmdline="$(grep append /tmp/iso$$/boot/isolinux/isolinux.cfg | tail -n 1 | sed 's/.*gz //')" 1.301 + ( cd /tmp/rootfs$$/fs ; find | cpio -o -H newc ) | lzma e /tmp/rootfs$$/rootfs -si 1.302 + echo "Create first stage boot floppies..." 1.303 + floppyset $bzimage /tmp/rootfs$$/rootfs $cmdline 1.304 + base=100 1.305 + for i in /tmp/rootfs$$/[1-9]* ; do 1.306 + [ -d $i ] || continue 1.307 + j=0 1.308 + for f in $i/floppy* ; do 1.309 + mv $f $(printf "floppy.%03d" $(( $base + $j )) ) 1.310 + j=$(($j + 1)) 1.311 + done 1.312 + base=$(($base + 100)) 1.313 + done 1.314 + rm -rf /tmp/rootfs$$ 1.315 + umount -d /tmp/iso$$ 1.316 + rm -rf /tmp/iso$$ 1.317 +} 1.318 + 1.319 +# Show new boot floppy set 1.320 +dialogwritefloppyset() 1.321 +{ 1.322 + if ! list_floppy check; then 1.323 + du -h floppy.??? 1.324 + return 1.325 + fi 1.326 + while true; do 1.327 + exec 3>&1 1.328 + IMAGE=`$DIALOG --title " Write floppy image " \ 1.329 + --backtitle "Boot floppy set creation on $DEVICE" --clear \ 1.330 + --colors --radiolist " 1.331 + Insert a blank floppy in drive and 1.332 +select the floppy image you what to write. 1.333 +" 18 46 46 \ 1.334 + $(on="on"; for i in floppy*; do echo "$i $(du -h $i | cut -f1) $on "; on="off"; done) 2>&1 1>&3` 1.335 + retval=$? 1.336 + exec 3>&- 1.337 + check_retval 1.338 + dd if=$IMAGE of=$DEVICE 1.339 + done 1.340 +} 1.341 + 1.342 +dialognofloppyset() 1.343 +{ 1.344 + cat << EOT 1.345 +The boot loader can't load the kernel and the initramfs in the first 16Mb 1.346 +of RAM. The total size exceed 15Mb. No floppy image is created. 1.347 +EOT 1.348 +} 1.349 + 1.350 +# Check for iso 9660 image 1.351 +isiso() 1.352 +{ 1.353 + mkdir /tmp/iso$$ 1.354 + mount -o loop,ro $1 /tmp/iso$$ 2> /dev/null 1.355 + status=$? 1.356 + umount -d /tmp/iso$$ 2> /dev/null 1.357 + rm -rf /tmp/iso$$ 1.358 + return $status 1.359 +} 1.360 + 1.361 +dialogfloppyset() 1.362 +{ 1.363 + : ${DIALOG=dialog} 1.364 + while true; do 1.365 + exec 3>&1 1.366 + KERNEL=`$DIALOG --title " Select a Linux kernel or a SliTaz iso " \ 1.367 + --backtitle "Boot floppy set creation on $DEVICE" --clear \ 1.368 + --colors --fselect "$PWD" 10 70 \ 1.369 + 2>&1 1>&3` 1.370 + retval=$? 1.371 + exec 3>&- 1.372 + check_retval 1.373 + [ -f $KERNEL ] && break 1.374 + done 1.375 + if isiso $KERNEL ; then 1.376 + bootfloppybox call mkisofloppies $KERNEL 1.377 + dialogwritefloppyset 1.378 + return 1.379 + fi 1.380 + exec 3>&1 1.381 + INITRD=`$DIALOG --title " Select an Initramfs " \ 1.382 + --backtitle "Boot floppy set creation on $DEVICE" --clear \ 1.383 + --colors --fselect "$PWD" 10 70 \ 1.384 + 2>&1 1>&3` 1.385 + retval=$? 1.386 + exec 3>&- 1.387 + check_retval 1.388 + [ -f "$INITRD" ] || INITRD="" 1.389 + exec 3>&1 1.390 + CMDLINE=`$DIALOG --title " Enter boot command line " \ 1.391 + --backtitle "Boot floppy set creation on $DEVICE" --clear \ 1.392 + --colors --inputbox "Kernel command line" 10 70 "rw root=/dev/null autologin" \ 1.393 + 2>&1 1>&3` 1.394 + retval=$? 1.395 + exec 3>&- 1.396 + check_retval 1.397 + bootfloppybox call mkfloppies $KERNEL $INITRD $CMDLINE && 1.398 + dialogwritefloppyset || 1.399 + dialognofloppyset 1.400 +} 1.401 + 1.402 +# 1.403 +# Create floppy image set 1.404 +# 1.405 +export IMAGE_SET=' 1.406 +<window title="Image set generator" icon-name="gtk-floppy"> 1.407 + <vbox> 1.408 + <text use-markup="true"> 1.409 + <label> 1.410 +" 1.411 +<b>Create a boot floppy set</b> 1.412 +" 1.413 + </label> 1.414 + </text> 1.415 + <notebook labels="Slitaz only|Any linux"> 1.416 + <frame Slitaz only (no size limit)> 1.417 + <vbox> 1.418 + <text wrap="false" width-chars="44" use-markup="true"> 1.419 + <label> 1.420 +" 1.421 +Slitaz distro use a floppy boot flavor as first 1.422 +stage boot to break the tiny loader 15Mb limit. 1.423 +" 1.424 + </label> 1.425 + </text> 1.426 + <hbox> 1.427 + <text use-markup="true"> 1.428 + <label>"<b>Slitaz ISO : </b>"</label> 1.429 + </text> 1.430 + <entry accept="filename"> 1.431 + <label>Select a Slitaz ISO image</label> 1.432 + <variable>ISO</variable> 1.433 + </entry> 1.434 + <button> 1.435 + <input file stock="gtk-open"></input> 1.436 + <action type="fileselect">ISO</action> 1.437 + </button> 1.438 + </hbox> 1.439 + <hbox> 1.440 + <text use-markup="true"> 1.441 + <label>"<b>Output directory : </b>"</label> 1.442 + </text> 1.443 + <entry accept="directory"> 1.444 + <label>Select output directory</label> 1.445 + <variable>FILE_DIRECTORY</variable> 1.446 + <default>/tmp</default> 1.447 + </entry> 1.448 + <button> 1.449 + <input file stock="gtk-open"></input> 1.450 + <action type="fileselect">FILE_DIRECTORY</action> 1.451 + </button> 1.452 + </hbox> 1.453 + <hbox> 1.454 + <button> 1.455 + <input file icon="forward"></input> 1.456 + <label>Create image set from ISO boot</label> 1.457 + <action>cd $OUTPUTDIR; bootfloppybox call mkisofloppiesxterm $ISO</action> 1.458 + <action type="closewindow">IMAGE_SET</action> 1.459 + </button> 1.460 + </hbox> 1.461 + </vbox> 1.462 + </frame> 1.463 + <frame Any Linux distribution (max total size 14-15Mb)> 1.464 + <vbox> 1.465 + <text wrap="false" width-chars="44" use-markup="true"> 1.466 + <label> 1.467 +" 1.468 +The total size of the kernel and the initramfs must be 1.469 +lower than 14-15Mb due to the tiny boot loader design. 1.470 +" 1.471 + </label> 1.472 + </text> 1.473 + <hbox> 1.474 + <text use-markup="true"> 1.475 + <label>"<b>Kernel : </b>"</label> 1.476 + </text> 1.477 + <entry accept="filename"> 1.478 + <label>Select a linux kernel</label> 1.479 + <variable>KERNEL</variable> 1.480 + </entry> 1.481 + <button> 1.482 + <input file stock="gtk-open"></input> 1.483 + <action type="fileselect">KERNEL</action> 1.484 + </button> 1.485 + </hbox> 1.486 + <hbox> 1.487 + <text use-markup="true"> 1.488 + <label>"<b>Initramfs : </b>"</label> 1.489 + </text> 1.490 + <entry accept="filename"> 1.491 + <label>Select an initramfs/initrd file</label> 1.492 + <variable>INITRD</variable> 1.493 + </entry> 1.494 + <button> 1.495 + <input file stock="gtk-open"></input> 1.496 + <action type="fileselect">INITRD</action> 1.497 + </button> 1.498 + </hbox> 1.499 + <hbox> 1.500 + <text use-markup="true"> 1.501 + <label>"<b>Cmdline : </b>"</label> 1.502 + </text> 1.503 + <entry> 1.504 + <label>Enter kernel arguments</label> 1.505 + <variable>CMDLINE</variable> 1.506 + <default>rw root=/dev/null autologin</default> 1.507 + </entry> 1.508 + </hbox> 1.509 + <hbox> 1.510 + <text use-markup="true"> 1.511 + <label>"<b>Output directory : </b>"</label> 1.512 + </text> 1.513 + <entry accept="directory"> 1.514 + <label>Select output directory</label> 1.515 + <variable>OUTPUT_DIRECTORY</variable> 1.516 + <default>/tmp</default> 1.517 + </entry> 1.518 + <button> 1.519 + <input file stock="gtk-open"></input> 1.520 + <action type="fileselect">OUTPUT_DIRECTORY</action> 1.521 + </button> 1.522 + </hbox> 1.523 + <hbox> 1.524 + <button> 1.525 + <input file icon="forward"></input> 1.526 + <label>Create image set</label> 1.527 + <action>cd $OUTPUTDIR; bootfloppybox call mkfloppies $KERNEL $INITRD $CMDLINE</action> 1.528 + <action type="closewindow">IMAGE_SET</action> 1.529 + </button> 1.530 + </hbox> 1.531 + </vbox> 1.532 + </frame> 1.533 + </notebook> 1.534 + <hbox> 1.535 + <button> 1.536 + <input file icon="gtk-close"></input> 1.537 + <action type="closewindow">IMAGE_SET</action> 1.538 + </button> 1.539 + </hbox> 1.540 + </vbox> 1.541 +</window> 1.542 +' 1.543 + 1.544 +# 1.545 +# Read/write floppy images 1.546 +# 1.547 +export FLOPPY_IMAGE=' 1.548 +<window title="Floppy image manager" icon-name="gtk-floppy"> 1.549 + <vbox> 1.550 + <frame Floppy disk drive> 1.551 + <hbox> 1.552 + <text use-markup="true"> 1.553 + <label>"<b>Device : </b>"</label> 1.554 + </text> 1.555 + <combobox> 1.556 + <variable>DEVICE</variable>' 1.557 +FLOPPY_DEV="" 1.558 +for i in $(list_floppy); do 1.559 + FLOPPY_DEV="$FLOPPY_DEV 1.560 + <item>/dev/$i</item>" 1.561 +done 1.562 + FLOPPY_IMAGE="$FLOPPY_IMAGE$FLOPPY_DEV 1.563 + </combobox> 1.564 + <button> 1.565 + <label>Format floppy</label> 1.566 + <input file icon=\"media-floppy\"></input> 1.567 + <action>fdformat -n $DEVICE</action> 1.568 + </button> 1.569 + </hbox> 1.570 + </frame> 1.571 + <frame Floppy image file> 1.572 + <hbox> 1.573 + <text use-markup=\"true\"> 1.574 + <label>\"<b>File : </b>\"</label> 1.575 + </text> 1.576 + <entry accept=\"filename\"> 1.577 + <label>Select a floppy image</label> 1.578 + <variable>IMAGE</variable> 1.579 + </entry> 1.580 + <button> 1.581 + <input file stock=\"gtk-open\"></input> 1.582 + <action type=\"fileselect\">IMAGE</action> 1.583 + </button> 1.584 + </hbox> 1.585 + </frame> 1.586 + <hbox> 1.587 + <button> 1.588 + <input file icon=\"reload\"></input> 1.589 + <label>Create image set</label> 1.590 + <action type=\"launch\">IMAGE_SET</action> 1.591 + </button> 1.592 + <button> 1.593 + <input file icon=\"go-jump\"></input> 1.594 + <label>Write image to floppy</label> 1.595 + <action>dd if=\$IMAGE of=\$DEVICE</action> 1.596 + </button> 1.597 + <button> 1.598 + <input file icon=\"undo\"></input> 1.599 + <label>Get floppy image</label> 1.600 + <action>dd if=\$DEVICE of=\$IMAGE</action> 1.601 + </button> 1.602 + <button> 1.603 + <input file icon=\"gtk-close\"></input> 1.604 + <action type=\"closewindow\">FLOPPY_IMAGE</action> 1.605 + </button> 1.606 + </hbox> 1.607 + </vbox> 1.608 +</window> 1.609 +" 1.610 + 1.611 +gtkdialogshowfloppyset() 1.612 +{ 1.613 +# 1.614 +# Show floppy image set 1.615 +# 1.616 +IMAGE_SHOW=' 1.617 +<window title="Image set" icon-name="gtk-floppy"> 1.618 + <vbox> 1.619 + <text use-markup="true"> 1.620 + <label> 1.621 +" 1.622 +<b>Boot floppy images</b> 1.623 +" 1.624 + </label> 1.625 + </text> 1.626 + <tree> 1.627 + <width>50</width><height>140</height> 1.628 + <label>Size|File</label> 1.629 + <input>du -h floppy.??? | sed "s/\t/|/" </input> 1.630 + </tree> 1.631 + <hbox> 1.632 +' 1.633 + [ 0$1 -gt $((15 * 1024 * 1024)) ] && IMAGE_SHOW="$IMAGE_SHOW 1.634 + <frame WARNING> 1.635 + <text> 1.636 + <label> 1.637 +\"This floppy set breaks 15Mb limit ($1 bytes). 1.638 +It should not be able to complete boot process.\" 1.639 + </label> 1.640 + </text> 1.641 + </frame> 1.642 + </hbox> 1.643 + <hbox> 1.644 +" 1.645 + list_floppy check && IMAGE_SHOW="$IMAGE_SHOW 1.646 + <button> 1.647 + <input file icon=\"media-floppy\"></input> 1.648 + <label>Manage images</label> 1.649 + <action type=\"launch\">FLOPPY_IMAGE</action> 1.650 + </button> 1.651 +" 1.652 + IMAGE_SHOW="$IMAGE_SHOW 1.653 + <button> 1.654 + <input file icon=\"gtk-close\"></input> 1.655 + <action type=\"closewindow\">IMAGE_SET</action> 1.656 + </button> 1.657 + </hbox> 1.658 + </vbox> 1.659 +</window> 1.660 +" 1.661 + export IMAGE_SHOW 1.662 + gtkdialog --program=IMAGE_SHOW 1.663 +} 1.664 + 1.665 while true; do 1.666 1.667 if [ "$1" == "call" ]; then 1.668 case "$2" in 1.669 mkmenu) mkmenu $3;; 1.670 + mkisofloppiesxterm) 1.671 + shift 2 1.672 + xterm -geometry 80x16 -title "Build boot floppies from ISO" \ 1.673 + -e "$0 call mkisofloppies $@ ; echo -e \"----\nENTER to continue...\" && read close" 1.674 + gtkdialogshowfloppyset 1.675 + ;; 1.676 + mkisofloppies) 1.677 + shift 2 1.678 + floppysetfromiso $@ 1.679 + ;; 1.680 mkfloppies) 1.681 shift 2 1.682 - floppyset $@ | split -b 1440k /dev/stdin floppy$$ 1.683 - i=1 1.684 - ls floppy$$* | while read file ; do 1.685 - output=floppy.$(printf "%03d" $i) 1.686 - cat $file /dev/zero | dd bs=1k count=1440 of=$output conv=sync 2> /dev/null 1.687 - rm -f $file 1.688 - i=$(( $i + 1 )) 1.689 - done;; 1.690 + floppyset $@ 1.691 + sz=$(cat floppy.* | wc -c) 1.692 + if [ -n "$XAUTHORITY" ]; then 1.693 + gtkdialogshowfloppyset $sz 1.694 + else 1.695 + if [ $sz -gt $((15 * 1024 * 1024)) ]; then 1.696 + cat <<EOT 1.697 +This floppy set breaks 15Mb limit ($sz bytes). 1.698 +It should not be able to complete boot process. 1.699 +EOT 1.700 + fi 1.701 + fi 1.702 + ;; 1.703 install) 1.704 DIR=/tmp/mkbootfloppy$$ 1.705 mkdir -p $DIR 1.706 DEVICE=$4 1.707 file=$5 1.708 case "$3" in 1.709 + dialog*) 1.710 + shift 2 1.711 + $@ 1.712 + ;; 1.713 grub*) 1.714 mkdir -p $DIR/boot/grub 1.715 [ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ] \ 1.716 @@ -452,24 +1036,25 @@ 1.717 : ${DIALOG=dialog} 1.718 1.719 DEVICE=/dev/fd0 1.720 + list_floppy check || DEVICE="floppy" 1.721 while true; do 1.722 exec 3>&1 1.723 ID_SOURCE=`$DIALOG --title " Choose a boot floppy " \ 1.724 --backtitle "Boot Floppy Creation on $DEVICE" --clear \ 1.725 --extra-button --extra-label "Change floppy" \ 1.726 - --yes-label "Install" \ 1.727 - --no-label "Quit" \ 1.728 --colors --radiolist " 1.729 Create a floppy or a cdrom to boot a LiveCD in a PXE network... 1.730 May need a floppy disk in drive. Erase the whole floppy disk. 1.731 " 18 70 50\ 1.732 - SmartBtmgr "Boot any partition or ATAPI CD-ROM." on \ 1.733 + FloppySet "Boot Slitaz with floppies only." on \ 1.734 + SmartBtmgr "Boot any partition or ATAPI CD-ROM." off \ 1.735 Plop "Boot USB harddisk floppy or CD/DVD." off \ 1.736 Etherboot "Replacement for proprietary PXE ROMs." off \ 1.737 gPXE "Boot from http://boot.slitaz.org/" off \ 1.738 Memtest86+ "Memory failures detection tool." off \ 1.739 Grub4DOS "Enhanced grub version supporting NTFS." off \ 1.740 - Grub "Boot loader with command shell." off 2>&1 1>&3` 1.741 + Grub "Boot loader with command shell." off \ 1.742 + 2>&1 1>&3` 1.743 retval=$? 1.744 exec 3>&- 1.745 check_retval 1.746 @@ -495,6 +1080,7 @@ 1.747 bootfloppybox call install "$pkg" "$DEVICE" "$file" 1.748 exit 0 1.749 done <<EOT 1.750 +FloppySet /bin/dd dialogfloppyset 1.751 SmartBtmgr /usr/share/boot/btmgr btmgr 1.752 Plop /usr/share/boot/plpbt.bin plop 1.753 Etherboot /usr/share/boot/etherboot etherboot 1.754 @@ -511,7 +1097,7 @@ 1.755 export HELP=' 1.756 <window title="gPXE forced url" icon-name="gtk-floppy"> 1.757 <vbox> 1.758 - <text use-markup="true"> 1.759 + <text use-markup="true"> 1.760 <label>" 1.761 <b>Web boot parameters</b>" 1.762 </label> 1.763 @@ -536,162 +1122,6 @@ 1.764 </window> 1.765 ' 1.766 # 1.767 -# Create floppy image set 1.768 -# 1.769 -export IMAGE_SET=' 1.770 -<window title="Image set generator" icon-name="gtk-floppy"> 1.771 - <vbox> 1.772 - <text use-markup="true"> 1.773 - <label> 1.774 -" 1.775 -<b>Create a boot floppy set.</b> 1.776 -" 1.777 - </label> 1.778 - </text> 1.779 - <text wrap="false" width-chars="44" use-markup="true"> 1.780 - <label> 1.781 -" 1.782 -The total size of the kernel and the initramfs must not 1.783 -increase 14-15Mb due to the tiny boot loader design. 1.784 -" 1.785 - </label> 1.786 - </text> 1.787 - <frame> 1.788 - <vbox> 1.789 - <hbox> 1.790 - <text use-markup="true"> 1.791 - <label>"<b>Kernel : </b>"</label> 1.792 - </text> 1.793 - <entry accept="filename"> 1.794 - <label>Select a linux kernel</label> 1.795 - <variable>KERNEL</variable> 1.796 - </entry> 1.797 - <button> 1.798 - <input file stock="gtk-open"></input> 1.799 - <action type="fileselect">KERNEL</action> 1.800 - </button> 1.801 - </hbox> 1.802 - <hbox> 1.803 - <text use-markup="true"> 1.804 - <label>"<b>Initramfs : </b>"</label> 1.805 - </text> 1.806 - <entry accept="filename"> 1.807 - <label>Select an initramfs/initrd file</label> 1.808 - <variable>INITRD</variable> 1.809 - </entry> 1.810 - <button> 1.811 - <input file stock="gtk-open"></input> 1.812 - <action type="fileselect">INITRD</action> 1.813 - </button> 1.814 - </hbox> 1.815 - <hbox> 1.816 - <text use-markup="true"> 1.817 - <label>"<b>Cmdline : </b>"</label> 1.818 - </text> 1.819 - <entry> 1.820 - <label>Enter kernel arguments</label> 1.821 - <variable>CMDLINE</variable> 1.822 - <default>rw root=/dev/null autologin</default> 1.823 - </entry> 1.824 - </hbox> 1.825 - <hbox> 1.826 - <text use-markup="true"> 1.827 - <label>"<b>Output directory : </b>"</label> 1.828 - </text> 1.829 - <entry accept="directory"> 1.830 - <label>Select output directory</label> 1.831 - <variable>OUTPUTDIR</variable> 1.832 - <default>/tmp</default> 1.833 - </entry> 1.834 - <button> 1.835 - <input file stock="gtk-open"></input> 1.836 - <action type="fileselect">OUTPUTDIR</action> 1.837 - </button> 1.838 - </hbox> 1.839 - </vbox> 1.840 - </frame> 1.841 - <hbox> 1.842 - <button> 1.843 - <input file icon="forward"></input> 1.844 - <label>Create image set</label> 1.845 - <action>cd $OUTPUTDIR; bootfloppybox call mkfloppies $KERNEL $INITRD $CMDLINE</action> 1.846 - <action type="closewindow">IMAGE_SET</action> 1.847 - </button> 1.848 - <button> 1.849 - <input file icon="gtk-close"></input> 1.850 - <action type="closewindow">IMAGE_SET</action> 1.851 - </button> 1.852 - </hbox> 1.853 - </vbox> 1.854 -</window> 1.855 -' 1.856 -# 1.857 -# Read/write floppy images 1.858 -# 1.859 -export FLOPPY_IMAGE=' 1.860 -<window title="Floppy image manager" icon-name="gtk-floppy"> 1.861 - <vbox> 1.862 - <frame Floppy disk drive> 1.863 - <hbox> 1.864 - <text use-markup="true"> 1.865 - <label>"<b>Device : </b>"</label> 1.866 - </text> 1.867 - <combobox> 1.868 - <variable>DEVICE</variable>' 1.869 -for i in /sys/devices/platform/floppy.*/block:*; do 1.870 - [ -d $i ] || continue 1.871 - FLOPPY_IMAGE="$FLOPPY_IMAGE 1.872 - <item>/dev/${i#*block:}</item>" 1.873 -done 1.874 - FLOPPY_IMAGE="$FLOPPY_IMAGE 1.875 - </combobox> 1.876 - <button> 1.877 - <label>Format floppy</label> 1.878 - <input file icon=\"media-floppy\"></input> 1.879 - <action>fdformat -n $DEVICE</action> 1.880 - </button> 1.881 - </hbox> 1.882 - </frame> 1.883 - <frame Floppy image file> 1.884 - <hbox> 1.885 - <text use-markup=\"true\"> 1.886 - <label>\"<b>File : </b>\"</label> 1.887 - </text> 1.888 - <entry accept=\"filename\"> 1.889 - <label>Select a floppy image</label> 1.890 - <variable>IMAGE</variable> 1.891 - </entry> 1.892 - <button> 1.893 - <input file stock=\"gtk-open\"></input> 1.894 - <action type=\"fileselect\">IMAGE</action> 1.895 - </button> 1.896 - </hbox> 1.897 - </frame> 1.898 - <hbox> 1.899 - <button> 1.900 - <input file icon=\"reload\"></input> 1.901 - <label>Create image set</label> 1.902 - <action type=\"launch\">IMAGE_SET</action> 1.903 - </button> 1.904 - <button> 1.905 - <input file icon=\"go-jump\"></input> 1.906 - <label>Write image to floppy</label> 1.907 - <action>dd if=\$IMAGE of=\$DEVICE</action> 1.908 - </button> 1.909 - <button> 1.910 - <input file icon=\"undo\"></input> 1.911 - <label>Get floppy image</label> 1.912 - <action>dd if=\$DEVICE of=\$IMAGE</action> 1.913 - </button> 1.914 - <button> 1.915 - <input file icon=\"gtk-close\"></input> 1.916 - <action type=\"closewindow\">FLOPPY_IMAGE</action> 1.917 - </button> 1.918 - </hbox> 1.919 - </vbox> 1.920 -</window> 1.921 -" 1.922 -# 1.923 # Write bootfloppy image to floppy device. 1.924 # 1.925 BOOT_DIALOG=' 1.926 @@ -720,28 +1150,56 @@ 1.927 </text> 1.928 <combobox> 1.929 <variable>DEVICE</variable>' 1.930 -for i in /sys/devices/platform/floppy.*/block:*; do 1.931 - [ -d $i ] || continue 1.932 - BOOT_DIALOG="$BOOT_DIALOG 1.933 - <item>/dev/${i#*block:}</item>" 1.934 +FLOPPY_DEV="" 1.935 +for i in $(list_floppy); do 1.936 + FLOPPY_DEV="$FLOPPY_DEV 1.937 + <item>/dev/$i</item>" 1.938 done 1.939 -tmp=' <item>floppy image (boot.fd)</item> 1.940 + BOOT_DIALOG="$BOOT_DIALOG$FLOPPY_DEV 1.941 + <item>floppy image (boot.fd)</item> 1.942 <item>cdrom image (boot.iso)</item> 1.943 - </combobox> 1.944 + </combobox>" 1.945 +if [ -n "$FLOPPY_DEV" ]; then 1.946 + tmp=' 1.947 <button> 1.948 <label>Format floppy</label> 1.949 <input file icon="media-floppy"></input> 1.950 <action>case "$DEVICE" in /dev/*) fdformat -n $DEVICE;; esac</action> 1.951 - </button> 1.952 + </button>' 1.953 + BOOT_DIALOG="$BOOT_DIALOG$tmp" 1.954 +fi 1.955 +tmp=' 1.956 </hbox> 1.957 </frame> 1.958 - <notebook labels="LiveCD|USB|PXE Network|WEB Network|Memory Test|Windows|Expert"> 1.959 + <notebook labels="Set|LiveCD|USB|PXE Network|WEB Network|Memory Test|Windows|Expert"> 1.960 + <frame Boot floppy set (many floppies)> 1.961 + <vbox> 1.962 + <hbox> 1.963 + <text wrap="true" width-chars="58" use-markup="true"> 1.964 + <label> 1.965 +" 1.966 +Only people without CD-ROM, USB and Network should use a floppy set. 1.967 +The images are built from an ISO boot or from a Linux kernel, an initramfs 1.968 +and a boot command line. Non Slitaz boot floppy set are limited to 15Mb. 1.969 +" 1.970 + </label> 1.971 + </text> 1.972 + </hbox> 1.973 + <hbox> 1.974 + <button> 1.975 + <label>Create image set</label> 1.976 + <input file icon="forward"></input> 1.977 + <action type="launch">IMAGE_SET</action> 1.978 + </button> 1.979 + </hbox> 1.980 + </vbox> 1.981 + </frame> 1.982 ' 1.983 BOOT_DIALOG="$BOOT_DIALOG$tmp" 1.984 while read name file pkg desc; do 1.985 - tmp="<frame $name> 1.986 + tmp="<frame $name (single floppy)> 1.987 <hbox> 1.988 - <text wrap=\"true\" width-chars=\"44\" use-markup=\"true\"> 1.989 + <text wrap=\"true\" width-chars=\"58\" use-markup=\"true\"> 1.990 <label> 1.991 \" 1.992 $(echo -e $desc) 1.993 @@ -837,9 +1295,9 @@ 1.994 fi 1.995 BOOT_DIALOG="$BOOT_DIALOG$tmp" 1.996 done <<EOT 1.997 -SmartBtmgr /usr/share/boot/btmgr btmgr This OS independent Smart Boot Manager can boot any partition or ATAPI CD-ROM. 1.998 -Plop /usr/share/boot/plpbt.bin plop This non free Boot Manager can boot a floppy disk, hardisk, USB or CD/DVD. Hit Ctrl-ESC for text mode. 1.999 -Etherboot /usr/share/boot/etherboot etherboot This network bootloader provides a replacement for proprietary PXE or NBI ROMs. 1.1000 +SmartBtmgr /usr/share/boot/btmgr btmgr This OS independent Smart Boot Manager can boot \\\\nany partition or ATAPI CD-ROM. 1.1001 +Plop /usr/share/boot/plpbt.bin plop This non free Boot Manager can boot a floppy disk, hardisk, USB or \\\\nCD/DVD. Hit Ctrl-ESC for text mode. 1.1002 +Etherboot /usr/share/boot/etherboot etherboot This network bootloader provides a replacement \\\\nfor proprietary PXE or NBI ROMs. 1.1003 gPXE /boot/gpxe gpxe PXE / iSCSI / AoE network bootloader. 1.1004 Memtest86+ /usr/share/boot/memtest.lzma memtest Memory failures detection tool. 1.1005 Grub4DOS /usr/share/boot/grldr.lzma grub4dos Enhanced grub version supporting NTFS. 1.1006 @@ -848,16 +1306,29 @@ 1.1007 tmp=' 1.1008 </notebook> 1.1009 <hbox> 1.1010 +' 1.1011 +BOOT_DIALOG="$BOOT_DIALOG$tmp" 1.1012 +if [ -e /dev/cdrom ]; then 1.1013 +tmp=' 1.1014 <button> 1.1015 <input file icon="media-cdrom"></input> 1.1016 <label>Burn cdrom image</label> 1.1017 <action>burnbox</action> 1.1018 </button> 1.1019 +' 1.1020 +BOOT_DIALOG="$BOOT_DIALOG$tmp" 1.1021 +fi 1.1022 +if list_floppy check; then 1.1023 +tmp=' 1.1024 <button> 1.1025 <input file icon="media-floppy"></input> 1.1026 <label>Manage floppy image</label> 1.1027 <action type="launch">FLOPPY_IMAGE</action> 1.1028 </button> 1.1029 +' 1.1030 +BOOT_DIALOG="$BOOT_DIALOG$tmp" 1.1031 +fi 1.1032 +tmp=' 1.1033 <button> 1.1034 <input file icon="exit"></input> 1.1035 <label>Exit</label>