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.27 2006/01/27 22:49:10 rocket 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" >> ${icfg}
75 # Setup the IBM yaboot.conf
76 etc_icfg=$1/etc/yaboot.conf
79 echo "default ${first}" > ${etc_icfg}
80 echo "timeout 300" >> ${etc_icfg}
81 echo "device=cd:" >> ${etc_icfg}
82 echo "root=/dev/ram" >> ${etc_icfg}
83 echo "fgcolor=white" >> ${etc_icfg}
84 echo "bgcolor=black" >> ${etc_icfg}
85 echo "message=/boot/boot.msg" >> ${etc_icfg}
87 for x in ${clst_boot_kernel}
89 eval "clst_kernel_console=\$clst_boot_kernel_${x}_console"
90 eval "clst_kernel_machine_type=\$clst_boot_kernel_${x}_machine_type"
91 eval custom_kopts=\$${x}_kernelopts
93 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
94 if [ "${clst_kernel_machine_type}" == "ibm" ]
97 if [ -n "${clst_kernel_console}" ]
99 for y in ${clst_kernel_console}
103 echo "image=/boot/${x}" >> ${etc_icfg}
105 if [ -e "$1/boot/${x}.igz" ]
107 echo "initrd=/boot/${x}.igz" >> ${etc_icfg}
110 echo "label=${x} [${y}] " >> ${etc_icfg}
111 echo "read-write" >> ${icfg}
112 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
114 echo "append=\"${default_append_line} console=${y} splash=silent,theme:${clst_livecd_splash_theme}\"" >> ${etc_icfg}
116 echo "append=\"${default_append_line} console=${y} splash=silent\"" >> ${etc_icfg}
121 echo "image=/boot/${x}" >> ${etc_icfg}
123 if [ -e "$1/boot/${x}.igz" ]
125 echo "initrd=/boot/${x}.igz" >> ${etc_icfg}
128 echo "label=${x}" >> ${etc_icfg}
129 echo "read-write" >> ${etc_icfg}
130 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
132 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme}\"" >> ${etc_icfg}
134 echo "append=\"${default_append_line} splash=silent\"" >> ${etc_icfg}
138 if [ -n "${clst_kernel_console}" ]
140 for y in ${clst_kernel_console}
143 echo "image=/boot/${x}" >> ${icfg}
145 if [ -e "$1/boot/${x}.igz" ]
147 echo "initrd=/boot/${x}.igz" >> ${icfg}
150 echo "label=${x} [${y}] " >> ${icfg}
151 echo "read-write" >> ${icfg}
152 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
154 echo "append=\"${default_append_line} console=${y} splash=silent,theme:${clst_livecd_splash_theme}\"" >> ${icfg}
156 echo "append=\"${default_append_line} console=${y} splash=silent\"" >> ${icfg}
161 echo "image=/boot/${x}" >> ${icfg}
163 if [ -e "$1/boot/${x}.igz" ]
165 echo "initrd=/boot/${x}.igz" >> ${icfg}
168 echo "label=${x}" >> ${icfg}
169 echo "read-write" >> ${icfg}
170 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
172 echo "append=\"${default_append_line} splash=silent,theme:${clst_livecd_splash_theme}\"" >> ${icfg}
174 echo "append=\"${default_append_line} splash=silent\"" >> ${icfg}
180 if [ "${IBM_YABOOT}" == "FALSE" ]
192 # NO SOFTLEVEL SUPPORT YET
194 scfg=$1/boot/silo.conf
195 echo "default=\"help\"" > ${scfg}
196 echo "message=\"/boot/boot.msg\"" >> ${scfg}
198 for x in ${clst_boot_kernel}
201 echo "image=\"/boot/${x}\"" >> ${scfg}
202 echo -e "\tlabel=\"${x}\"" >> ${scfg}
203 echo -e "\tappend=\"initrd=/boot/${x}.igz root=/dev/ram0 init=/linuxrc ${cmdline_opts} cdroot\"" >> ${scfg}
207 echo "image=\"cat /boot/silo.conf\"" >> ${scfg}
208 echo -e "label=\"config\"" >> ${scfg}
209 echo "image=\"cat /boot/video.msg\"" >> ${scfg}
210 echo -e "label=\"video\"" >> ${scfg}
211 echo "image=\"cat /boot/help.msg\"" >> ${scfg}
212 echo -e "label=\"help\"" >> ${scfg}
215 # NO SOFTLEVEL SUPPORT YET
217 iacfg=$1/boot/elilo.conf
218 echo 'prompt' > ${iacfg}
219 echo 'message=/efi/boot/elilo.msg' >> ${iacfg}
220 echo 'chooser=simple' >> ${iacfg}
221 echo 'timeout=50' >> ${iacfg}
223 for x in ${clst_boot_kernel}
225 echo "image=/efi/boot/${x}" >> ${iacfg}
226 echo " label=${x}" >> ${iacfg}
227 echo ' append="'initrd=${x}.igz ${default_append_line}'"' >> ${iacfg}
228 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
230 echo "image=/efi/boot/${x}" >> ${iacfg}
231 echo " label=${x}-serial">> ${iacfg}
232 echo ' append="'initrd=${x}.igz ${default_append_line}' console=tty0 console=ttyS0,9600"' >> ${iacfg}
233 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
235 mv $1/boot/${x}{,.igz} $1/boot/efi/boot
237 cp ${iacfg} $1/boot/efi/boot
240 if [ -e $1/isolinux/isolinux.bin ]
242 mv $1/boot/* $1/isolinux
244 # the rest of this function sets up the config file for isolinux
245 icfg=$1/isolinux/isolinux.cfg
246 kmsg=$1/isolinux/kernels.msg
247 echo "default ${first}" > ${icfg}
248 echo "timeout 150" >> ${icfg}
249 echo "prompt 1" >> ${icfg}
250 echo "display boot.msg" >> ${icfg}
251 echo "F1 kernels.msg" >> ${icfg}
252 echo "F2 F2.msg" >> ${icfg}
253 echo "F3 F3.msg" >> ${icfg}
254 echo "F4 F4.msg" >> ${icfg}
255 echo "F5 F5.msg" >> ${icfg}
256 echo "F6 F6.msg" >> ${icfg}
257 echo "F7 F7.msg" >> ${icfg}
259 echo "Available kernels:" > ${kmsg}
262 cp ${clst_sharedir}/livecd/files/x86-F$i.msg \
266 for x in ${clst_boot_kernel}
268 eval custom_kopts=\$${x}_kernelopts
269 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
272 eval "clst_kernel_softlevel=\$clst_boot_kernel_${x}_softlevel"
274 if [ -n "${clst_kernel_softlevel}" ]
276 for y in ${clst_kernel_softlevel}
278 echo "label ${x}-${y}" >> ${icfg}
279 echo " kernel ${x}" >> ${icfg}
280 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
282 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
284 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791 splash=silent" >> ${icfg}
288 echo " ${x}" >> ${kmsg}
289 echo "label ${x}-${y}-nofb" >> ${icfg}
290 echo " kernel ${x}" >> ${icfg}
291 echo " append ${default_append_line} softlevel=${y} initrd=${x}.igz" >> ${icfg}
293 echo " ${x}-nofb" >> ${kmsg}
296 echo "label ${x}" >> ${icfg}
297 echo " kernel ${x}" >> ${icfg}
298 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
300 echo " append ${default_append_line} initrd=${x}.igz vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
302 echo " append ${default_append_line} initrd=${x}.igz vga=791 splash=silent" >> ${icfg}
306 echo " ${x}" >> ${kmsg}
307 echo "label ${x}-nofb" >> ${icfg}
308 echo " kernel ${x}" >> ${icfg}
309 echo " append ${default_append_line} initrd=${x}.igz" >> ${icfg}
311 echo " ${x}-nofb" >> ${kmsg}
315 if [ -f $1/isolinux/memtest86 ]
318 echo " memtest86" >> $kmsg
319 echo "label memtest86" >> $icfg
320 echo " kernel memtest86" >> $icfg
324 if [ -e $1/boot/efi/elilo.efi ]
326 iacfg=$1/boot/elilo.conf
327 echo 'prompt' > ${iacfg}
328 echo 'message=/efi/boot/elilo.msg' >> ${iacfg}
329 echo 'chooser=simple' >> ${iacfg}
330 echo 'timeout=50' >> ${iacfg}
332 for x in ${clst_boot_kernel}
334 echo "image=/efi/boot/${x}" >> ${iacfg}
335 echo " label=${x}" >> ${iacfg}
336 echo ' append="'initrd=${x}.igz ${default_append_line}'"' >> ${iacfg}
337 echo " initrd=/efi/boot/${x}.igz" >> ${iacfg}
339 echo "image=/efi/boot/${x}" >> ${iacfg}
341 cp -f $1/boot/${x}{,.igz} $1/boot/efi/boot > /dev/null
342 cp -f $1/isolinux/${x}{,.igz} $1/boot/efi/boot > /dev/null
344 cp ${iacfg} $1/boot/efi/boot
347 if [ -e $1/boot/grub/stage2_eltorito ]
349 icfg=$1/boot/grub/grub.conf
350 echo "default 1" > ${icfg}
351 echo "timeout 150" >> ${icfg}
355 echo "title help" >> ${icfg}
356 cp ${clst_sharedir}/livecd/files/README.txt \
358 echo "cat /boot/help.msg" >> ${icfg}
360 for x in ${clst_boot_kernel}
362 eval custom_kopts=\$${x}_kernelopts
363 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
366 eval "clst_kernel_softlevel=\$clst_boot_kernel_${x}_softlevel"
368 if [ -n "${clst_kernel_softlevel}" ]
370 for y in ${clst_kernel_softlevel}
372 echo "title ${x}-${y}" >> ${icfg}
373 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
375 echo "kernel /boot/${x} softlevel=${y} ${default_append_line} vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
377 echo "kernel /boot/${x} softlevel=${y} ${default_append_line} vga=791 splash=silent" >> ${icfg}
379 if [ -e $1/boot/${x}.igz ]
381 echo "initrd /boot/${x}.igz" >> ${icfg}
384 echo "title ${x}-${y} [ No FrameBuffer ]" >> ${icfg}
385 echo "kernel ${x} /boot/${x} softlevel=${y} ${default_append_line}" >> ${icfg}
386 if [ -e $1/boot/${x}.igz ]
388 echo "initrd /boot/${x}.igz" >> ${icfg}
393 echo "title ${x}" >> ${icfg}
394 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
396 echo "kernel /boot/${x} ${default_append_line} vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
398 echo "kernel /boot/${x} ${default_append_line} vga=791 splash=silent" >> ${icfg}
400 if [ -e $1/boot/${x}.igz ]
402 echo "initrd /boot/${x}.igz" >> ${icfg}
405 echo "title ${x} [ No FrameBuffer ]" >> ${icfg}
406 echo "kernel ${x} /boot/${x} ${default_append_line}" >> ${icfg}
407 if [ -e $1/boot/${x}.igz ]
409 echo "initrd /boot/${x}.igz" >> ${icfg}
415 if [ -f $1/boot/memtest86 ]
418 echo "title memtest86" >> ${icfg}
419 echo "kernel /boot/memtest86" >> ${icfg}
425 # NO SOFTLEVEL SUPPORT YET
428 # Mips is an interesting arch -- where most archs will
429 # use ${1} as the root of the LiveCD, an SGI LiveCD lacks
430 # such a root. Instead, we will use ${1} as a scratch
431 # directory to build the components we need for the
432 # CD image, and then pass these components to the
433 # `sgibootcd` tool which outputs a final CD image
435 mkdir ${scratch}/kernels
436 mkdir ${scratch}/kernels/misc
437 mkdir ${scratch}/arcload
438 echo "" > ${scratch}/arc.cf
440 # Move kernel binaries to ${scratch}/kernels, and
441 # move everything else to ${scratch}/kernels/misc
442 for x in ${clst_boot_kernel}; do
443 mv ${1}/boot/${x} ${scratch}/kernels
444 mv ${1}/boot/${x}.igz ${scratch}/kernels/misc
448 # Source the bashified arcload config
449 source ${clst_sharedir}/targets/support/mips-arcload_conf.sh
451 # Generate top portions of the config
452 echo -e "${topofconfig}${serial}${dbg}${cmt1}" >> ${scratch}/arc.cf
454 # Next, figure out what kernels were specified in the
455 # spec file, and generate the appropriate arcload conf
456 # blocks specific to each system
457 ip22="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip22" | tr "\n" " ")"
458 ip27="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip27" | tr "\n" " ")"
459 ip28="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip28" | tr "\n" " ")"
460 ip30="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip30" | tr "\n" " ")"
461 ip32="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip32" | tr "\n" " ")"
463 if [ -n "${ip22}" ]; then
464 echo -e "${ip22base}" >> ${scratch}/arc.cf
465 for x in ${ip22}; do echo -e "${!x}" >> ${scratch}/arc.cf; done
466 echo -e "${ip22vid}${ip22x}" >> ${scratch}/arc.cf
469 [ -n "${ip27}" ] && echo -e "${ip27base}" >> ${scratch}/arc.cf
470 [ -n "${ip28}" ] && echo -e "${ip28base}" >> ${scratch}/arc.cf
471 [ -n "${ip30}" ] && echo -e "${ip30base}" >> ${scratch}/arc.cf
473 if [ -n "${ip32}" ]; then
474 echo -e "${ip32base}" >> ${scratch}/arc.cf
475 for x in ${ip32}; do echo -e "${!x}" >> ${scratch}/arc.cf; done
476 echo -e "${ip32vid}${ip32x}" >> ${scratch}/arc.cf
479 # Finish off the config
480 echo -e "${cmt2}" >> ${scratch}/arc.cf
482 # Move the bootloader binaries & config to their destination
483 mv ${1}/sashARCS ${1}/sash64 ${1}/arc.cf ${scratch}/arcload