slitaz-tools rev 264
bootfloppybox: create iso image too
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Aug 18 08:38:13 2008 +0000 (2008-08-18) |
parents | 9fbb84b399ed |
children | d489ac2eb878 |
files | tinyutils/bootfloppybox |
line diff
1.1 --- a/tinyutils/bootfloppybox Sun Jul 27 07:16:22 2008 +0000 1.2 +++ b/tinyutils/bootfloppybox Mon Aug 18 08:38:13 2008 +0000 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=20080625 1.8 +VERSION=20080818 1.9 PLOP_URL=http://download.plop.at/plop/bootmngr/plpbt50rc12flp.zip 1.10 1.11 # Check if user is root. 1.12 @@ -31,60 +31,37 @@ 1.13 1.14 select_floppy() 1.15 { 1.16 + DEVICE="$DIALOG --title \" Floppy device \" --backtitle \"Boot Floppy Creation\" --clear --extra-button --extra-label \"Format\" --colors --radiolist \" 1.17 +Select boot device 1.18 +\" 18 70 50" 1.19 + on=on 1.20 + for i in /sys/devices/platform/floppy.*/block:*; do 1.21 + [ -d $i ] || continue 1.22 + DEVICE="$DEVICE /dev/${i#*block:} 'Floppy in ${i#*block:}' $on" 1.23 + on=off 1.24 + done 1.25 + DEVICE="$DEVICE cdrom \"cdrom image file boot.iso\" $on 2>&1 1>&3" 1.26 exec 3>&1 1.27 - DEVICE=`$DIALOG --title " Floppy device " \ 1.28 - --backtitle "Boot Floppy Creation" --clear \ 1.29 - --extra-button --extra-label "Format" \ 1.30 - --colors --inputbox " 1.31 -Enter floppy device (default /dev/fd0) 1.32 - " 18 70 2>&1 1>&3` 1.33 + DEVICE=`eval $DEVICE` 1.34 retval=$? 1.35 exec 3>&- 1.36 check_retval 1.37 - case "$DEVICE" in 1.38 - /dev/fd*);; 1.39 - *) DEVICE=/dev/fd0;; 1.40 - esac 1.41 if [ "$retval" = "3" ]; then 1.42 - fdformat -n $DEVICE 1.43 + case "$DEVICE" in 1.44 + /dev/*) fdformat -n $DEVICE;; 1.45 + esac 1.46 fi 1.47 } 1.48 1.49 -while true; do 1.50 - 1.51 -if [ "$1" == "call" ]; then 1.52 - case "$2" in 1.53 - setup-grub) 1.54 - DEVICE=$3 1.55 +install_grub() 1.56 +{ 1.57 + case "$DEVICE" in 1.58 + /dev/*) 1.59 mke2fs $DEVICE 1.60 mkdir /media/floppy 1.61 mount $DEVICE /media/floppy 1.62 - mkdir -p /media/floppy/boot/grub 1.63 cp /usr/lib/grub/i386-pc/stage? /media/floppy/boot/grub 1.64 - cp /tmp/floppybox.grub.menu /media/floppy/boot/grub/menu.lst 1.65 - [ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ]\ 1.66 - && cat /usr/share/boot/btmgr /dev/zero | \ 1.67 - dd bs=18k count=80 | gzip -9 > \ 1.68 - /media/floppy/boot/btmgr.gz \ 1.69 - && unlzma -c /usr/share/boot/memdisk.lzma > \ 1.70 - /media/floppy/boot/memdisk 1.71 - [ -f /usr/share/boot/plop.gz -a \ 1.72 - -f /usr/share/boot/memdisk.lzma ]\ 1.73 - && zcat /usr/share/boot/plop.gz | cat - /dev/zero | \ 1.74 - dd bs=18k count=80 | gzip -9 > \ 1.75 - /media/floppy/boot/plop.gz \ 1.76 - && unlzma -c /usr/share/boot/memdisk.lzma > \ 1.77 - /media/floppy/boot/memdisk 1.78 - [ -f /usr/share/boot/etherboot ]\ 1.79 - && cp /usr/share/boot/etherboot /media/floppy/boot 1.80 - [ -f /boot/gpxe ]\ 1.81 - && cp /boot/gpxe /media/floppy/boot 1.82 - [ -f /usr/share/boot/memtest.lzma ]\ 1.83 - && unlzma -c /usr/share/boot/memtest.lzma > \ 1.84 - /media/floppy/boot/memtest 1.85 - [ -f /usr/share/boot/grub.exe.lzma ]\ 1.86 - && unlzma -c /usr/share/boot/grub.exe.lzma > \ 1.87 - /media/floppy/boot/grub.exe 1.88 + cp -a $1 /media/floppy 1.89 grub-set-default --root-directory=/media/floppy 0 1.90 umount $DEVICE 1.91 grub --batch <<EOT 1.92 @@ -93,28 +70,107 @@ 1.93 quit 1.94 EOT 1.95 ;; 1.96 + cdrom*) 1.97 + cp /usr/lib/grub/i386-pc/stage2_eltorito $1/boot/grub 1.98 + genisoimage -R -o boot.iso -b boot/grub/stage2_eltorito \ 1.99 + -c boot/boot.cat -no-emul-boot -boot-load-size 4 \ 1.100 + -input-charset iso8859-1 -boot-info-table $1 1.101 + ;; 1.102 + esac 1.103 +} 1.104 + 1.105 +while true; do 1.106 + 1.107 +if [ "$1" == "call" ]; then 1.108 + case "$2" in 1.109 + install) 1.110 + DIR=/tmp/mkbootfloppy$$ 1.111 + mkdir -p $DIR 1.112 + DEVICE=$4 1.113 + file=$5 1.114 + case "$3" in 1.115 + grub) 1.116 + mkdir -p $DIR/boot/grub 1.117 + cp /tmp/floppybox.grub.menu $DIR/boot/grub/menu.lst 1.118 + [ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ]\ 1.119 + && cat /usr/share/boot/btmgr /dev/zero | \ 1.120 + dd bs=18k count=80 | gzip -9 > \ 1.121 + $DIR/boot/btmgr.gz \ 1.122 + && unlzma -c /usr/share/boot/memdisk.lzma > \ 1.123 + $DIR/boot/memdisk 1.124 + [ -f /usr/share/boot/plop.gz -a \ 1.125 + -f /usr/share/boot/memdisk.lzma ]\ 1.126 + && zcat /usr/share/boot/plop.gz | cat - /dev/zero | \ 1.127 + dd bs=18k count=80 | gzip -9 > \ 1.128 + $DIR/boot/plop.gz \ 1.129 + && unlzma -c /usr/share/boot/memdisk.lzma > \ 1.130 + $DIR/boot/memdisk 1.131 + [ -f /usr/share/boot/etherboot ]\ 1.132 + && cp /usr/share/boot/etherboot $DIR/boot 1.133 + [ -f /boot/gpxe ]\ 1.134 + && cp /boot/gpxe $DIR/boot 1.135 + [ -f /usr/share/boot/memtest.lzma ]\ 1.136 + && unlzma -c /usr/share/boot/memtest.lzma > \ 1.137 + $DIR/boot/memtest 1.138 + [ -f /usr/share/boot/grub.exe.lzma ]\ 1.139 + && unlzma -c /usr/share/boot/grub.exe.lzma > \ 1.140 + $DIR/boot/grub.exe 1.141 + install_grub $DIR 1.142 + ;; 1.143 + *) 1.144 + case "$file" in 1.145 + *.lzma) action="unlzma -c";; 1.146 + *.gz) action="zcat";; 1.147 + *) action="cat";; 1.148 + esac 1.149 + case "$DEVICE" in 1.150 + /dev/*) $action $file > $DEVICE;; 1.151 + cdrom*) 1.152 + mkdir -p $DIR/boot/grub 1.153 + case "$3" in 1.154 + btmgr|plop) 1.155 + $action $file | cat - /dev/zero | \ 1.156 + dd bs=18k count=80 | \ 1.157 + gzip -9 > $DIR/boot/$3.gz 1.158 + unlzma -c /usr/share/boot/memdisk.lzma \ 1.159 + > $DIR/boot/memdisk 1.160 + cat > $DIR/boot/grub/menu.lst << EOT 1.161 +timeout 0 1.162 +title $3 1.163 +kernel /boot/memdisk floppy c=80 h=2 s=18 1.164 +initrd /boot/$3.gz 1.165 +EOT 1.166 + ;; 1.167 + *) $action $file > $DIR/boot/$3 1.168 + cat > $DIR/boot/grub/menu.lst << EOT 1.169 +timeout 0 1.170 +title $3 1.171 +kernel /boot/$3 1.172 +EOT 1.173 + ;; 1.174 + esac 1.175 + install_grub $DIR 1.176 + ;; 1.177 + esac 1.178 + ;; 1.179 + esac 1.180 + rm -rf $DIR 1.181 + ;; 1.182 get-plop) 1.183 - wget -O - $PLOP_URL | unzip -p /dev/stdin | \ 1.184 - dd bs=18k count=6 | gzip -9 > $3 1.185 - [ -s $3 ] || exit 1 1.186 - mkdir /tmp/get-plop$$ 1.187 - cd /tmp/get-plop$$ 1.188 - echo $3 > files.list 1.189 - cpio -o -H newc < files.list | gzip -9 > fs.cpio.gz 1.190 - cat > receipt <<EOT 1.191 + mkdir -p /tmp/get-plop$$/plop-1.0/fs/$(dirname $3) 1.192 + wget -O - $PLOP_URL | unzip -p /dev/stdin | dd bs=18k count=6 |\ 1.193 + gzip -9 > /tmp/get-plop$$/plop-1.0/fs/$3 1.194 + if [ -s /tmp/get-plop$$/plop-1.0/fs/$3 ]; then 1.195 + cat > /tmp/get-plop$$/plop-1.0/receipt <<EOT 1.196 PACKAGE="plop" 1.197 VERSION="1.0" 1.198 CATEGORY="non-free" 1.199 SHORT_DESC="Plop boot manager." 1.200 WEB_SITE="http://www.plop.at/en/bootmanager.html" 1.201 EOT 1.202 - cpio -o -H newc > plop-1.0.tazpkg <<EOT 1.203 -receipt 1.204 -files.list 1.205 -fs.cpio.gz 1.206 -EOT 1.207 - tazpkg install plop-1.0.tazpkg 1.208 - cd .. 1.209 + ( cd /tmp/get-plop$$ ; tazpkg pack plop-1.0 ) 1.210 + tazpkg install /tmp/get-plop$$/plop-1.0.tazpkg 1.211 + fi 1.212 rm -rf /tmp/get-plop$$ 1.213 ;; 1.214 *) echo "Invalid command $0 $@" 1>&2 1.215 @@ -125,8 +181,30 @@ 1.216 1.217 cat > /tmp/floppybox.grub.menu <<EOT 1.218 default saved 1.219 -timeout 10 1.220 +timeout 8 1.221 +color yellow/brown light-green/black 1.222 1.223 +EOT 1.224 +[ -f /boot/gpxe ] && cat >> /tmp/floppybox.grub.menu <<EOT 1.225 +title gPXE (Boot from the Web, PXE/iSCSI/AoE support) 1.226 + kernel /boot/gpxe $(dd if=/boot/gpxe bs=1 skip=519 count=255 2>/dev/null | strings) 1.227 + 1.228 +EOT 1.229 +[ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ]\ 1.230 + && cat >> /tmp/floppybox.grub.menu <<EOT 1.231 +title Smart Boot Manager (text - boot floppy, hard disk or CD/DVD) 1.232 + kernel /boot/memdisk floppy c=80 h=2 s=18 1.233 + initrd /boot/btmgr.gz 1.234 + 1.235 +EOT 1.236 +[ -f /usr/share/boot/plop.gz -a -f /usr/share/boot/memdisk.lzma ]\ 1.237 + && cat >> /tmp/floppybox.grub.menu <<EOT 1.238 +title Plop Boot Manager (graphic - boot floppy, hard disk, CD/DVD or USB) 1.239 + kernel /boot/memdisk floppy c=80 h=2 s=18 1.240 + initrd /boot/plop.gz 1.241 + 1.242 +EOT 1.243 +cat >> /tmp/floppybox.grub.menu <<EOT 1.244 title Windows (example on /dev/hda1) 1.245 rootnoverify (hd0,0) 1.246 chainloader +1 1.247 @@ -144,32 +222,13 @@ 1.248 save default 1.249 1.250 EOT 1.251 -[ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ]\ 1.252 - && cat >> /tmp/floppybox.grub.menu <<EOT 1.253 -title Smart Boot Manager (boot floppy, hard disk or CD/DVD) 1.254 - kernel /boot/memdisk floppy c=80 h=2 s=18 1.255 - initrd /boot/btmgr.gz 1.256 - 1.257 -EOT 1.258 -[ -f /usr/share/boot/plop.gz -a -f /usr/share/boot/memdisk.lzma ]\ 1.259 - && cat >> /tmp/floppybox.grub.menu <<EOT 1.260 -title Plop Boot Manager (boot floppy, hard disk, CD/DVD or USB) 1.261 - kernel /boot/memdisk floppy c=80 h=2 s=18 1.262 - initrd /boot/plop.gz 1.263 - 1.264 -EOT 1.265 [ -f /usr/share/boot/etherboot ] && cat >> /tmp/floppybox.grub.menu <<EOT 1.266 title Etherboot (LAN boot, PXE or NBI) 1.267 kernel /boot/etherboot 1.268 1.269 EOT 1.270 -[ -f /boot/gpxe ] && cat >> /tmp/floppybox.grub.menu <<EOT 1.271 -title gPXE (default boot form http://boot.slitaz.org/, PXE/iSCSI/AoE support) 1.272 - kernel /boot/gpxe 1.273 - 1.274 -EOT 1.275 [ -f /usr/share/boot/memtest.lzma ] && cat >> /tmp/floppybox.grub.menu <<EOT 1.276 -title Memtest86+ 1.277 +title Memtest86+ (Test system memory) 1.278 kernel /boot/memtest 1.279 1.280 EOT 1.281 @@ -192,8 +251,8 @@ 1.282 --yes-label "Install" \ 1.283 --no-label "Quit" \ 1.284 --colors --radiolist " 1.285 -Create a floppy to boot a LiveCD, in a PXE network... 1.286 -Needs a floppy disk in drive. Erase the whole floppy disk. 1.287 +Create a floppy or a cdrom to boot a LiveCD, in a PXE network... 1.288 +May need a floppy disk in drive. Erase the whole floppy disk. 1.289 " 18 70 50\ 1.290 SmartBtmgr "Boot any partition or ATAPI CD-ROM." on \ 1.291 Plop "Boot harddisk floppy CD/DVD or USB." off \ 1.292 @@ -220,19 +279,10 @@ 1.293 if [ "$pkg" = "plop" ]; then 1.294 bootfloppybox call get-plop $file 1.295 else 1.296 - tazpkg get-install $pkg --forced 1.297 + tazpkg get-install $pkg 1.298 fi 1.299 fi 1.300 - if [ "$pkg" = "grub" ]; then 1.301 - bootfloppybox call setup-grub $DEVICE 1.302 - else 1.303 - case "$file" in 1.304 - *.lzma) action="unlzma -c";; 1.305 - *.gz) action="zcat";; 1.306 - *) action="cat";; 1.307 - esac 1.308 - $action $file > $DEVICE 1.309 - fi 1.310 + bootfloppybox call install "$pkg" "$DEVICE" "$file" 1.311 exit 0 1.312 done <<EOT 1.313 SmartBtmgr /usr/share/boot/btmgr btmgr 1.314 @@ -244,6 +294,41 @@ 1.315 EOT 1.316 done 1.317 fi 1.318 +# 1.319 +# Describe gPXE arguments. 1.320 +# 1.321 +export HELP=' 1.322 +<window title="gPXE forced url" icon-name="gtk-floppy"> 1.323 +<vbox> 1.324 + <text use-markup="true"> 1.325 + <label>" 1.326 +<b>Web boot parameters</b>" 1.327 + </label> 1.328 + </text> 1.329 + <frame> 1.330 + <text wrap="true" width-chars="58" use-markup="true"> 1.331 + <label> 1.332 +"Without parameters (i.e. with an empty Boot URL) gPXE will perform a normal 1.333 +PXE boot: IP configuration with DHCP and download DHCP bootfile with TFTP. 1.334 + 1.335 +You can override the DHCP bootfile with an Boot URL such as 1.336 +<i>tftp://192.168.0.1/pxe/pxeloader</i>, <i>http://mirror.slitaz.org/pxe/pxelinux.0</i>, 1.337 +or <i>x-tftm://192.168.0.201//lts/vmlinuz.ltsp</i>. 1.338 + 1.339 +You can override IP configuration too (usefull without DHCP server), example: 1.340 +<i>ip=192.168.0.10/24 gw=192.168.0.1 dns=192.168.0.1 nodhcp 1.341 +url=http://mirror.slitaz.org/pxe/pxelinux.0</i> 1.342 + 1.343 +The <i>nodhcp</i> keyword avoids dhcp timeouts and the <i>url=</i> keyword is 1.344 +optionnal when the url is the only argument. 1.345 +" 1.346 + </label> 1.347 + </text> 1.348 + </frame> 1.349 +</vbox> 1.350 +</window> 1.351 +' 1.352 +# 1.353 # Write bootfloppy image to floppy device. 1.354 # 1.355 BOOT_DIALOG=' 1.356 @@ -259,8 +344,8 @@ 1.357 <text wrap="false" width-chars="44" use-markup="true"> 1.358 <label> 1.359 " 1.360 -Create a floppy to boot a LiveCD, in a PXE network or WEB... 1.361 -Need a floppy disk in drive. Erase the whole floppy disk. 1.362 +Create a floppy or a cdrom to boot a LiveCD, in a PXE network or WEB... 1.363 +May need a floppy disk in drive. Erase the whole floppy disk. 1.364 " 1.365 </label> 1.366 </text> 1.367 @@ -270,19 +355,26 @@ 1.368 <text use-markup="true"> 1.369 <label>"<b>Device : </b>"</label> 1.370 </text> 1.371 - <entry> 1.372 - <default>/dev/fd0</default> 1.373 - <variable>DEVICE</variable> 1.374 - </entry> 1.375 + <combobox> 1.376 + <variable>DEVICE</variable>' 1.377 +for i in /sys/devices/platform/floppy.*/block:*; do 1.378 + [ -d $i ] || continue 1.379 + BOOT_DIALOG="$BOOT_DIALOG 1.380 + <item>/dev/${i#*block:}</item>" 1.381 + on=off 1.382 +done 1.383 +tmp=' <item>cdrom image (boot.iso)</item> 1.384 + </combobox> 1.385 <button> 1.386 <label>Format floppy</label> 1.387 <input file icon="forward"></input> 1.388 - <action>fdformat -n $DEVICE</action> 1.389 + <action>case "$DEVICE" in /dev/*) fdformat -n $DEVICE;; esac</action> 1.390 </button> 1.391 </hbox> 1.392 </frame> 1.393 <notebook labels="LiveCD|USB|PXE Network|WEB Network|Memory Test|Expert"> 1.394 ' 1.395 +BOOT_DIALOG="$BOOT_DIALOG$tmp" 1.396 while read name file pkg desc; do 1.397 tmp="<frame $name> 1.398 <hbox> 1.399 @@ -294,32 +386,19 @@ 1.400 </label> 1.401 </text> 1.402 </hbox> 1.403 + <hbox> 1.404 " 1.405 if [ -f $file ]; then 1.406 - case "$file" in 1.407 - *.lzma) action="unlzma -c";; 1.408 - *.gz) action="zcat";; 1.409 - *) action="cat";; 1.410 - esac 1.411 if [ "$pkg" = "grub" ]; then 1.412 tmp="$tmp 1.413 - <hbox> 1.414 <button> 1.415 <label>Grub menu</label> 1.416 <input file icon=\"accessories-text-editor\"></input> 1.417 <action type=\"lauch\">leafpad /tmp/floppybox.grub.menu</action> 1.418 </button> 1.419 - <button> 1.420 - <label>Write floppy</label> 1.421 - <input file icon=\"forward\"></input> 1.422 - <action>bootfloppybox call setup-grub \$DEVICE</action> 1.423 - </button> 1.424 - </hbox> 1.425 - </frame> 1.426 " 1.427 elif [ "$pkg" = "gpxe" ]; then 1.428 tmp="$tmp 1.429 - <hbox> 1.430 <text wrap=\"true\" use-markup=\"true\"> 1.431 <label> \"<b>Boot URL:</b>\" </label> 1.432 </text> 1.433 @@ -327,39 +406,31 @@ 1.434 <default>$(dd if=$file bs=1 skip=519 count=255 2>/dev/null | strings)</default> 1.435 <variable>URL</variable> 1.436 </entry> 1.437 + </hbox> 1.438 + <hbox> 1.439 + <button help> 1.440 + <action type=\"launch\">HELP</action> 1.441 + </button> 1.442 <button> 1.443 <label>Update</label> 1.444 <input file icon=\"reload\"></input> 1.445 <action>echo -n \"\$URL\" | cat - /dev/zero | dd conv=notrunc bs=1 count=255 seek=519 of=$file 2>/dev/null</action> 1.446 </button> 1.447 - </hbox> 1.448 - <hbox> 1.449 +" 1.450 + fi 1.451 + tmp="$tmp 1.452 <button> 1.453 <label>Write floppy</label> 1.454 <input file icon=\"forward\"></input> 1.455 - <action>$action $file > \$DEVICE</action> 1.456 + <action>bootfloppybox call install \"$pkg\" \"\$DEVICE\" \"$file\"</action> 1.457 </button> 1.458 </hbox> 1.459 </frame> 1.460 " 1.461 - else 1.462 - tmp="$tmp 1.463 - <hbox> 1.464 - <button> 1.465 - <label>Write floppy</label> 1.466 - <input file icon=\"forward\"></input> 1.467 - <action>$action $file > \$DEVICE</action> 1.468 - </button> 1.469 - </hbox> 1.470 - </frame> 1.471 -" 1.472 - fi 1.473 else 1.474 - tmp2="[ -f /var/lib/tazpkg/packages.list ] || tazpkg recharge</action> 1.475 - <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title \"$pkg install\" -e \"tazpkg get-install $pkg --forced; echo -e \\\"----\\n\\nENTER to continue...\\\" && read close\"" 1.476 + tmp2="tazpkg get-install $pkg --forced" 1.477 [ "$pkg" = "plop" ] && tmp2="bootfloppybox call get-plop $file" 1.478 tmp="$tmp 1.479 - <hbox> 1.480 <text wrap=\"true\" width-chars=\"34\" use-markup=\"true\"> 1.481 <label> 1.482 \"<i>The package <b>$pkg</b> is not yet installed</i>\" 1.483 @@ -368,7 +439,8 @@ 1.484 <button> 1.485 <input file icon=\"go-jump\"></input> 1.486 <label>Install</label> 1.487 - <action>$tmp2</action> 1.488 + <action>[ -f /var/lib/tazpkg/packages.list ] || tazpkg recharge</action> 1.489 + <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title \"$pkg install\" -e \"$tmp2 ; sleep 2\"</action> 1.490 <action type=\"exit\">restart</action> 1.491 </button> 1.492 </hbox>