Forward port the changes from catalyst 1.1.9 to 1.1.10.10 to catalyst2. Need to...
[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.11 2005/08/09 19:02:31 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 ${keymap}" >> ${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/boot/isolinux.bin ]
128                 then
129                         # the rest of this function sets up the config file for isolinux
130                         icfg=$1/boot/isolinux.cfg
131                         kmsg=$1/boot/kernels.msg
132                         hmsg=$1/boot/help.msg
133                         echo "default ${first}" > ${icfg}
134                         echo "timeout 150" >> ${icfg}
135                         echo "prompt 1" >> ${icfg}
136                         echo "display boot.msg" >> ${icfg}
137                         echo "F1 kernels.msg" >> ${icfg}
138                         echo "F2 help.msg" >> ${icfg}
139
140                         echo "Available kernels:" > ${kmsg}
141                         cp ${clst_sharedir}/livecd/files/x86-help.msg ${hmsg}
142
143                         case ${clst_livecd_type} in
144                         gentoo-*)
145                                 keymap="dokeymap"
146                                 ;;
147                         esac
148
149                         for x in ${clst_boot_kernel}
150                         do
151
152                                 eval custom_kopts=\$${x}_kernelopts
153                                 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
154                                 echo >> ${icfg}
155                                 echo "label ${x}" >> ${icfg}
156                                 echo "  kernel ${x}" >> ${icfg}
157                                 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
158                                 then
159                                         echo "  append ${default_append_line} vga=791 splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet ${keymap}" >> ${icfg}
160                                 else
161                                         echo "  append ${default_append_line} vga=791 splash=silent ${keymap}" >> ${icfg}
162                                 fi
163                         
164                                 echo >> ${icfg}
165                                 echo "   ${x}" >> ${kmsg}
166                                 echo "label ${x}-nofb" >> ${icfg}
167                                 echo "  kernel ${x}" >> ${icfg}
168                                 echo "  append ${default_append_line} ${keymap}" >> ${icfg}
169                                 echo >> ${icfg}
170                                 echo "   ${x}-nofb" >> ${kmsg}
171                         done
172
173                         if [ -f $1/boot/memtest86 ]
174                         then
175                                 echo >> $icfg
176                                 echo "   memtest86" >> $kmsg
177                                 echo "label memtest86" >> $icfg
178                                 echo "  kernel memtest86" >> $icfg
179                         fi
180                 fi
181
182                 if [ -e $1/boot/grub/stage2_eltorito ]
183                 then
184                         icfg=$1/boot/grub/grub.conf
185                         echo "default 1" > ${icfg}
186                         echo "timeout 150" >> ${icfg}
187                         
188                         
189                         # Setup help message    
190                         hmsg=${clst_sharedir}/livecd/files/x86-help.msg
191                         hmsg_txt="$(cat ${hmsg})"
192                         
193                         echo >> ${icfg}
194                         echo "title help" >> ${icfg}
195                         echo "pause ${hmsg_txt}" >> ${icfg}
196                         
197                         
198                         for x in ${clst_boot_kernel}
199                         do
200                                 eval custom_kopts=\$${x}_kernelopts
201                                 echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
202                                 echo >> ${icfg}
203                                 echo "title ${x}" >> ${icfg}
204                                 
205                                 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
206                                 then
207                                         echo "kernel /boot/${x} ${default_append_line} vga=791 dokeymap splash=silent,theme:${clst_livecd_splash_theme}" >> ${icfg}
208                                 else
209                                         echo "kernel /boot/${x} ${default_append_line} vga=791 dokeymap splash=silent" >> ${icfg}
210                                 fi
211
212                                 if [ -e $1/boot/${x}.igz ]
213                                 then
214                                         echo "initrd /boot/${x}.igz" >> ${icfg}
215                                 fi
216                                 
217                                 echo >> ${icfg}
218                                 echo "title ${x} [ No FrameBuffer ]" >> ${icfg}
219                                 echo "kernel ${x} /boot/${x} ${default_append_line}" >> ${icfg}
220                                 if [ -e $1/boot/${x}.igz ]
221                                 then
222                                         echo "initrd /boot/${x}.igz" >> ${icfg}
223                                 fi
224                         done
225
226                         if [ -f $1/boot/memtest86 ]
227                         then
228                                 echo >> ${icfg}
229                                 echo "title memtest86" >> ${icfg}
230                                 echo "kernel /boot/memtest86" >> ${icfg}
231                         fi
232                 fi
233                 ;;
234 esac
235 exit $?