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.32 2006/02/14 00:04:14 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 for x in ${clst_boot_kernel}
77 eval custom_kopts=\$${x}_kernelopts
78 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
79 echo "image=/boot/${x}" >> ${icfg}
81 if [ -e "$1/boot/${x}.igz" ]
83 echo "initrd=/boot/${x}.igz" >> ${icfg}
86 echo "label=${x}" >> ${icfg}
87 echo "read-write" >> ${icfg}
88 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
90 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme}\"" >> ${icfg}
92 echo "append=\"${default_append_line} splash=silent\"" >> ${icfg}
98 # NO SOFTLEVEL SUPPORT YET
102 # The specs indicate the kernels to be build. We need to put
103 # those kernels and the corresponding initrd.img.gz(s) in the
104 # /boot directory. This directory contains a message boot.msg
105 # containing some info to be displayed on boot, a configuration
106 # (yaboot.conf) specifying the boot options (kernel/initrd
107 # combinations). The boot directory also contains a file called
108 # yaboot, which normally gets copied from the live environment.
109 # For now we supply a prebuilt file, prebuilt configuration
110 # and prebuilt boot message. This can be enhanced later on
111 # but the following suffices for now:
113 # this sets up the config file for yaboot
116 # ADD RUNLEVEL SUPPORT ???
118 icfg=$1/boot/yaboot.conf
119 kmsg=$1/boot/boot.msg
121 echo "device=cd:" >> ${icfg}
122 echo "root=/dev/ram" >> ${icfg}
123 echo "fgcolor=white" >> ${icfg}
124 echo "bgcolor=black" >> ${icfg}
125 echo "message=/boot/boot.msg" >> ${icfg}
127 # Setup the IBM yaboot.conf
128 etc_icfg=$1/etc/yaboot.conf
131 echo "root=/dev/ram" >> ${etc_icfg}
132 echo "fgcolor=white" >> ${etc_icfg}
133 echo "bgcolor=black" >> ${etc_icfg}
134 echo "message=/boot/boot.msg" >> ${etc_icfg}
136 for x in ${clst_boot_kernel}
138 eval "clst_kernel_console=\$clst_boot_kernel_${x}_console"
139 eval "clst_kernel_machine_type=\$clst_boot_kernel_${x}_machine_type"
140 eval custom_kopts=\$${x}_kernelopts
142 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
143 if [ "${clst_kernel_machine_type}" == "ibm" ]
146 if [ -n "${clst_kernel_console}" ]
149 echo "image=/boot/${x}" >> ${etc_icfg}
151 if [ -e "$1/boot/${x}.igz" ]
153 echo "initrd=/boot/${x}.igz" >> ${etc_icfg}
156 echo "label=${x}" >> ${etc_icfg}
157 echo "read-write" >> ${icfg}
158 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
160 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme}\"" >> ${etc_icfg}
162 echo "append=\"${default_append_line} splash=silent\"" >> ${etc_icfg}
165 for y in ${clst_kernel_console}
169 echo "image=/boot/${x}" >> ${etc_icfg}
171 if [ -e "$1/boot/${x}.igz" ]
173 echo "initrd=/boot/${x}.igz" >> ${etc_icfg}
176 echo "label=${x}-${y} " >> ${etc_icfg}
177 echo "read-write" >> ${icfg}
178 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
180 echo "append=\"${default_append_line} console=${y} splash=silent,theme:${clst_livecd_splash_theme}\"" >> ${etc_icfg}
182 echo "append=\"${default_append_line} console=${y} splash=silent\"" >> ${etc_icfg}
187 echo "image=/boot/${x}" >> ${etc_icfg}
189 if [ -e "$1/boot/${x}.igz" ]
191 echo "initrd=/boot/${x}.igz" >> ${etc_icfg}
194 echo "label=${x}" >> ${etc_icfg}
195 echo "read-write" >> ${etc_icfg}
196 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
198 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme}\"" >> ${etc_icfg}
200 echo "append=\"${default_append_line} splash=silent\"" >> ${etc_icfg}
204 if [ -n "${clst_kernel_console}" ]
207 echo "image=/boot/${x}" >> ${icfg}
209 if [ -e "$1/boot/${x}.igz" ]
211 echo "initrd=/boot/${x}.igz" >> ${icfg}
214 echo "label=${x}" >> ${icfg}
215 echo "read-write" >> ${icfg}
216 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
218 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme}\"" >> ${icfg}
220 echo "append=\"${default_append_line} splash=silent\"" >> ${icfg}
223 for y in ${clst_kernel_console}
226 echo "image=/boot/${x}" >> ${icfg}
228 if [ -e "$1/boot/${x}.igz" ]
230 echo "initrd=/boot/${x}.igz" >> ${icfg}
233 echo "label=${x}-${y} " >> ${icfg}
234 echo "read-write" >> ${icfg}
235 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
237 echo "append=\"${default_append_line} console=${y} splash=silent,theme:${clst_livecd_splash_theme}\"" >> ${icfg}
239 echo "append=\"${default_append_line} console=${y} splash=silent\"" >> ${icfg}
244 echo "image=/boot/${x}" >> ${icfg}
246 if [ -e "$1/boot/${x}.igz" ]
248 echo "initrd=/boot/${x}.igz" >> ${icfg}
251 echo "label=${x}" >> ${icfg}
252 echo "read-write" >> ${icfg}
253 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
255 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme}\"" >> ${icfg}
257 echo "append=\"${default_append_line} splash=silent\"" >> ${icfg}
263 if [ "${IBM_YABOOT}" == "FALSE" ]
275 # NO SOFTLEVEL SUPPORT YET
277 scfg=$1/boot/silo.conf
278 echo "default=\"help\"" > ${scfg}
279 echo "message=\"/boot/boot.msg\"" >> ${scfg}
281 for x in ${clst_boot_kernel}
284 echo "image=\"/boot/${x}\"" >> ${scfg}
285 echo -e "\tlabel=\"${x}\"" >> ${scfg}
286 echo -e "\tappend=\"initrd=/boot/${x}.igz root=/dev/ram0 init=/linuxrc ${cmdline_opts} cdroot\"" >> ${scfg}
290 echo "image=\"cat /boot/silo.conf\"" >> ${scfg}
291 echo -e "label=\"config\"" >> ${scfg}
292 echo "image=\"cat /boot/video.msg\"" >> ${scfg}
293 echo -e "label=\"video\"" >> ${scfg}
294 echo "image=\"cat /boot/help.msg\"" >> ${scfg}
295 echo -e "label=\"help\"" >> ${scfg}
298 # NO SOFTLEVEL SUPPORT YET
300 iacfg=$1/boot/elilo.conf
301 echo 'prompt' > ${iacfg}
302 echo 'message=/efi/boot/elilo.msg' >> ${iacfg}
303 echo 'chooser=simple' >> ${iacfg}
304 echo 'timeout=50' >> ${iacfg}
305 echo 'relocatable' >> ${iacfg}
307 for x in ${clst_boot_kernel}
309 echo "image=/efi/boot/${x}" >> ${iacfg}
310 echo " label=${x}" >> ${iacfg}
311 echo ' append="'initrd=${x}.igz ${default_append_line}'"' >> ${iacfg}
312 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
314 echo "image=/efi/boot/${x}" >> ${iacfg}
315 echo " label=${x}-serial">> ${iacfg}
316 echo ' append="'initrd=${x}.igz ${default_append_line}' console=tty0 console=ttyS0,9600"' >> ${iacfg}
317 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
319 echo "image=/efi/boot/${x}" >> ${iacfg}
320 echo " label=${x}-sgi">> ${iacfg}
321 echo ' append="'initrd=${x}.igz ${default_append_line}' console=tty0 console=ttySG0,115200"' >> ${iacfg}
322 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
324 mv $1/boot/${x}{,.igz} $1/boot/efi/boot
326 cp ${iacfg} $1/boot/efi/boot
329 if [ -e $1/isolinux/isolinux.bin ]
331 mv $1/boot/* $1/isolinux
333 # the rest of this function sets up the config file for isolinux
334 icfg=$1/isolinux/isolinux.cfg
335 kmsg=$1/isolinux/kernels.msg
336 echo "default ${first}" > ${icfg}
337 echo "timeout 150" >> ${icfg}
338 echo "prompt 1" >> ${icfg}
339 echo "display boot.msg" >> ${icfg}
340 echo "F1 kernels.msg" >> ${icfg}
341 echo "F2 F2.msg" >> ${icfg}
342 echo "F3 F3.msg" >> ${icfg}
343 echo "F4 F4.msg" >> ${icfg}
344 echo "F5 F5.msg" >> ${icfg}
345 echo "F6 F6.msg" >> ${icfg}
346 echo "F7 F7.msg" >> ${icfg}
348 echo "Available kernels:" > ${kmsg}
351 cp ${clst_sharedir}/livecd/files/x86-F$i.msg \
355 for x in ${clst_boot_kernel}
357 eval custom_kopts=\$${x}_kernelopts
358 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
361 eval "clst_kernel_softlevel=\$clst_boot_kernel_${x}_softlevel"
363 if [ -n "${clst_kernel_softlevel}" ]
365 for y in ${clst_kernel_softlevel}
367 echo "label ${x}-${y}" >> ${icfg}
368 echo " kernel ${x}" >> ${icfg}
369 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
371 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
373 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791 splash=silent" >> ${icfg}
377 echo " ${x}" >> ${kmsg}
378 echo "label ${x}-${y}-nofb" >> ${icfg}
379 echo " kernel ${x}" >> ${icfg}
380 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz" >> ${icfg}
382 echo " ${x}-nofb" >> ${kmsg}
385 echo "label ${x}" >> ${icfg}
386 echo " kernel ${x}" >> ${icfg}
387 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
389 echo " append ${default_append_line} initrd=${x}.igz vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
391 echo " append ${default_append_line} initrd=${x}.igz vga=791 splash=silent" >> ${icfg}
395 echo " ${x}" >> ${kmsg}
396 echo "label ${x}-nofb" >> ${icfg}
397 echo " kernel ${x}" >> ${icfg}
398 echo " append ${default_append_line} initrd=${x}.igz" >> ${icfg}
400 echo " ${x}-nofb" >> ${kmsg}
404 if [ -f $1/isolinux/memtest86 ]
407 echo " memtest86" >> $kmsg
408 echo "label memtest86" >> $icfg
409 echo " kernel memtest86" >> $icfg
413 if [ -e $1/boot/efi/elilo.efi ]
415 iacfg=$1/boot/elilo.conf
416 echo 'prompt' > ${iacfg}
417 echo 'message=/efi/boot/elilo.msg' >> ${iacfg}
418 echo 'chooser=simple' >> ${iacfg}
419 echo 'timeout=50' >> ${iacfg}
421 for x in ${clst_boot_kernel}
423 echo "image=/efi/boot/${x}" >> ${iacfg}
424 echo " label=${x}" >> ${iacfg}
425 echo ' append="'initrd=${x}.igz ${default_append_line}'"' >> ${iacfg}
426 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
428 echo "image=/efi/boot/${x}" >> ${iacfg}
430 cp -f $1/boot/${x}{,.igz} $1/boot/efi/boot > /dev/null
431 cp -f $1/isolinux/${x}{,.igz} $1/boot/efi/boot > /dev/null
433 cp ${iacfg} $1/boot/efi/boot
436 if [ -e $1/boot/grub/stage2_eltorito ]
438 icfg=$1/boot/grub/grub.conf
439 echo "default 1" > ${icfg}
440 echo "timeout 150" >> ${icfg}
444 echo "title help" >> ${icfg}
445 cp ${clst_sharedir}/livecd/files/README.txt \
447 echo "cat /boot/help.msg" >> ${icfg}
449 for x in ${clst_boot_kernel}
451 eval custom_kopts=\$${x}_kernelopts
452 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
455 eval "clst_kernel_softlevel=\$clst_boot_kernel_${x}_softlevel"
457 if [ -n "${clst_kernel_softlevel}" ]
459 for y in ${clst_kernel_softlevel}
461 echo "title ${x}-${y}" >> ${icfg}
462 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
464 echo "kernel /boot/${x} softlevel=${y} ${default_append_line} vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
466 echo "kernel /boot/${x} softlevel=${y} ${default_append_line} vga=791 splash=silent" >> ${icfg}
468 if [ -e $1/boot/${x}.igz ]
470 echo "initrd /boot/${x}.igz" >> ${icfg}
473 echo "title ${x}-${y} [ No FrameBuffer ]" >> ${icfg}
474 echo "kernel ${x} /boot/${x} softlevel=${y} ${default_append_line}" >> ${icfg}
475 if [ -e $1/boot/${x}.igz ]
477 echo "initrd /boot/${x}.igz" >> ${icfg}
482 echo "title ${x}" >> ${icfg}
483 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
485 echo "kernel /boot/${x} ${default_append_line} vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
487 echo "kernel /boot/${x} ${default_append_line} vga=791 splash=silent" >> ${icfg}
489 if [ -e $1/boot/${x}.igz ]
491 echo "initrd /boot/${x}.igz" >> ${icfg}
494 echo "title ${x} [ No FrameBuffer ]" >> ${icfg}
495 echo "kernel ${x} /boot/${x} ${default_append_line}" >> ${icfg}
496 if [ -e $1/boot/${x}.igz ]
498 echo "initrd /boot/${x}.igz" >> ${icfg}
504 if [ -f $1/boot/memtest86 ]
507 echo "title memtest86" >> ${icfg}
508 echo "kernel /boot/memtest86" >> ${icfg}
514 # NO SOFTLEVEL SUPPORT YET
517 # Mips is an interesting arch -- where most archs will
518 # use ${1} as the root of the LiveCD, an SGI LiveCD lacks
519 # such a root. Instead, we will use ${1} as a scratch
520 # directory to build the components we need for the
521 # CD image, and then pass these components to the
522 # `sgibootcd` tool which outputs a final CD image
524 mkdir ${scratch}/kernels
525 mkdir ${scratch}/kernels/misc
526 mkdir ${scratch}/arcload
527 echo "" > ${scratch}/arc.cf
529 # Move kernel binaries to ${scratch}/kernels, and
530 # move everything else to ${scratch}/kernels/misc
531 for x in ${clst_boot_kernel}; do
532 mv ${1}/boot/${x} ${scratch}/kernels
533 mv ${1}/boot/${x}.igz ${scratch}/kernels/misc
537 # Source the bashified arcload config
538 source ${clst_sharedir}/targets/support/mips-arcload_conf.sh
540 # Generate top portions of the config
541 echo -e "${topofconfig}${serial}${dbg}${cmt1}" >> ${scratch}/arc.cf
543 # Next, figure out what kernels were specified in the
544 # spec file, and generate the appropriate arcload conf
545 # blocks specific to each system
546 ip22="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip22" | tr "\n" " ")"
547 ip27="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip27" | tr "\n" " ")"
548 ip28="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip28" | tr "\n" " ")"
549 ip30="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip30" | tr "\n" " ")"
550 ip32="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip32" | tr "\n" " ")"
552 if [ -n "${ip22}" ]; then
553 echo -e "${ip22base}" >> ${scratch}/arc.cf
554 for x in ${ip22}; do echo -e "${!x}" >> ${scratch}/arc.cf; done
555 echo -e "${ip22vid}${ip22x}" >> ${scratch}/arc.cf
558 [ -n "${ip27}" ] && echo -e "${ip27base}" >> ${scratch}/arc.cf
559 [ -n "${ip28}" ] && echo -e "${ip28base}" >> ${scratch}/arc.cf
560 [ -n "${ip30}" ] && echo -e "${ip30base}" >> ${scratch}/arc.cf
562 if [ -n "${ip32}" ]; then
563 echo -e "${ip32base}" >> ${scratch}/arc.cf
564 for x in ${ip32}; do echo -e "${!x}" >> ${scratch}/arc.cf; done
565 echo -e "${ip32vid}${ip32x}" >> ${scratch}/arc.cf
568 # Finish off the config
569 echo -e "${cmt2}" >> ${scratch}/arc.cf
571 # Move the bootloader binaries & config to their destination
572 mv ${1}/sashARCS ${1}/sash64 ${1}/arc.cf ${scratch}/arcload