2 # Copyright 1999-2005 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header: /var/cvsroot/gentoo/src/catalyst/targets/support/bootloader-setup.sh,v 1.34 2006/04/19 14:28:40 wolf31o2 Exp $
5 . ${clst_sharedir}/targets/support/functions.sh
6 . ${clst_sharedir}/targets/support/filesystem-functions.sh
8 # $1 is the destination root
11 extract_kernels $1/boot
16 default_append_line="root=/dev/ram0 init=/linuxrc ${cmdline_opts} ${custom_kopts} cdroot"
18 case ${clst_mainarch} in
20 # NO SOFTLEVEL SUPPORT YET
21 acfg=$1/etc/aboot.conf
23 for x in ${clst_boot_kernel}
25 echo -n "${bctr}:/boot/${x} " >> ${acfg}
26 echo -n "initrd=/boot/${x}.igz root=/dev/ram0 " >> ${acfg}
27 echo "init=/linuxrc ${cmdline_opts} cdroot" >> ${acfg}
32 # NO SOFTLEVEL SUPPORT YET
35 # NO SOFTLEVEL SUPPORT YET
36 icfg=$1/boot/palo.conf
37 kmsg=$1/boot/kernels.msg
39 echo "--commandline=0/${first} initrd=${first}.igz root=/dev/ram0 init=/linuxrc ${cmdline_opts}" >> ${icfg}
40 echo "--bootloader=boot/iplboot" >> ${icfg}
41 echo "--ramdisk=boot/${first}.igz" >> ${icfg}
44 # NO SOFTLEVEL SUPPORT YET
48 # The specs indicate the kernels to be build. We need to put
49 # those kernels and the corresponding initrd.img.gz(s) in the
50 # /boot directory. This directory contains a message boot.msg
51 # containing some info to be displayed on boot, a configuration
52 # (yaboot.conf) specifying the boot options (kernel/initrd
53 # combinations). The boot directory also contains a file called
54 # yaboot, which normally gets copied from the live environment.
55 # For now we supply a prebuilt file, prebuilt configuration
56 # and prebuilt boot message. This can be enhanced later on
57 # but the following suffices for now:
59 # this sets up the config file for yaboot
62 # ADD RUNLEVEL SUPPORT ???
64 icfg=$1/boot/yaboot.conf
67 echo "default ${first}" > ${icfg}
68 echo "timeout 300" >> ${icfg}
69 echo "device=cd:" >> ${icfg}
70 echo "root=/dev/ram" >> ${icfg}
71 echo "fgcolor=white" >> ${icfg}
72 echo "bgcolor=black" >> ${icfg}
73 echo "message=/boot/boot.msg" >> ${icfg}
75 # Here is where I fix up the boot.msg file.
76 sed -e 's/ARCH/PPC/' \
77 -e 's/HARDWARE/32-bit Apple and Pegasos hardware/' \
80 # Here we wipe out the /ppc directory, if it exists.
83 for x in ${clst_boot_kernel}
85 eval custom_kopts=\$${x}_kernelopts
86 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
87 echo "image=/boot/${x}" >> ${icfg}
89 if [ -e "$1/boot/${x}.igz" ]
91 echo "initrd=/boot/${x}.igz" >> ${icfg}
94 echo "label=${x}" >> ${icfg}
95 echo "read-write" >> ${icfg}
96 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
98 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet\"" >> ${icfg}
100 echo "append=\"${default_append_line}\"" >> ${icfg}
106 # NO SOFTLEVEL SUPPORT YET
110 # The specs indicate the kernels to be build. We need to put
111 # those kernels and the corresponding initrd.img.gz(s) in the
112 # /boot directory. This directory contains a message boot.msg
113 # containing some info to be displayed on boot, a configuration
114 # (yaboot.conf) specifying the boot options (kernel/initrd
115 # combinations). The boot directory also contains a file called
116 # yaboot, which normally gets copied from the live environment.
117 # For now we supply a prebuilt file, prebuilt configuration
118 # and prebuilt boot message. This can be enhanced later on
119 # but the following suffices for now:
121 # this sets up the config file for yaboot
124 # ADD RUNLEVEL SUPPORT ???
126 icfg=$1/boot/yaboot.conf
127 kmsg=$1/boot/boot.msg
129 echo "device=cd:" >> ${icfg}
130 echo "root=/dev/ram" >> ${icfg}
131 echo "fgcolor=white" >> ${icfg}
132 echo "bgcolor=black" >> ${icfg}
133 echo "message=/boot/boot.msg" >> ${icfg}
135 # Here is where I fix up the boot.msg file.
136 sed -e 's/ARCH/PPC/' \
137 -e 's/HARDWARE/64-bit Apple and IBM hardware/' \
140 # Setup the IBM yaboot.conf
141 etc_icfg=$1/etc/yaboot.conf
144 echo "root=/dev/ram" >> ${etc_icfg}
145 echo "fgcolor=white" >> ${etc_icfg}
146 echo "bgcolor=black" >> ${etc_icfg}
147 echo "message=/boot/boot.msg" >> ${etc_icfg}
149 for x in ${clst_boot_kernel}
151 eval "clst_kernel_console=\$clst_boot_kernel_${x}_console"
152 eval "clst_kernel_machine_type=\$clst_boot_kernel_${x}_machine_type"
153 eval custom_kopts=\$${x}_kernelopts
155 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
156 if [ "${clst_kernel_machine_type}" == "ibm" ]
159 if [ -n "${clst_kernel_console}" ]
162 echo "image=/boot/${x}" >> ${etc_icfg}
164 if [ -e "$1/boot/${x}.igz" ]
166 echo "initrd=/boot/${x}.igz" >> ${etc_icfg}
169 echo "label=${x}" >> ${etc_icfg}
170 echo "read-write" >> ${icfg}
171 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
173 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet\"" >> ${etc_icfg}
175 echo "append=\"${default_append_line}\"" >> ${etc_icfg}
178 for y in ${clst_kernel_console}
182 echo "image=/boot/${x}" >> ${etc_icfg}
184 if [ -e "$1/boot/${x}.igz" ]
186 echo "initrd=/boot/${x}.igz" >> ${etc_icfg}
189 echo "label=${x}-${y} " >> ${etc_icfg}
190 echo "read-write" >> ${icfg}
191 echo "append=\"${default_append_line} console=${y}\"" >> ${etc_icfg}
195 echo "image=/boot/${x}" >> ${etc_icfg}
197 if [ -e "$1/boot/${x}.igz" ]
199 echo "initrd=/boot/${x}.igz" >> ${etc_icfg}
202 echo "label=${x}" >> ${etc_icfg}
203 echo "read-write" >> ${etc_icfg}
204 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
206 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet\"" >> ${etc_icfg}
208 echo "append=\"${default_append_line}\"" >> ${etc_icfg}
212 if [ -n "${clst_kernel_console}" ]
215 echo "image=/boot/${x}" >> ${icfg}
217 if [ -e "$1/boot/${x}.igz" ]
219 echo "initrd=/boot/${x}.igz" >> ${icfg}
222 echo "label=${x}" >> ${icfg}
223 echo "read-write" >> ${icfg}
224 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
226 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet\"" >> ${icfg}
228 echo "append=\"${default_append_line}\"" >> ${icfg}
231 for y in ${clst_kernel_console}
234 echo "image=/boot/${x}" >> ${icfg}
236 if [ -e "$1/boot/${x}.igz" ]
238 echo "initrd=/boot/${x}.igz" >> ${icfg}
241 echo "label=${x}-${y} " >> ${icfg}
242 echo "read-write" >> ${icfg}
243 echo "append=\"${default_append_line} console=${y}\"" >> ${icfg}
247 echo "image=/boot/${x}" >> ${icfg}
249 if [ -e "$1/boot/${x}.igz" ]
251 echo "initrd=/boot/${x}.igz" >> ${icfg}
254 echo "label=${x}" >> ${icfg}
255 echo "read-write" >> ${icfg}
256 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
258 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet\"" >> ${icfg}
260 echo "append=\"${default_append_line}\"" >> ${icfg}
266 if [ "${IBM_YABOOT}" == "FALSE" ]
278 # NO SOFTLEVEL SUPPORT YET
280 scfg=$1/boot/silo.conf
281 echo "default=\"help\"" > ${scfg}
282 echo "message=\"/boot/boot.msg\"" >> ${scfg}
284 for x in ${clst_boot_kernel}
287 echo "image=\"/boot/${x}\"" >> ${scfg}
288 echo -e "\tlabel=\"${x}\"" >> ${scfg}
289 echo -e "\tappend=\"initrd=/boot/${x}.igz root=/dev/ram0 init=/linuxrc ${cmdline_opts} cdroot\"" >> ${scfg}
293 echo "image=\"cat /boot/silo.conf\"" >> ${scfg}
294 echo -e "label=\"config\"" >> ${scfg}
295 echo "image=\"cat /boot/video.msg\"" >> ${scfg}
296 echo -e "label=\"video\"" >> ${scfg}
297 echo "image=\"cat /boot/help.msg\"" >> ${scfg}
298 echo -e "label=\"help\"" >> ${scfg}
301 # NO SOFTLEVEL SUPPORT YET
303 iacfg=$1/boot/elilo.conf
304 echo 'prompt' > ${iacfg}
305 echo 'message=/efi/boot/elilo.msg' >> ${iacfg}
306 echo 'chooser=simple' >> ${iacfg}
307 echo 'timeout=50' >> ${iacfg}
308 echo 'relocatable' >> ${iacfg}
310 for x in ${clst_boot_kernel}
312 echo "image=/efi/boot/${x}" >> ${iacfg}
313 echo " label=${x}" >> ${iacfg}
314 echo ' append="'initrd=${x}.igz ${default_append_line}'"' >> ${iacfg}
315 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
317 echo "image=/efi/boot/${x}" >> ${iacfg}
318 echo " label=${x}-serial">> ${iacfg}
319 echo ' append="'initrd=${x}.igz ${default_append_line}' console=tty0 console=ttyS0,9600"' >> ${iacfg}
320 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
322 echo "image=/efi/boot/${x}" >> ${iacfg}
323 echo " label=${x}-sgi">> ${iacfg}
324 echo ' append="'initrd=${x}.igz ${default_append_line}' console=tty0 console=ttySG0,115200"' >> ${iacfg}
325 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
327 mv $1/boot/${x}{,.igz} $1/boot/efi/boot
329 cp ${iacfg} $1/boot/efi/boot
332 if [ -e $1/isolinux/isolinux.bin ]
334 mv $1/boot/* $1/isolinux
336 # the rest of this function sets up the config file for isolinux
337 icfg=$1/isolinux/isolinux.cfg
338 kmsg=$1/isolinux/kernels.msg
339 echo "default ${first}" > ${icfg}
340 echo "timeout 150" >> ${icfg}
341 echo "prompt 1" >> ${icfg}
342 echo "display boot.msg" >> ${icfg}
343 echo "F1 kernels.msg" >> ${icfg}
344 echo "F2 F2.msg" >> ${icfg}
345 echo "F3 F3.msg" >> ${icfg}
346 echo "F4 F4.msg" >> ${icfg}
347 echo "F5 F5.msg" >> ${icfg}
348 echo "F6 F6.msg" >> ${icfg}
349 echo "F7 F7.msg" >> ${icfg}
351 echo "Available kernels:" > ${kmsg}
354 cp ${clst_sharedir}/livecd/files/x86-F$i.msg \
358 for x in ${clst_boot_kernel}
360 eval custom_kopts=\$${x}_kernelopts
361 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
364 eval "clst_kernel_softlevel=\$clst_boot_kernel_${x}_softlevel"
366 if [ -n "${clst_kernel_softlevel}" ]
368 for y in ${clst_kernel_softlevel}
370 echo "label ${x}-${y}" >> ${icfg}
371 echo " kernel ${x}" >> ${icfg}
372 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
374 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
375 elif [ "${clst_livecd_splash_type}" == "bootplash" -a -n "${clst_livecd_splash_theme}" ]
376 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791 splash=silent" >> ${icfg}
378 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791" >> ${icfg}
382 echo " ${x}" >> ${kmsg}
383 echo "label ${x}-${y}-nofb" >> ${icfg}
384 echo " kernel ${x}" >> ${icfg}
385 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz" >> ${icfg}
387 echo " ${x}-nofb" >> ${kmsg}
390 echo "label ${x}" >> ${icfg}
391 echo " kernel ${x}" >> ${icfg}
392 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
394 echo " append ${default_append_line} initrd=${x}.igz vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
395 elif [ "${clst_livecd_splash_type}" == "bootplash" -a -n "${clst_livecd_splash_theme}" ]
396 echo " append ${default_append_line} initrd=${x}.igz vga=791 splash=silent" >> ${icfg}
398 echo " append ${default_append_line} initrd=${x}.igz vga=791" >> ${icfg}
401 echo " ${x}" >> ${kmsg}
402 echo "label ${x}-nofb" >> ${icfg}
403 echo " kernel ${x}" >> ${icfg}
404 echo " append ${default_append_line} initrd=${x}.igz" >> ${icfg}
406 echo " ${x}-nofb" >> ${kmsg}
410 if [ -f $1/isolinux/memtest86 ]
413 echo " memtest86" >> $kmsg
414 echo "label memtest86" >> $icfg
415 echo " kernel memtest86" >> $icfg
419 if [ -e $1/boot/efi/elilo.efi ]
421 iacfg=$1/boot/elilo.conf
422 echo 'prompt' > ${iacfg}
423 echo 'message=/efi/boot/elilo.msg' >> ${iacfg}
424 echo 'chooser=simple' >> ${iacfg}
425 echo 'timeout=50' >> ${iacfg}
427 for x in ${clst_boot_kernel}
429 echo "image=/efi/boot/${x}" >> ${iacfg}
430 echo " label=${x}" >> ${iacfg}
431 echo ' append="'initrd=${x}.igz ${default_append_line}'"' >> ${iacfg}
432 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
434 echo "image=/efi/boot/${x}" >> ${iacfg}
436 cp -f $1/boot/${x}{,.igz} $1/boot/efi/boot > /dev/null
437 cp -f $1/isolinux/${x}{,.igz} $1/boot/efi/boot > /dev/null
439 cp ${iacfg} $1/boot/efi/boot
442 if [ -e $1/boot/grub/stage2_eltorito ]
444 icfg=$1/boot/grub/grub.conf
445 echo "default 1" > ${icfg}
446 echo "timeout 150" >> ${icfg}
450 echo "title help" >> ${icfg}
451 cp ${clst_sharedir}/livecd/files/README.txt \
453 echo "cat /boot/help.msg" >> ${icfg}
455 for x in ${clst_boot_kernel}
457 eval custom_kopts=\$${x}_kernelopts
458 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
461 eval "clst_kernel_softlevel=\$clst_boot_kernel_${x}_softlevel"
463 if [ -n "${clst_kernel_softlevel}" ]
465 for y in ${clst_kernel_softlevel}
467 echo "title ${x}-${y}" >> ${icfg}
468 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
470 echo "kernel /boot/${x} softlevel=${y} ${default_append_line} vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
471 elif [ "${clst_livecd_splash_type}" == "bootplash" -a -n "${clst_livecd_splash_theme}" ]
472 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791 splash=silent" >> ${icfg}
474 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791" >> ${icfg}
476 if [ -e $1/boot/${x}.igz ]
478 echo "initrd /boot/${x}.igz" >> ${icfg}
481 echo "title ${x}-${y} [ No FrameBuffer ]" >> ${icfg}
482 echo "kernel ${x} /boot/${x} softlevel=${y} ${default_append_line}" >> ${icfg}
483 if [ -e $1/boot/${x}.igz ]
485 echo "initrd /boot/${x}.igz" >> ${icfg}
490 echo "title ${x}" >> ${icfg}
491 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
493 echo "kernel /boot/${x} ${default_append_line} vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
494 elif [ "${clst_livecd_splash_type}" == "bootplash" -a -n "${clst_livecd_splash_theme}" ]
495 echo "kernel /boot/${x} ${default_append_line} vga=791 splash=silent" >> ${icfg}
497 echo "kernel /boot/${x} ${default_append_line} vga=791" >> ${icfg}
499 if [ -e $1/boot/${x}.igz ]
501 echo "initrd /boot/${x}.igz" >> ${icfg}
504 echo "title ${x} [ No FrameBuffer ]" >> ${icfg}
505 echo "kernel ${x} /boot/${x} ${default_append_line}" >> ${icfg}
506 if [ -e $1/boot/${x}.igz ]
508 echo "initrd /boot/${x}.igz" >> ${icfg}
514 if [ -f $1/boot/memtest86 ]
517 echo "title memtest86" >> ${icfg}
518 echo "kernel /boot/memtest86" >> ${icfg}
524 # NO SOFTLEVEL SUPPORT YET
527 # Mips is an interesting arch -- where most archs will
528 # use ${1} as the root of the LiveCD, an SGI LiveCD lacks
529 # such a root. Instead, we will use ${1} as a scratch
530 # directory to build the components we need for the
531 # CD image, and then pass these components to the
532 # `sgibootcd` tool which outputs a final CD image
534 mkdir ${scratch}/kernels
535 mkdir ${scratch}/kernels/misc
536 mkdir ${scratch}/arcload
537 echo "" > ${scratch}/arc.cf
539 # Move kernel binaries to ${scratch}/kernels, and
540 # move everything else to ${scratch}/kernels/misc
541 for x in ${clst_boot_kernel}; do
542 mv ${1}/boot/${x} ${scratch}/kernels
543 mv ${1}/boot/${x}.igz ${scratch}/kernels/misc
547 # Source the bashified arcload config
548 source ${clst_sharedir}/targets/support/mips-arcload_conf.sh
550 # Generate top portions of the config
551 echo -e "${topofconfig}${serial}${dbg}${cmt1}" >> ${scratch}/arc.cf
553 # Next, figure out what kernels were specified in the
554 # spec file, and generate the appropriate arcload conf
555 # blocks specific to each system
556 ip22="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip22" | tr "\n" " ")"
557 ip27="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip27" | tr "\n" " ")"
558 ip28="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip28" | tr "\n" " ")"
559 ip30="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip30" | tr "\n" " ")"
560 ip32="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip32" | tr "\n" " ")"
562 if [ -n "${ip22}" ]; then
563 echo -e "${ip22base}" >> ${scratch}/arc.cf
564 for x in ${ip22}; do echo -e "${!x}" >> ${scratch}/arc.cf; done
565 echo -e "${ip22vid}${ip22x}" >> ${scratch}/arc.cf
568 [ -n "${ip27}" ] && echo -e "${ip27base}" >> ${scratch}/arc.cf
569 [ -n "${ip28}" ] && echo -e "${ip28base}" >> ${scratch}/arc.cf
570 [ -n "${ip30}" ] && echo -e "${ip30base}" >> ${scratch}/arc.cf
572 if [ -n "${ip32}" ]; then
573 echo -e "${ip32base}" >> ${scratch}/arc.cf
574 for x in ${ip32}; do echo -e "${!x}" >> ${scratch}/arc.cf; done
575 echo -e "${ip32vid}${ip32x}" >> ${scratch}/arc.cf
578 # Finish off the config
579 echo -e "${cmt2}" >> ${scratch}/arc.cf
581 # Move the bootloader binaries & config to their destination
582 mv ${1}/sashARCS ${1}/sash64 ${1}/arc.cf ${scratch}/arcload