fix the bootloader script for isolinux so that it actually makes a cfg file, remove...
[catalyst.git] / targets / support / bootloader-setup.sh
1 #!/bin/bash
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.15 2005/11/18 02:25:44 rocket Exp $
5 . ${clst_sharedir}/targets/support/functions.sh
6 . ${clst_sharedir}/targets/support/filesystem-functions.sh
7
8 # $1 is the destination root
9
10 extract_cdtar $1
11 extract_kernels $1/boot
12 check_dev_manager
13 check_bootargs
14 check_filesystem_type
15
16 default_append_line="initrd=${x}.igz root=/dev/ram0 init=/linuxrc ${cmdline_opts} ${custom_kopts} cdroot"
17
18 case ${clst_mainarch} in
19         alpha)
20                 acfg=$1/etc/aboot.conf
21                 bctr=0
22                 for x in ${clst_boot_kernel}
23                 do
24                         echo -n "${bctr}:/boot/${x} " >> ${acfg}
25                         echo -n "initrd=/boot/${x}.igz root=/dev/ram0 " >> ${acfg}
26                         echo "init=/linuxrc ${cmdline_opts} cdroot" >> ${acfg}
27                         ((bctr=${bctr}+1))
28                 done
29                 ;;
30
31         arm)
32                 ;;
33         hppa)
34                 icfg=$1/boot/palo.conf
35                 kmsg=$1/boot/kernels.msg
36                 hmsg=$1/boot/help.msg
37                 echo "--commandline=0/${first} initrd=${first}.igz root=/dev/ram0 init=/linuxrc ${cmdline_opts}" >> ${icfg}
38                 echo "--bootloader=boot/iplboot" >> ${icfg}
39                 echo "--ramdisk=boot/${first}.igz" >> ${icfg}
40                 ;;
41         ppc)
42                 # PPC requirements: 
43                 # -----------------
44                 # The specs indicate the kernels to be build. We need to put
45                 # those kernels and the corresponding initrd.img.gz(s) in the
46                 # /boot directory. This directory contains a message boot.msg 
47                 # containing some info to be displayed on boot, a configuration
48                 # (yaboot.conf) specifying the boot options (kernel/initrd 
49                 # combinations). The boot directory also contains a file called
50                 # yaboot, which normally gets copied from the live environment.
51                 # For now we supply a prebuilt file, prebuilt configuration 
52                 # and prebuilt boot message. This can be enhanced later on
53                 # but the following suffices for now:
54                 
55                 # this sets up the config file for yaboot
56                 icfg=$1/boot/yaboot.conf
57                 kmsg=$1/boot/boot.msg
58                 echo "default ${first}" > ${icfg}
59                 echo "timeout 300" >> ${icfg}
60                 echo "device=cd:" >> ${icfg}
61                 echo "root=/dev/ram" >> ${icfg}
62                 echo "fgcolor=white" >> ${icfg}
63                 echo "bgcolor=black" >> ${icfg}
64                 echo "message=/boot/boot.msg" >> ${icfg}
65                 for x in ${clst_boot_kernel}
66                 do
67                         eval custom_kopts=\$${x}_kernelopts
68                         echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
69                         echo >> ${icfg}
70                         echo "image=/boot/${x}" >> ${icfg}
71                         echo "initrd=/boot/${x}.igz" >> ${icfg}
72                         echo "label=${x}" >> ${icfg}
73                         echo "read-write" >> ${icfg}
74                         if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
75                         then
76                             echo "append ${default_append_line} vga=791 splash=silent,theme:${clst_livecd_splash_theme}" >> ${icfg}
77                         else
78                             echo "append ${default_append_line} vga=791 splash=silent" >> ${icfg}
79                         fi
80                 done
81                 ;;
82         sparc*)
83                 scfg=$1/boot/silo.conf
84                 echo "default=\"help\"" > ${scfg}
85                 echo "message=\"/boot/boot.msg\"" >> ${scfg}
86
87                 for x in ${clst_boot_kernel}
88                 do
89                         echo >> ${icfg}
90                         echo "image=\"/boot/${x}\"" >> ${scfg}
91                         echo -e "\tlabel=\"${x}\"" >> ${scfg}
92                         echo -e "\tappend=\"initrd=/boot/${x}.igz root=/dev/ram0 init=/linuxrc ${cmdline_opts} cdroot\"" >> ${scfg}
93
94                 done
95
96                 echo "image=\"cat /boot/silo.conf\"" >> ${scfg}
97                 echo -e "label=\"config\"" >> ${scfg}
98                 echo "image=\"cat /boot/video.msg\"" >> ${scfg}
99                 echo -e "label=\"video\"" >> ${scfg}
100                 echo "image=\"cat /boot/help.msg\"" >> ${scfg}
101                 echo -e "label=\"help\"" >> ${scfg}
102                 ;;
103         ia64)
104                 iacfg=$1/boot/elilo.conf
105                 echo 'prompt' > ${iacfg}
106                 echo 'message=/efi/boot/elilo.msg' >> ${iacfg}
107                 echo 'chooser=simple' >> ${iacfg}
108                 echo 'timeout=50' >> ${iacfg}
109                 echo >> ${iacfg}
110                 for x in ${clst_boot_kernel}
111                 do
112                         echo "image=/efi/boot/${x}" >> ${iacfg}
113                         echo "  label=${x}" >> ${iacfg}
114                         echo '  append="'${default_append_line}'"' >> ${iacfg}
115                         echo "  initrd=/efi/boot/${x}.igz" >> ${iacfg}
116                         echo >> ${iacfg}
117                         echo "image=/efi/boot/${x}" >> ${iacfg}
118                         echo "  label=${x}-serial">> ${iacfg}
119                         echo '  append="'${default_append_line}' console=tty0 console=ttyS0,9600"' >> ${iacfg}
120                         echo "  initrd=/efi/boot/${x}.igz" >> ${iacfg}
121                         echo >> ${iacfg}
122                 done
123                 cp ${iacfg} $1/boot/efi/boot
124                 mv $1/boot/${x}{,.igz} $1/boot/efi/boot
125                 ;;
126         x86|amd64)
127                 if [ -e $1/isolinux/isolinux.bin ]
128                 then
129                         mv $1/boot/* $1/isolinux
130                         rmdir $1/boot
131                         # the rest of this function sets up the config file for isolinux
132                         icfg=$1/isolinux/isolinux.cfg
133                         kmsg=$1/isolinux/kernels.msg
134                         echo "default ${first}" > ${icfg}
135                         echo "timeout 150" >> ${icfg}
136                         echo "prompt 1" >> ${icfg}
137                         echo "display boot.msg" >> ${icfg}
138                         echo "F1 kernels.msg" >> ${icfg}
139                         echo "F2 F2.msg" >> ${icfg}
140                         echo "F3 F3.msg" >> ${icfg}
141                         echo "F4 F4.msg" >> ${icfg}
142                         echo "F5 F5.msg" >> ${icfg}
143                         echo "F6 F6.msg" >> ${icfg}
144                         echo "F7 F7.msg" >> ${icfg}
145
146                         echo "Available kernels:" > ${kmsg}
147                         for i in 2 3 4 5 6 7
148                         do
149                                 cp ${clst_sharedir}/livecd/files/x86-F$i.msg \
150                                         $1/isolinux/F$i.msg
151                         done
152
153                         for x in ${clst_boot_kernel}
154                         do
155
156                                 eval custom_kopts=\$${x}_kernelopts
157                                 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
158                                 echo >> ${icfg}
159                                 echo "label ${x}" >> ${icfg}
160                                 echo "  kernel ${x}" >> ${icfg}
161                                 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
162                                 then
163                                         echo "  append ${default_append_line} vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
164                                 else
165                                         echo "  append ${default_append_line} vga=791 splash=silent" >> ${icfg}
166                                 fi
167                         
168                                 echo >> ${icfg}
169                                 echo "   ${x}" >> ${kmsg}
170                                 echo "label ${x}-nofb" >> ${icfg}
171                                 echo "  kernel ${x}" >> ${icfg}
172                                 echo "  append ${default_append_line}" >> ${icfg}
173                                 echo >> ${icfg}
174                                 echo "   ${x}-nofb" >> ${kmsg}
175                         done
176
177                         if [ -f $1/isolinux/memtest86 ]
178                         then
179                                 echo >> $icfg
180                                 echo "   memtest86" >> $kmsg
181                                 echo "label memtest86" >> $icfg
182                                 echo "  kernel memtest86" >> $icfg
183                         fi
184                 fi
185
186                 if [ -e $1/boot/grub/stage2_eltorito ]
187                 then
188                         icfg=$1/boot/grub/grub.conf
189                         echo "default 1" > ${icfg}
190                         echo "timeout 150" >> ${icfg}
191
192                         # Setup help message
193                         echo >> ${icfg}
194                         echo "title help" >> ${icfg}
195                         for i in 2 3 4 5 6 7
196                         do
197                                 cp ${clst_sharedir}/livecd/files/README.txt
198                                         $1/boot/help.msg
199                                 echo "cat /boot/help.msg" >> ${icfg}
200                         done
201
202                         for x in ${clst_boot_kernel}
203                         do
204                                 eval custom_kopts=\$${x}_kernelopts
205                                 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
206                                 echo >> ${icfg}
207                                 echo "title ${x}" >> ${icfg}
208                                 
209                                 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
210                                 then
211                                         echo "kernel /boot/${x} ${default_append_line} vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" >> ${icfg}
212                                 else
213                                         echo "kernel /boot/${x} ${default_append_line} vga=791 splash=silent" >> ${icfg}
214                                 fi
215
216                                 if [ -e $1/boot/${x}.igz ]
217                                 then
218                                         echo "initrd /boot/${x}.igz" >> ${icfg}
219                                 fi
220                                 
221                                 echo >> ${icfg}
222                                 echo "title ${x} [ No FrameBuffer ]" >> ${icfg}
223                                 echo "kernel ${x} /boot/${x} ${default_append_line}" >> ${icfg}
224                                 if [ -e $1/boot/${x}.igz ]
225                                 then
226                                         echo "initrd /boot/${x}.igz" >> ${icfg}
227                                 fi
228                         done
229
230                         if [ -f $1/boot/memtest86 ]
231                         then
232                                 echo >> ${icfg}
233                                 echo "title memtest86" >> ${icfg}
234                                 echo "kernel /boot/memtest86" >> ${icfg}
235                         fi
236                 fi
237                 ;;
238         mips)
239                 # Mips is an interesting arch -- where most archs will
240                 # use ${1} as the root of the LiveCD, an SGI LiveCD lacks
241                 # such a root.  Instead, we will use ${1} as a scratch
242                 # directory to build the components we need for the
243                 # CD image, and then pass these components to the
244                 # `sgibootcd` tool which outputs a final CD image
245                 scratch="${1}"
246                 mkdir ${scratch}/kernels
247                 mkdir ${scratch}/kernels/misc
248                 mkdir ${scratch}/arcload
249                 echo "" > ${scratch}/arc.cf
250
251                 # Move kernel binaries to ${scratch}/kernels, and
252                 # move everything else to ${scratch}/kernels/misc
253                 for x in ${clst_boot_kernel}; do
254                         mv ${1}/boot/${x} ${scratch}/kernels
255                         mv ${1}/boot/${x}.igz ${scratch}/kernels/misc
256                 done
257                 rmdir ${1}/boot
258
259                 # Source the bashified arcload config
260                 source ${clst_sharedir}/targets/support/mips-arcload_conf.sh
261
262                 # Generate top portions of the config
263                 echo -e "${topofconfig}${serial}${dbg}${cmt1}" >> ${scratch}/arc.cf
264
265                 # Next, figure out what kernels were specified in the
266                 # spec file, and generate the appropriate arcload conf
267                 # blocks specific to each system
268                 ip22="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip22" | tr "\n" " ")"
269                 ip27="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip27" | tr "\n" " ")"
270                 ip28="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip28" | tr "\n" " ")"
271                 ip30="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip30" | tr "\n" " ")"
272                 ip32="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip32" | tr "\n" " ")"
273
274                 if [ -n "${ip22}" ]; then
275                         echo -e "${ip22base}" >> ${scratch}/arc.cf
276                         for x in ${ip22}; do echo -e "${!x}" >> ${scratch}/arc.cf; done
277                         echo -e "${ip22vid}${ip22x}" >> ${scratch}/arc.cf
278                 fi
279
280                 [ -n "${ip27}" ] && echo -e "${ip27base}" >> ${scratch}/arc.cf
281                 [ -n "${ip28}" ] && echo -e "${ip28base}" >> ${scratch}/arc.cf
282                 [ -n "${ip30}" ] && echo -e "${ip30base}" >> ${scratch}/arc.cf
283
284                 if [ -n "${ip32}" ]; then
285                         echo -e "${ip32base}" >> ${scratch}/arc.cf
286                         for x in ${ip32}; do echo -e "${!x}" >> ${scratch}/arc.cf; done
287                         echo -e "${ip32vid}${ip32x}" >> ${scratch}/arc.cf
288                 fi
289
290                 # Finish off the config
291                 echo -e "${cmt2}" >> ${scratch}/arc.cf
292
293                 # Move the bootloader binaries & config to their destination
294                 mv ${1}/sashARCS ${1}/sash64 ${1}/arc.cf ${scratch}/arcload
295                 ;;
296 esac
297 exit $?