aboutsummaryrefslogtreecommitdiff
blob: ffd6794fa17f7ceaadb186d4ed241a2ba97782e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
#!/bin/bash
. ${clst_sharedir}/targets/support/functions.sh
. ${clst_sharedir}/targets/support/filesystem-functions.sh

# $1 is the destination root

extract_cdtar $1
extract_kernels $1/boot
check_bootargs
check_filesystem_type

default_append_line="root=/dev/ram0 init=/linuxrc ${cmdline_opts} ${custom_kopts} cdroot"
[ -n "${clst_splash_theme}" ] && default_append_line="${default_append_line} splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet"

case ${clst_hostarch} in
	alpha)
		# NO SOFTLEVEL SUPPORT YET
		acfg=$1/etc/aboot.conf
		bctr=0
		# Pass 1 is for non-serial
		for x in ${clst_boot_kernel}
		do
			echo -n "${bctr}:/boot/${x} " >> ${acfg}
			echo -n "initrd=/boot/${x}.igz root=/dev/ram0 " >> ${acfg}
			echo "init=/linuxrc ${cmdline_opts} cdroot" >> ${acfg}
			((bctr=${bctr}+1))
		done
		# Pass 2 is for serial
		cmdline_opts="${cmdline_opts} console=ttyS0"
		for x in ${clst_boot_kernel}
		do
			echo -n "${bctr}:/boot/${x} " >> ${acfg}
			echo -n "initrd=/boot/${x}.igz root=/dev/ram0 " >> ${acfg}
			echo "init=/linuxrc ${cmdline_opts} cdroot" >> ${acfg}
			((bctr=${bctr}+1))
		done
	;;
	arm)
		# NO SOFTLEVEL SUPPORT YET
	;;
	hppa)
		# NO SOFTLEVEL SUPPORT YET
		icfg=$1/boot/palo.conf
		kmsg=$1/boot/kernels.msg
		hmsg=$1/boot/help.msg
		# Make sure we strip the extension to the kernel to allow palo to choose
		boot_kernel_common_name=${first/%32/}
		boot_kernel_common_name=${boot_kernel_common_name/%64/}
		echo "--commandline=0/${boot_kernel_common_name} initrd=${first}.igz root=/dev/ram0 init=/linuxrc cdroot ${cmdline_opts}" >> ${icfg}
		echo "--bootloader=boot/iplboot" >> ${icfg}
		echo "--ramdisk=boot/${first}.igz" >> ${icfg}
		for x in ${clst_boot_kernel}
		do
			echo "--recoverykernel=boot/${x}" >> ${icfg}
		done
	;;
	ppc*|powerpc*)
		# NO SOFTLEVEL SUPPORT YET
		icfg=$1/boot/yaboot.conf
		kmsg=$1/boot/boot.msg

		echo "device=cd:" >> ${icfg}
		echo "root=/dev/ram" >> ${icfg}
		echo "fgcolor=white" >> ${icfg}
		echo "bgcolor=black" >> ${icfg}
		echo "message=/boot/boot.msg" >> ${icfg}

		# Here is where I fix up the boot.msg file.
		sed -e 's/ARCH/PowerPC/' \
			-e 's/HARDWARE/Apple and IBM hardware/' \
			-i $kmsg

		# Setup the IBM yaboot.conf
		etc_icfg=$1/etc/yaboot.conf
		mkdir -p $1/etc
		IBM_YABOOT="FALSE"
		echo "root=/dev/ram" >> ${etc_icfg}
		echo "fgcolor=white" >> ${etc_icfg}
		echo "bgcolor=black" >> ${etc_icfg}
		echo "message=/boot/boot.msg" >> ${etc_icfg}

		for x in ${clst_boot_kernel}
		do
			eval "clst_kernel_console=\$clst_boot_kernel_${x}_console"
			eval "clst_kernel_machine_type=\$clst_boot_kernel_${x}_machine_type"
			eval custom_kopts=\$${x}_kernelopts

			echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
			if [ "${clst_kernel_machine_type}" == "ibm" ]
			then
				IBM_YABOOT="true"
				if [ -n "${clst_kernel_console}" ]
				then
					echo >> ${etc_icfg}
					echo "image=/boot/${x}" >> ${etc_icfg}

					if [ -e "$1/boot/${x}.igz" ]
					then
						echo "initrd=/boot/${x}.igz" >> ${etc_icfg}
					fi

					echo "label=${x}" >> ${etc_icfg}
					echo "read-write" >> ${icfg}
					echo "append=\"${default_append_line}\"" >> ${etc_icfg}

					for y in ${clst_kernel_console}
					do
						echo ${y}
						echo >> ${etc_icfg}
						echo "image=/boot/${x}" >> ${etc_icfg}

						if [ -e "$1/boot/${x}.igz" ]
						then
							echo "initrd=/boot/${x}.igz" >> ${etc_icfg}
						fi

						echo "label=${x}-${y} " >> ${etc_icfg}
						echo "read-write" >> ${icfg}
						echo "append=\"${default_append_line} console=${y}\"" >> ${etc_icfg}
					done
				else
					echo >> ${etc_icfg}
					echo "image=/boot/${x}" >> ${etc_icfg}

					if [ -e "$1/boot/${x}.igz" ]
					then
						echo "initrd=/boot/${x}.igz" >> ${etc_icfg}
					fi

					echo "label=${x}" >> ${etc_icfg}
					echo "read-write" >> ${etc_icfg}
					echo "append=\"${default_append_line}\"" >> ${etc_icfg}
				fi
			else
				# Here we wipe out the /ppc directory, if it exists.
				rm -rf $1/ppc
				if [ -n "${clst_kernel_console}" ]
				then
					echo >> ${icfg}
					echo "image=/boot/${x}" >> ${icfg}

					if [ -e "$1/boot/${x}.igz" ]
					then
						echo "initrd=/boot/${x}.igz" >> ${icfg}
					fi

					echo "label=${x}" >> ${icfg}
					echo "read-write" >> ${icfg}
					echo "append=\"${default_append_line}\"" >> ${icfg}

					for y in ${clst_kernel_console}
					do
						echo >> ${icfg}
						echo "image=/boot/${x}" >> ${icfg}

						if [ -e "$1/boot/${x}.igz" ]
						then
							echo "initrd=/boot/${x}.igz" >> ${icfg}
						fi

						echo "label=${x}-${y} " >> ${icfg}
						echo "read-write" >> ${icfg}
						echo "append=\"${default_append_line} console=${y}\"" >> ${icfg}
					done
				else
					echo >> ${icfg}
					echo "image=/boot/${x}" >> ${icfg}

					if [ -e "$1/boot/${x}.igz" ]
					then
						echo "initrd=/boot/${x}.igz" >> ${icfg}
					fi

					echo "label=${x}" >> ${icfg}
					echo "read-write" >> ${icfg}
					echo "append=\"${default_append_line}\"" >> ${icfg}
				fi
			fi
		done

		if [ "${IBM_YABOOT}" == "FALSE" ]
		then
			rm ${etc_kmsg}
			rmdir $1/etc
			if [ -d $1/ppc ]
			then
				rm -r $1/ppc
			fi
		fi

	;;
	sparc*)
		# NO SOFTLEVEL SUPPORT YET
		scfg=$1/boot/silo.conf
		echo "default=\"help\"" > ${scfg}
		echo "message=\"/boot/boot.msg\"" >> ${scfg}

		for x in ${clst_boot_kernel}
		do
			echo >> ${icfg}
			echo "image=\"/boot/${x}\"" >> ${scfg}
			echo -e "\tlabel=\"${x}\"" >> ${scfg}
			echo -e "\tappend=\"initrd=/boot/${x}.igz root=/dev/ram0 init=/linuxrc ${cmdline_opts} cdroot\"" >> ${scfg}

		done

		echo "image=\"cat /boot/silo.conf\"" >> ${scfg}
		echo -e "label=\"config\"" >> ${scfg}
		echo "image=\"cat /boot/video.msg\"" >> ${scfg}
		echo -e "label=\"video\"" >> ${scfg}
		echo "image=\"cat /boot/help.msg\"" >> ${scfg}
		echo -e "label=\"help\"" >> ${scfg}
		echo "image=\"cat /boot/parameters.msg\"" >> ${scfg}
		echo -e "label=\"parameters\"" >> ${scfg}
	;;
	ia64)
		# NO SOFTLEVEL SUPPORT YET
		iacfg=$1/boot/elilo.conf
		echo 'prompt' > ${iacfg}
		echo 'message=/efi/boot/elilo.msg' >> ${iacfg}
		echo 'chooser=simple' >> ${iacfg}
		echo 'timeout=50' >> ${iacfg}
		echo 'relocatable' >> ${iacfg}
		echo >> ${iacfg}
		for x in ${clst_boot_kernel}
		do
			echo "image=/efi/boot/${x}" >> ${iacfg}
			echo "  label=${x}" >> ${iacfg}
			echo '  append="'initrd=${x}.igz ${default_append_line}'"' >> ${iacfg}
			echo "  initrd=/efi/boot/${x}.igz" >> ${iacfg}
			echo >> ${iacfg}
			echo "image=/efi/boot/${x}" >> ${iacfg}
			echo "  label=${x}-serial">> ${iacfg}
			echo '  append="'initrd=${x}.igz ${default_append_line}' console=tty0 console=ttyS0,9600"' >> ${iacfg}
			echo "  initrd=/efi/boot/${x}.igz" >> ${iacfg}
			echo >> ${iacfg}
			echo "image=/efi/boot/${x}" >> ${iacfg}
			echo "  label=${x}-ilo">> ${iacfg}
			echo '  append="'initrd=${x}.igz ${default_append_line}' console=tty0 console=ttyS3,9600"' >> ${iacfg}
			echo "  initrd=/efi/boot/${x}.igz" >> ${iacfg}
			echo >> ${iacfg}
			echo "image=/efi/boot/${x}" >> ${iacfg}
			echo "  label=${x}-sgi">> ${iacfg}
			echo '  append="'initrd=${x}.igz ${default_append_line}' console=tty0 console=ttySG0,115200"' >> ${iacfg}
			echo "  initrd=/efi/boot/${x}.igz" >> ${iacfg}
			echo >> ${iacfg}
			mv $1/boot/${x}{,.igz} $1/boot/efi/boot
		done
		cp ${iacfg} $1/boot/efi/boot
	;;
	x86|amd64)
		if [ -e $1/isolinux/isolinux.bin ]
		then
			cp -f $1/boot/* $1/isolinux
			# the rest of this function sets up the config file for isolinux
			icfg=$1/isolinux/isolinux.cfg
			kmsg=$1/isolinux/kernels.msg
			echo "default ${first}" > ${icfg}
			echo "timeout 150" >> ${icfg}
			echo "prompt 1" >> ${icfg}
			echo "display boot.msg" >> ${icfg}
			echo "F1 kernels.msg" >> ${icfg}
			echo "F2 F2.msg" >> ${icfg}
			echo "F3 F3.msg" >> ${icfg}
			echo "F4 F4.msg" >> ${icfg}
			echo "F5 F5.msg" >> ${icfg}
			echo "F6 F6.msg" >> ${icfg}
			echo "F7 F7.msg" >> ${icfg}

			echo "Available kernels:" > ${kmsg}
			for i in 2 3 4 5 6 7
			do
				cp ${clst_sharedir}/files/livecd/x86-F$i.msg \
					$1/isolinux/F$i.msg
			done

			for x in ${clst_boot_kernel}
			do
				eval custom_kopts=\$${x}_kernelopts
				echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
				echo >> ${icfg}

				eval "clst_kernel_softlevel=\$clst_boot_kernel_${x}_softlevel"

				if [ -n "${clst_kernel_softlevel}" ]
				then
					for y in ${clst_kernel_softlevel}
					do
						echo "label ${x}-${y}" >> ${icfg}
						echo "  kernel ${x}" >> ${icfg}
						echo "  append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791" >> ${icfg}

						echo >> ${icfg}
						echo "   ${x}" >> ${kmsg}
						echo "label ${x}-${y}-nofb" >> ${icfg}
						echo "  kernel ${x}" >> ${icfg}
						echo "  append ${default_append_line} softlevel=${y} initrd=${x}.igz" >> ${icfg}
						echo >> ${icfg}
						echo "   ${x}-nofb" >> ${kmsg}
					done
				else
					echo "label ${x}" >> ${icfg}
					echo "  kernel ${x}" >> ${icfg}
					echo "  append ${default_append_line} initrd=${x}.igz vga=791" >> ${icfg}
					echo >> ${icfg}
					echo "   ${x}" >> ${kmsg}
					echo "label ${x}-nofb" >> ${icfg}
					echo "  kernel ${x}" >> ${icfg}
					echo "  append ${default_append_line} initrd=${x}.igz" >> ${icfg}
					echo >> ${icfg}
					echo "   ${x}-nofb" >> ${kmsg}
				fi
			done

			if [ -f $1/isolinux/memtest86 ]
			then
				echo >> $icfg
				echo "   memtest86" >> $kmsg
				echo "label memtest86" >> $icfg
				echo "  kernel memtest86" >> $icfg
			fi
		fi

		if [ -e $1/boot/efi/elilo.efi ]
		then
			[ -e $1/isolinux/elilo.efi ] && rm -f $1/isolinux/elilo.efi
			iacfg=$1/boot/elilo.conf
			echo 'prompt' > ${iacfg}
			echo 'message=/efi/boot/elilo.msg' >> ${iacfg}
			echo 'chooser=simple' >> ${iacfg}
			echo 'timeout=50' >> ${iacfg}
			echo >> ${iacfg}
			for x in ${clst_boot_kernel}
			do
				echo "image=/efi/boot/${x}" >> ${iacfg}
				echo "  label=${x}" >> ${iacfg}
				echo '  append="'initrd=${x}.igz ${default_append_line}'"' >> ${iacfg}
				echo "  initrd=/efi/boot/${x}.igz" >> ${iacfg}
				echo >> ${iacfg}
				echo "image=/efi/boot/${x}" >> ${iacfg}
				echo >> ${iacfg}
				cp -f $1/boot/${x}{,.igz} $1/boot/efi/boot > /dev/null
				cp -f $1/isolinux/${x}{,.igz} $1/boot/efi/boot > /dev/null
			done
			cp ${iacfg} $1/boot/efi/boot
		fi

		if [ -e $1/boot/grub/stage2_eltorito ]
		then
			icfg=$1/boot/grub/menu.lst
			echo "default 0" > ${icfg}
			echo "timeout 15" >> ${icfg}
			echo "pager on" >> ${icfg}

			# Copy our splash if we're a Gentoo release
			case ${clst_livecd_type} in
				gentoo-*)
					[ -e ${clst_chroot_path}/boot/grub/splash.xpm.gz ] && \
						cp -f ${clst_chroot_path}/boot/grub/splash.xpm.gz \
						${1}/boot/grub
				;;
			esac

			if [ -e ${1}/boot/grub/splash.xpm.gz ]; then
				echo "splashimage=/boot/grub/splash.xpm.gz" >> ${icfg}
			fi

			for x in ${clst_boot_kernel}
			do
				eval custom_kopts=\$${x}_kernelopts
				echo "APPENDING CUSTOM KERNEL ARGS: ${custom_kopts}"
				echo >> ${icfg}

				eval "clst_kernel_softlevel=\$clst_boot_kernel_${x}_softlevel"

				if [ -n "${clst_kernel_softlevel}" ]
				then
					for y in ${clst_kernel_softlevel}
					do
						echo "title ${x}-${y}" >> ${icfg}
						echo "  append ${default_append_line} softlevel=${y} initrd=${x}.igz vga=791" >> ${icfg}
						if [ -e $1/boot/${x}.igz ]
						then
							echo "initrd /boot/${x}.igz" >> ${icfg}
						fi
						echo >> ${icfg}
						echo "title ${x}-${y} [ No FrameBuffer ]" >> ${icfg}
						echo "kernel /boot/${x} softlevel=${y} ${default_append_line}" >> ${icfg}
						if [ -e $1/boot/${x}.igz ]
						then
							echo "initrd /boot/${x}.igz" >> ${icfg}
						fi
						echo >> ${icfg}
					done
				else
					echo "title ${x}" >> ${icfg}
					echo "kernel /boot/${x} ${default_append_line} vga=791" >> ${icfg}
					if [ -e $1/boot/${x}.igz ]
					then
						echo "initrd /boot/${x}.igz" >> ${icfg}
					fi
					echo >> ${icfg}
					echo "title ${x} [ No FrameBuffer ]" >> ${icfg}
					echo "kernel /boot/${x} ${default_append_line}" >> ${icfg}
					if [ -e $1/boot/${x}.igz ]
					then
						echo "initrd /boot/${x}.igz" >> ${icfg}
					fi
				fi

			done

			# Setup help message
			echo >> ${icfg}
			echo "title help" >> ${icfg}
			cp ${clst_sharedir}/files/livecd/README.txt \
				$1/boot/help.msg
			echo "cat /boot/help.msg" >> ${icfg}

			if [ -f $1/boot/memtest86 ]
			then
				echo >> ${icfg}
				echo "title memtest86" >> ${icfg}
				echo "kernel /boot/memtest86" >> ${icfg}
			fi
		fi
	;;
	mips)
		# NO SOFTLEVEL SUPPORT YET

		# Mips is an interesting arch -- where most archs will
		# use ${1} as the root of the LiveCD, an SGI LiveCD lacks
		# such a root.  Instead, we will use ${1} as a scratch
		# directory to build the components we need for the
		# CD image, and then pass these components to the
		# `sgibootcd` tool which outputs a final CD image
		scratch="${1}"
		[ ! -d "${scratch}/kernels" ] && mkdir ${scratch}/kernels
		[ ! -d "${scratch}/kernels/misc" ] && mkdir ${scratch}/kernels/misc
		[ ! -d "${scratch}/arcload" ] && mkdir ${scratch}/arcload
		echo "" > ${scratch}/arc.cf

		# Move kernel binaries to ${scratch}/kernels, and
		# move everything else to ${scratch}/kernels/misc
		for x in ${clst_boot_kernel}; do
			[ -e "${1}/boot/${x}" ] && mv ${1}/boot/${x} ${scratch}/kernels
			[ -e "${1}/boot/${x}.igz" ] && mv ${1}/boot/${x}.igz ${scratch}/kernels/misc
		done
		[ -d "${1}/boot" ] && rmdir ${1}/boot

		# Source the arcload source file to generated required sections of arc.cf
		source ${clst_sharedir}/targets/support/mips-arcload_conf.sh

		# Generate top portions of the config
		echo -e "${topofconfig}${serial}${dbg}${cmt1}" >> ${scratch}/arc.cf

		# Next, figure out what kernels were specified in the
		# spec file, and generate the appropriate arcload conf
		# blocks specific to each system
		ip22="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip22" | tr "\n" " ")"
		ip27="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip27" | tr "\n" " ")"
		ip28="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip28" | tr "\n" " ")"
		ip30="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip30" | tr "\n" " ")"
		ip32="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip32" | tr "\n" " ")"

		if [ -n "${ip22}" ]; then
			echo -e "${ip22base}" >> ${scratch}/arc.cf
			for x in ${ip22}; do echo -e "${!x}" >> ${scratch}/arc.cf; done
			echo -e "${ip22vid}${ip22x}" >> ${scratch}/arc.cf
		fi

		[ -n "${ip27}" ] && echo -e "${ip27base}" >> ${scratch}/arc.cf
		[ -n "${ip28}" ] && echo -e "${ip28base}" >> ${scratch}/arc.cf
		[ -n "${ip30}" ] && echo -e "${ip30base}" >> ${scratch}/arc.cf

		if [ -n "${ip32}" ]; then
			echo -e "${ip32base}" >> ${scratch}/arc.cf
			for x in ${ip32}; do echo -e "${!x}" >> ${scratch}/arc.cf; done
			echo -e "${ip32vid}${ip32x}" >> ${scratch}/arc.cf
		fi

		# Finish off the config
		echo -e "${cmt2}" >> ${scratch}/arc.cf

		# Move the bootloader binaries & config to their destination
		[ -e "${1}/sashARCS" ] && mv ${1}/sashARCS ${scratch}/arcload
		[ -e "${1}/sash64" ] && mv ${1}/sash64 ${scratch}/arcload
		[ -e "${1}/arc.cf" ] && mv ${1}/arc.cf ${scratch}/arcload
		;;
esac
exit $?