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.36 2006/04/20 15:17:01 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}" ]
377 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791 splash=silent" >> ${icfg}
379 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791" >> ${icfg}
383 echo " ${x}" >> ${kmsg}
384 echo "label ${x}-${y}-nofb" >> ${icfg}
385 echo " kernel ${x}" >> ${icfg}
386 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz" >> ${icfg}
388 echo " ${x}-nofb" >> ${kmsg}
391 echo "label ${x}" >> ${icfg}
392 echo " kernel ${x}" >> ${icfg}
393 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
395 echo " append ${default_append_line} initrd=${x}.igz vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
396 elif [ "${clst_livecd_splash_type}" == "bootplash" -a -n "${clst_livecd_splash_theme}" ]
398 echo " append ${default_append_line} initrd=${x}.igz vga=791 splash=silent" >> ${icfg}
400 echo " append ${default_append_line} initrd=${x}.igz vga=791" >> ${icfg}
403 echo " ${x}" >> ${kmsg}
404 echo "label ${x}-nofb" >> ${icfg}
405 echo " kernel ${x}" >> ${icfg}
406 echo " append ${default_append_line} initrd=${x}.igz" >> ${icfg}
408 echo " ${x}-nofb" >> ${kmsg}
412 if [ -f $1/isolinux/memtest86 ]
415 echo " memtest86" >> $kmsg
416 echo "label memtest86" >> $icfg
417 echo " kernel memtest86" >> $icfg
421 if [ -e $1/boot/efi/elilo.efi ]
423 iacfg=$1/boot/elilo.conf
424 echo 'prompt' > ${iacfg}
425 echo 'message=/efi/boot/elilo.msg' >> ${iacfg}
426 echo 'chooser=simple' >> ${iacfg}
427 echo 'timeout=50' >> ${iacfg}
429 for x in ${clst_boot_kernel}
431 echo "image=/efi/boot/${x}" >> ${iacfg}
432 echo " label=${x}" >> ${iacfg}
433 echo ' append="'initrd=${x}.igz ${default_append_line}'"' >> ${iacfg}
434 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
436 echo "image=/efi/boot/${x}" >> ${iacfg}
438 cp -f $1/boot/${x}{,.igz} $1/boot/efi/boot > /dev/null
439 cp -f $1/isolinux/${x}{,.igz} $1/boot/efi/boot > /dev/null
441 cp ${iacfg} $1/boot/efi/boot
444 if [ -e $1/boot/grub/stage2_eltorito ]
446 icfg=$1/boot/grub/grub.conf
447 echo "default 1" > ${icfg}
448 echo "timeout 150" >> ${icfg}
452 echo "title help" >> ${icfg}
453 cp ${clst_sharedir}/livecd/files/README.txt \
455 echo "cat /boot/help.msg" >> ${icfg}
457 for x in ${clst_boot_kernel}
459 eval custom_kopts=\$${x}_kernelopts
460 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
463 eval "clst_kernel_softlevel=\$clst_boot_kernel_${x}_softlevel"
465 if [ -n "${clst_kernel_softlevel}" ]
467 for y in ${clst_kernel_softlevel}
469 echo "title ${x}-${y}" >> ${icfg}
470 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
472 echo "kernel /boot/${x} softlevel=${y} ${default_append_line} vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
473 elif [ "${clst_livecd_splash_type}" == "bootplash" -a -n "${clst_livecd_splash_theme}" ]
475 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791 splash=silent" >> ${icfg}
477 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791" >> ${icfg}
479 if [ -e $1/boot/${x}.igz ]
481 echo "initrd /boot/${x}.igz" >> ${icfg}
484 echo "title ${x}-${y} [ No FrameBuffer ]" >> ${icfg}
485 echo "kernel ${x} /boot/${x} softlevel=${y} ${default_append_line}" >> ${icfg}
486 if [ -e $1/boot/${x}.igz ]
488 echo "initrd /boot/${x}.igz" >> ${icfg}
493 echo "title ${x}" >> ${icfg}
494 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
496 echo "kernel /boot/${x} ${default_append_line} vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
497 elif [ "${clst_livecd_splash_type}" == "bootplash" -a -n "${clst_livecd_splash_theme}" ]
499 echo "kernel /boot/${x} ${default_append_line} vga=791 splash=silent" >> ${icfg}
501 echo "kernel /boot/${x} ${default_append_line} vga=791" >> ${icfg}
503 if [ -e $1/boot/${x}.igz ]
505 echo "initrd /boot/${x}.igz" >> ${icfg}
508 echo "title ${x} [ No FrameBuffer ]" >> ${icfg}
509 echo "kernel ${x} /boot/${x} ${default_append_line}" >> ${icfg}
510 if [ -e $1/boot/${x}.igz ]
512 echo "initrd /boot/${x}.igz" >> ${icfg}
518 if [ -f $1/boot/memtest86 ]
521 echo "title memtest86" >> ${icfg}
522 echo "kernel /boot/memtest86" >> ${icfg}
528 # NO SOFTLEVEL SUPPORT YET
531 # Mips is an interesting arch -- where most archs will
532 # use ${1} as the root of the LiveCD, an SGI LiveCD lacks
533 # such a root. Instead, we will use ${1} as a scratch
534 # directory to build the components we need for the
535 # CD image, and then pass these components to the
536 # `sgibootcd` tool which outputs a final CD image
538 mkdir ${scratch}/kernels
539 mkdir ${scratch}/kernels/misc
540 mkdir ${scratch}/arcload
541 echo "" > ${scratch}/arc.cf
543 # Move kernel binaries to ${scratch}/kernels, and
544 # move everything else to ${scratch}/kernels/misc
545 for x in ${clst_boot_kernel}; do
546 mv ${1}/boot/${x} ${scratch}/kernels
547 mv ${1}/boot/${x}.igz ${scratch}/kernels/misc
551 # Source the bashified arcload config
552 source ${clst_sharedir}/targets/support/mips-arcload_conf.sh
554 # Generate top portions of the config
555 echo -e "${topofconfig}${serial}${dbg}${cmt1}" >> ${scratch}/arc.cf
557 # Next, figure out what kernels were specified in the
558 # spec file, and generate the appropriate arcload conf
559 # blocks specific to each system
560 ip22="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip22" | tr "\n" " ")"
561 ip27="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip27" | tr "\n" " ")"
562 ip28="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip28" | tr "\n" " ")"
563 ip30="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip30" | tr "\n" " ")"
564 ip32="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip32" | tr "\n" " ")"
566 if [ -n "${ip22}" ]; then
567 echo -e "${ip22base}" >> ${scratch}/arc.cf
568 for x in ${ip22}; do echo -e "${!x}" >> ${scratch}/arc.cf; done
569 echo -e "${ip22vid}${ip22x}" >> ${scratch}/arc.cf
572 [ -n "${ip27}" ] && echo -e "${ip27base}" >> ${scratch}/arc.cf
573 [ -n "${ip28}" ] && echo -e "${ip28base}" >> ${scratch}/arc.cf
574 [ -n "${ip30}" ] && echo -e "${ip30base}" >> ${scratch}/arc.cf
576 if [ -n "${ip32}" ]; then
577 echo -e "${ip32base}" >> ${scratch}/arc.cf
578 for x in ${ip32}; do echo -e "${!x}" >> ${scratch}/arc.cf; done
579 echo -e "${ip32vid}${ip32x}" >> ${scratch}/arc.cf
582 # Finish off the config
583 echo -e "${cmt2}" >> ${scratch}/arc.cf
585 # Move the bootloader binaries & config to their destination
586 mv ${1}/sashARCS ${1}/sash64 ${1}/arc.cf ${scratch}/arcload