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.37 2006/06/15 22:18:51 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 # Pass 1 is for non-serial
24 for x in ${clst_boot_kernel}
26 echo -n "${bctr}:/boot/${x} " >> ${acfg}
27 echo -n "initrd=/boot/${x}.igz root=/dev/ram0 " >> ${acfg}
28 echo "init=/linuxrc ${cmdline_opts} cdroot" >> ${acfg}
31 # Pass 2 is for serial
32 cmdline_opts="${cmdline_opts} console=ttyS0"
33 for x in ${clst_boot_kernel}
35 echo -n "${bctr}:/boot/${x} " >> ${acfg}
36 echo -n "initrd=/boot/${x}.igz root=/dev/ram0 " >> ${acfg}
37 echo "init=/linuxrc ${cmdline_opts} cdroot" >> ${acfg}
42 # NO SOFTLEVEL SUPPORT YET
45 # NO SOFTLEVEL SUPPORT YET
46 icfg=$1/boot/palo.conf
47 kmsg=$1/boot/kernels.msg
49 echo "--commandline=0/${first} initrd=${first}.igz root=/dev/ram0 init=/linuxrc ${cmdline_opts}" >> ${icfg}
50 echo "--bootloader=boot/iplboot" >> ${icfg}
51 echo "--ramdisk=boot/${first}.igz" >> ${icfg}
54 # NO SOFTLEVEL SUPPORT YET
58 # The specs indicate the kernels to be build. We need to put
59 # those kernels and the corresponding initrd.img.gz(s) in the
60 # /boot directory. This directory contains a message boot.msg
61 # containing some info to be displayed on boot, a configuration
62 # (yaboot.conf) specifying the boot options (kernel/initrd
63 # combinations). The boot directory also contains a file called
64 # yaboot, which normally gets copied from the live environment.
65 # For now we supply a prebuilt file, prebuilt configuration
66 # and prebuilt boot message. This can be enhanced later on
67 # but the following suffices for now:
69 # this sets up the config file for yaboot
72 # ADD RUNLEVEL SUPPORT ???
74 icfg=$1/boot/yaboot.conf
77 echo "default ${first}" > ${icfg}
78 echo "timeout 300" >> ${icfg}
79 echo "device=cd:" >> ${icfg}
80 echo "root=/dev/ram" >> ${icfg}
81 echo "fgcolor=white" >> ${icfg}
82 echo "bgcolor=black" >> ${icfg}
83 echo "message=/boot/boot.msg" >> ${icfg}
85 # Here is where I fix up the boot.msg file.
86 sed -e 's/ARCH/PPC/' \
87 -e 's/HARDWARE/32-bit Apple and Pegasos hardware/' \
90 # Here we wipe out the /ppc directory, if it exists.
93 for x in ${clst_boot_kernel}
95 eval custom_kopts=\$${x}_kernelopts
96 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
97 echo "image=/boot/${x}" >> ${icfg}
99 if [ -e "$1/boot/${x}.igz" ]
101 echo "initrd=/boot/${x}.igz" >> ${icfg}
104 echo "label=${x}" >> ${icfg}
105 echo "read-write" >> ${icfg}
106 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
108 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet\"" >> ${icfg}
110 echo "append=\"${default_append_line}\"" >> ${icfg}
116 # NO SOFTLEVEL SUPPORT YET
120 # The specs indicate the kernels to be build. We need to put
121 # those kernels and the corresponding initrd.img.gz(s) in the
122 # /boot directory. This directory contains a message boot.msg
123 # containing some info to be displayed on boot, a configuration
124 # (yaboot.conf) specifying the boot options (kernel/initrd
125 # combinations). The boot directory also contains a file called
126 # yaboot, which normally gets copied from the live environment.
127 # For now we supply a prebuilt file, prebuilt configuration
128 # and prebuilt boot message. This can be enhanced later on
129 # but the following suffices for now:
131 # this sets up the config file for yaboot
134 # ADD RUNLEVEL SUPPORT ???
136 icfg=$1/boot/yaboot.conf
137 kmsg=$1/boot/boot.msg
139 echo "device=cd:" >> ${icfg}
140 echo "root=/dev/ram" >> ${icfg}
141 echo "fgcolor=white" >> ${icfg}
142 echo "bgcolor=black" >> ${icfg}
143 echo "message=/boot/boot.msg" >> ${icfg}
145 # Here is where I fix up the boot.msg file.
146 sed -e 's/ARCH/PPC/' \
147 -e 's/HARDWARE/64-bit Apple and IBM hardware/' \
150 # Setup the IBM yaboot.conf
151 etc_icfg=$1/etc/yaboot.conf
154 echo "root=/dev/ram" >> ${etc_icfg}
155 echo "fgcolor=white" >> ${etc_icfg}
156 echo "bgcolor=black" >> ${etc_icfg}
157 echo "message=/boot/boot.msg" >> ${etc_icfg}
159 for x in ${clst_boot_kernel}
161 eval "clst_kernel_console=\$clst_boot_kernel_${x}_console"
162 eval "clst_kernel_machine_type=\$clst_boot_kernel_${x}_machine_type"
163 eval custom_kopts=\$${x}_kernelopts
165 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
166 if [ "${clst_kernel_machine_type}" == "ibm" ]
169 if [ -n "${clst_kernel_console}" ]
172 echo "image=/boot/${x}" >> ${etc_icfg}
174 if [ -e "$1/boot/${x}.igz" ]
176 echo "initrd=/boot/${x}.igz" >> ${etc_icfg}
179 echo "label=${x}" >> ${etc_icfg}
180 echo "read-write" >> ${icfg}
181 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
183 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet\"" >> ${etc_icfg}
185 echo "append=\"${default_append_line}\"" >> ${etc_icfg}
188 for y in ${clst_kernel_console}
192 echo "image=/boot/${x}" >> ${etc_icfg}
194 if [ -e "$1/boot/${x}.igz" ]
196 echo "initrd=/boot/${x}.igz" >> ${etc_icfg}
199 echo "label=${x}-${y} " >> ${etc_icfg}
200 echo "read-write" >> ${icfg}
201 echo "append=\"${default_append_line} console=${y}\"" >> ${etc_icfg}
205 echo "image=/boot/${x}" >> ${etc_icfg}
207 if [ -e "$1/boot/${x}.igz" ]
209 echo "initrd=/boot/${x}.igz" >> ${etc_icfg}
212 echo "label=${x}" >> ${etc_icfg}
213 echo "read-write" >> ${etc_icfg}
214 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
216 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet\"" >> ${etc_icfg}
218 echo "append=\"${default_append_line}\"" >> ${etc_icfg}
222 if [ -n "${clst_kernel_console}" ]
225 echo "image=/boot/${x}" >> ${icfg}
227 if [ -e "$1/boot/${x}.igz" ]
229 echo "initrd=/boot/${x}.igz" >> ${icfg}
232 echo "label=${x}" >> ${icfg}
233 echo "read-write" >> ${icfg}
234 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
236 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet\"" >> ${icfg}
238 echo "append=\"${default_append_line}\"" >> ${icfg}
241 for y in ${clst_kernel_console}
244 echo "image=/boot/${x}" >> ${icfg}
246 if [ -e "$1/boot/${x}.igz" ]
248 echo "initrd=/boot/${x}.igz" >> ${icfg}
251 echo "label=${x}-${y} " >> ${icfg}
252 echo "read-write" >> ${icfg}
253 echo "append=\"${default_append_line} console=${y}\"" >> ${icfg}
257 echo "image=/boot/${x}" >> ${icfg}
259 if [ -e "$1/boot/${x}.igz" ]
261 echo "initrd=/boot/${x}.igz" >> ${icfg}
264 echo "label=${x}" >> ${icfg}
265 echo "read-write" >> ${icfg}
266 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
268 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet\"" >> ${icfg}
270 echo "append=\"${default_append_line}\"" >> ${icfg}
276 if [ "${IBM_YABOOT}" == "FALSE" ]
288 # NO SOFTLEVEL SUPPORT YET
290 scfg=$1/boot/silo.conf
291 echo "default=\"help\"" > ${scfg}
292 echo "message=\"/boot/boot.msg\"" >> ${scfg}
294 for x in ${clst_boot_kernel}
297 echo "image=\"/boot/${x}\"" >> ${scfg}
298 echo -e "\tlabel=\"${x}\"" >> ${scfg}
299 echo -e "\tappend=\"initrd=/boot/${x}.igz root=/dev/ram0 init=/linuxrc ${cmdline_opts} cdroot\"" >> ${scfg}
303 echo "image=\"cat /boot/silo.conf\"" >> ${scfg}
304 echo -e "label=\"config\"" >> ${scfg}
305 echo "image=\"cat /boot/video.msg\"" >> ${scfg}
306 echo -e "label=\"video\"" >> ${scfg}
307 echo "image=\"cat /boot/help.msg\"" >> ${scfg}
308 echo -e "label=\"help\"" >> ${scfg}
311 # NO SOFTLEVEL SUPPORT YET
313 iacfg=$1/boot/elilo.conf
314 echo 'prompt' > ${iacfg}
315 echo 'message=/efi/boot/elilo.msg' >> ${iacfg}
316 echo 'chooser=simple' >> ${iacfg}
317 echo 'timeout=50' >> ${iacfg}
318 echo 'relocatable' >> ${iacfg}
320 for x in ${clst_boot_kernel}
322 echo "image=/efi/boot/${x}" >> ${iacfg}
323 echo " label=${x}" >> ${iacfg}
324 echo ' append="'initrd=${x}.igz ${default_append_line}'"' >> ${iacfg}
325 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
327 echo "image=/efi/boot/${x}" >> ${iacfg}
328 echo " label=${x}-serial">> ${iacfg}
329 echo ' append="'initrd=${x}.igz ${default_append_line}' console=tty0 console=ttyS0,9600"' >> ${iacfg}
330 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
332 echo "image=/efi/boot/${x}" >> ${iacfg}
333 echo " label=${x}-sgi">> ${iacfg}
334 echo ' append="'initrd=${x}.igz ${default_append_line}' console=tty0 console=ttySG0,115200"' >> ${iacfg}
335 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
337 mv $1/boot/${x}{,.igz} $1/boot/efi/boot
339 cp ${iacfg} $1/boot/efi/boot
342 if [ -e $1/isolinux/isolinux.bin ]
344 mv $1/boot/* $1/isolinux
346 # the rest of this function sets up the config file for isolinux
347 icfg=$1/isolinux/isolinux.cfg
348 kmsg=$1/isolinux/kernels.msg
349 echo "default ${first}" > ${icfg}
350 echo "timeout 150" >> ${icfg}
351 echo "prompt 1" >> ${icfg}
352 echo "display boot.msg" >> ${icfg}
353 echo "F1 kernels.msg" >> ${icfg}
354 echo "F2 F2.msg" >> ${icfg}
355 echo "F3 F3.msg" >> ${icfg}
356 echo "F4 F4.msg" >> ${icfg}
357 echo "F5 F5.msg" >> ${icfg}
358 echo "F6 F6.msg" >> ${icfg}
359 echo "F7 F7.msg" >> ${icfg}
361 echo "Available kernels:" > ${kmsg}
364 cp ${clst_sharedir}/livecd/files/x86-F$i.msg \
368 for x in ${clst_boot_kernel}
370 eval custom_kopts=\$${x}_kernelopts
371 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
374 eval "clst_kernel_softlevel=\$clst_boot_kernel_${x}_softlevel"
376 if [ -n "${clst_kernel_softlevel}" ]
378 for y in ${clst_kernel_softlevel}
380 echo "label ${x}-${y}" >> ${icfg}
381 echo " kernel ${x}" >> ${icfg}
382 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
384 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
385 elif [ "${clst_livecd_splash_type}" == "bootplash" -a -n "${clst_livecd_splash_theme}" ]
387 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791 splash=silent" >> ${icfg}
389 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791" >> ${icfg}
393 echo " ${x}" >> ${kmsg}
394 echo "label ${x}-${y}-nofb" >> ${icfg}
395 echo " kernel ${x}" >> ${icfg}
396 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz" >> ${icfg}
398 echo " ${x}-nofb" >> ${kmsg}
401 echo "label ${x}" >> ${icfg}
402 echo " kernel ${x}" >> ${icfg}
403 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
405 echo " append ${default_append_line} initrd=${x}.igz vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
406 elif [ "${clst_livecd_splash_type}" == "bootplash" -a -n "${clst_livecd_splash_theme}" ]
408 echo " append ${default_append_line} initrd=${x}.igz vga=791 splash=silent" >> ${icfg}
410 echo " append ${default_append_line} initrd=${x}.igz vga=791" >> ${icfg}
413 echo " ${x}" >> ${kmsg}
414 echo "label ${x}-nofb" >> ${icfg}
415 echo " kernel ${x}" >> ${icfg}
416 echo " append ${default_append_line} initrd=${x}.igz" >> ${icfg}
418 echo " ${x}-nofb" >> ${kmsg}
422 if [ -f $1/isolinux/memtest86 ]
425 echo " memtest86" >> $kmsg
426 echo "label memtest86" >> $icfg
427 echo " kernel memtest86" >> $icfg
431 if [ -e $1/boot/efi/elilo.efi ]
433 iacfg=$1/boot/elilo.conf
434 echo 'prompt' > ${iacfg}
435 echo 'message=/efi/boot/elilo.msg' >> ${iacfg}
436 echo 'chooser=simple' >> ${iacfg}
437 echo 'timeout=50' >> ${iacfg}
439 for x in ${clst_boot_kernel}
441 echo "image=/efi/boot/${x}" >> ${iacfg}
442 echo " label=${x}" >> ${iacfg}
443 echo ' append="'initrd=${x}.igz ${default_append_line}'"' >> ${iacfg}
444 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
446 echo "image=/efi/boot/${x}" >> ${iacfg}
448 cp -f $1/boot/${x}{,.igz} $1/boot/efi/boot > /dev/null
449 cp -f $1/isolinux/${x}{,.igz} $1/boot/efi/boot > /dev/null
451 cp ${iacfg} $1/boot/efi/boot
454 if [ -e $1/boot/grub/stage2_eltorito ]
456 icfg=$1/boot/grub/grub.conf
457 echo "default 1" > ${icfg}
458 echo "timeout 150" >> ${icfg}
462 echo "title help" >> ${icfg}
463 cp ${clst_sharedir}/livecd/files/README.txt \
465 echo "cat /boot/help.msg" >> ${icfg}
467 for x in ${clst_boot_kernel}
469 eval custom_kopts=\$${x}_kernelopts
470 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
473 eval "clst_kernel_softlevel=\$clst_boot_kernel_${x}_softlevel"
475 if [ -n "${clst_kernel_softlevel}" ]
477 for y in ${clst_kernel_softlevel}
479 echo "title ${x}-${y}" >> ${icfg}
480 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
482 echo "kernel /boot/${x} softlevel=${y} ${default_append_line} vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
483 elif [ "${clst_livecd_splash_type}" == "bootplash" -a -n "${clst_livecd_splash_theme}" ]
485 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791 splash=silent" >> ${icfg}
487 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791" >> ${icfg}
489 if [ -e $1/boot/${x}.igz ]
491 echo "initrd /boot/${x}.igz" >> ${icfg}
494 echo "title ${x}-${y} [ No FrameBuffer ]" >> ${icfg}
495 echo "kernel ${x} /boot/${x} softlevel=${y} ${default_append_line}" >> ${icfg}
496 if [ -e $1/boot/${x}.igz ]
498 echo "initrd /boot/${x}.igz" >> ${icfg}
503 echo "title ${x}" >> ${icfg}
504 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
506 echo "kernel /boot/${x} ${default_append_line} vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
507 elif [ "${clst_livecd_splash_type}" == "bootplash" -a -n "${clst_livecd_splash_theme}" ]
509 echo "kernel /boot/${x} ${default_append_line} vga=791 splash=silent" >> ${icfg}
511 echo "kernel /boot/${x} ${default_append_line} vga=791" >> ${icfg}
513 if [ -e $1/boot/${x}.igz ]
515 echo "initrd /boot/${x}.igz" >> ${icfg}
518 echo "title ${x} [ No FrameBuffer ]" >> ${icfg}
519 echo "kernel ${x} /boot/${x} ${default_append_line}" >> ${icfg}
520 if [ -e $1/boot/${x}.igz ]
522 echo "initrd /boot/${x}.igz" >> ${icfg}
528 if [ -f $1/boot/memtest86 ]
531 echo "title memtest86" >> ${icfg}
532 echo "kernel /boot/memtest86" >> ${icfg}
538 # NO SOFTLEVEL SUPPORT YET
541 # Mips is an interesting arch -- where most archs will
542 # use ${1} as the root of the LiveCD, an SGI LiveCD lacks
543 # such a root. Instead, we will use ${1} as a scratch
544 # directory to build the components we need for the
545 # CD image, and then pass these components to the
546 # `sgibootcd` tool which outputs a final CD image
548 mkdir ${scratch}/kernels
549 mkdir ${scratch}/kernels/misc
550 mkdir ${scratch}/arcload
551 echo "" > ${scratch}/arc.cf
553 # Move kernel binaries to ${scratch}/kernels, and
554 # move everything else to ${scratch}/kernels/misc
555 for x in ${clst_boot_kernel}; do
556 mv ${1}/boot/${x} ${scratch}/kernels
557 mv ${1}/boot/${x}.igz ${scratch}/kernels/misc
561 # Source the bashified arcload config
562 source ${clst_sharedir}/targets/support/mips-arcload_conf.sh
564 # Generate top portions of the config
565 echo -e "${topofconfig}${serial}${dbg}${cmt1}" >> ${scratch}/arc.cf
567 # Next, figure out what kernels were specified in the
568 # spec file, and generate the appropriate arcload conf
569 # blocks specific to each system
570 ip22="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip22" | tr "\n" " ")"
571 ip27="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip27" | tr "\n" " ")"
572 ip28="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip28" | tr "\n" " ")"
573 ip30="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip30" | tr "\n" " ")"
574 ip32="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip32" | tr "\n" " ")"
576 if [ -n "${ip22}" ]; then
577 echo -e "${ip22base}" >> ${scratch}/arc.cf
578 for x in ${ip22}; do echo -e "${!x}" >> ${scratch}/arc.cf; done
579 echo -e "${ip22vid}${ip22x}" >> ${scratch}/arc.cf
582 [ -n "${ip27}" ] && echo -e "${ip27base}" >> ${scratch}/arc.cf
583 [ -n "${ip28}" ] && echo -e "${ip28base}" >> ${scratch}/arc.cf
584 [ -n "${ip30}" ] && echo -e "${ip30base}" >> ${scratch}/arc.cf
586 if [ -n "${ip32}" ]; then
587 echo -e "${ip32base}" >> ${scratch}/arc.cf
588 for x in ${ip32}; do echo -e "${!x}" >> ${scratch}/arc.cf; done
589 echo -e "${ip32vid}${ip32x}" >> ${scratch}/arc.cf
592 # Finish off the config
593 echo -e "${cmt2}" >> ${scratch}/arc.cf
595 # Move the bootloader binaries & config to their destination
596 mv ${1}/sashARCS ${1}/sash64 ${1}/arc.cf ${scratch}/arcload