aboutsummaryrefslogtreecommitdiff
blob: fe1f0fc4aecf55dd6948b15f6b536940ef71f727 (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
#!/bin/bash

source ${clst_sharedir}/targets/support/functions.sh
source ${clst_sharedir}/targets/support/filesystem-functions.sh

## START RUNSCRIPT

# Check for our CD ISO creation tools
case ${clst_hostarch} in
	mips)
   		cdmaker="sgibootcd"
		cdmakerpkg="sys-boot/sgibootcd"
		;;
	*)
		cdmaker="mkisofs"
		cdmakerpkg="app-cdr/cdrkit or app/cdr-cdrtools"
		;;
esac

[ ! -f /usr/bin/${cdmaker} ] \
   && echo && echo && die \
   "!!! /usr/bin/${cdmaker} is not found.  Have you merged ${cdmakerpkg}?" \
   && echo && echo

# If not volume ID is set, make up a sensible default
if [ -z "${clst_iso_volume_id}" ]
then
	case ${clst_livecd_type} in
		gentoo-*)
			case ${clst_hostarch} in
				alpha)
					clst_iso_volume_id="Gentoo Linux - Alpha"
				;;
				amd64)
					clst_iso_volume_id="Gentoo Linux - AMD64"
				;;
				arm)
					clst_iso_volume_id="Gentoo Linux - ARM"
				;;
				hppa)
					clst_iso_volume_id="Gentoo Linux - HPPA"
				;;
				ia64)
					clst_iso_volume_id="Gentoo Linux - IA64"
				;;
				m68k)
					clst_iso_volume_id="Gentoo Linux - M68K"
				;;
				mips)
					clst_iso_volume_id="Gentoo Linux - MIPS"
				;;
				ppc*|powerpc*)
					clst_iso_volume_id="Gentoo Linux - PowerPC"
				;;
				s390)
					clst_iso_volume_id="Gentoo Linux - S390"
				;;
				sh)
					clst_iso_volume_id="Gentoo Linux - SH"
				;;
				sparc*)
					clst_iso_volume_id="Gentoo Linux - SPARC"
				;;
				x86)
					clst_iso_volume_id="Gentoo Linux - x86"
				;;
				*)
					clst_iso_volume_id="Catalyst LiveCD"
				;;
				esac
	esac
fi

if [ "${clst_fstype}" == "zisofs" ]
then
	mkisofs_zisofs_opts="-z"
else
	mkisofs_zisofs_opts=""
fi

# Here we actually create the ISO images for each architecture
case ${clst_hostarch} in
	alpha)
		echo ">> Running mkisofs to create iso image...."
		echo ">> mkisofs -R -l -J ${mkisofs_zisofs_opts} -V \"${clst_iso_volume_id}\" -o ${1} ${clst_target_path}"
		mkisofs -R -l -J ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} ${clst_target_path} || die "Cannot make ISO image"
		isomarkboot ${1} /boot/bootlx
	;;
	arm)
	;;
	hppa)
		echo ">> Running mkisofs to create iso image...."
		echo ">> mkisofs -R -l -J ${mkisofs_zisofs_opts} -V \"${clst_iso_volume_id}\" -o ${1} ${clst_target_path}"
		mkisofs -R -l -J ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} ${clst_target_path} || die "Cannot make ISO image"
		pushd ${clst_target_path}
		palo -f boot/palo.conf -C ${1}
		popd
	;;
	ia64)
		if [ ! -e ${clst_target_path}/gentoo.efimg ]
		then
			iaSizeTemp=$(du -sk ${clst_target_path}/boot 2>/dev/null)
			iaSizeB=$(echo ${iaSizeTemp} | cut '-d ' -f1)
			iaSize=$((${iaSizeB}+32)) # Add slack

			dd if=/dev/zero of=${clst_target_path}/gentoo.efimg bs=1k \
				count=${iaSize}
			mkdosfs -F 16 -n GENTOO ${clst_target_path}/gentoo.efimg

			mkdir ${clst_target_path}/gentoo.efimg.mountPoint
			mount -t vfat -o loop ${clst_target_path}/gentoo.efimg \
				${clst_target_path}/gentoo.efimg.mountPoint

			echo '>> Populating EFI image...'
			cp -rv ${clst_target_path}/boot/* \
				${clst_target_path}/gentoo.efimg.mountPoint

			umount ${clst_target_path}/gentoo.efimg.mountPoint
			rmdir ${clst_target_path}/gentoo.efimg.mountPoint
		else
			echo ">> Found populated EFI image at \
				${clst_target_path}/gentoo.efimg"
		fi
		echo '>> Removing /boot...'
		rm -rf ${clst_target_path}/boot

		echo ">> Running mkisofs to create iso image...."
		echo ">> mkisofs -R -l -b gentoo.efimg -c boot.cat -no-emul-boot -J ${mkisofs_zisofs_opts} -V \"${clst_iso_volume_id}\" -o ${1} ${clst_target_path}"
		mkisofs -R -l -b gentoo.efimg -c boot.cat -no-emul-boot -J ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} ${clst_target_path} || die "Cannot make ISO image"
	;;
	mips)
		case ${clst_fstype} in
			squashfs)
				# $clst_target_path/[kernels|arcload] already exists, create loopback and sgibootcd
				[ ! -d "${clst_target_path}/loopback" ] && mkdir ${clst_target_path}/loopback
				[ ! -d "${clst_target_path}/sgibootcd" ] && mkdir ${clst_target_path}/sgibootcd

				# Setup variables
				[ -f "${clst_target_path}/livecd" ] && rm -f ${clst_target_path}/livecd
				img="${clst_target_path}/loopback/image.squashfs"
				knl="${clst_target_path}/kernels"
				arc="${clst_target_path}/arcload"
				cfg="${clst_target_path}/sgibootcd/sgibootcd.cfg"
				echo "" > ${cfg}

				# If the image file exists in $clst_target_path, move it to the loopback dir
				[ -e "${clst_target_path}/image.squashfs" ] \
					&& mv -f ${clst_target_path}/image.squashfs ${clst_target_path}/loopback

				# An sgibootcd config is essentially a collection of commandline params
				# stored in a text file.  We could pass these on the command line, but it's
				# far easier to generate a config file and pass it to sgibootcd versus using a
				# ton of commandline params.
				#
				# f=	indicates files to go into DVH (disk volume header) in an SGI disklabel
				#	    format: f=</path/to/file>@<DVH name>
				# p0=	the first partition holds the LiveCD rootfs image
				#	    format: p0=</path/to/image>
				# p8=	the eighth partition is the DVH partition
				# p10=	the tenth partition is the disk volume partition
				#	    format: p8= is always "#dvh" and p10= is always "#volume"

				# Add the kernels to the sgibootcd config
				for x in ${clst_boot_kernel}; do
					echo -e "f=${knl}/${x}@${x}" >> ${cfg}
				done

				# Next, the bootloader binaries and config
				echo -e "f=${arc}/sash64@sash64" >> ${cfg}
				echo -e "f=${arc}/sashARCS@sashARCS" >> ${cfg}
				echo -e "f=${arc}/arc.cf@arc.cf" >> ${cfg}

				# Next, the Loopback Image
				echo -e "p0=${img}" >> ${cfg}

				# Finally, the required SGI Partitions (dvh, volume)
				echo -e "p8=#dvh" >> ${cfg}
				echo -e "p10=#volume" >> ${cfg}

				# All done; feed the config to sgibootcd and end up with an image
				# c=	the config file
				# o=	output image (burnable to CD; readable by fdisk)
				/usr/bin/sgibootcd c=${cfg} o=${clst_iso}
			;;
			*) die "SGI LiveCD(s) only support the 'squashfs' fstype!"	;;
		esac
	;;
	ppc*|powerpc*)
		if [ -f ${clst_target_path}/ppc/bootinfo.txt ]
		then
			echo "bootinfo.txt found .. updating it"
			sed -i -e \
			's#^<description>.*</description>$#<description>'"${clst_iso_volume_id}"'</description>#' \
			${clst_target_path}/ppc/bootinfo.txt
			sed -i -e \
			's#^<os-name>.*</os-name>$#<os-name>'"${clst_iso_volume_id}"'</os-name>#' \
			${clst_target_path}/ppc/bootinfo.txt
		fi

		echo ">> Running mkisofs to create iso image...."
		echo ">> mkisofs -r -U -chrp-boot -netatalk -hfs -probe -map ${clst_target_path}boot/map.hfs -part -no-desktop -hfs-volid \"${clst_iso_volume_id}\" -hfs-bless ${clst_target_path}boot -hide-hfs \"zisofs\" -hide-hfs \"stages\" -hide-hfs \"distfiles\" -hide-hfs \"snapshots\" -J ${mkisofs_zisofs_opts} -V \"${clst_iso_volume_id}\" -o ${1} ${clst_target_path}"
		mkisofs -r -U -chrp-boot -netatalk -hfs -probe -map ${clst_target_path}boot/map.hfs -part -no-desktop -hfs-volid "${clst_iso_volume_id}" -hfs-bless ${clst_target_path}boot -hide-hfs "zisofs" -hide-hfs "stages" -hide-hfs "distfiles" -hide-hfs "snapshots" -J ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} ${clst_target_path} || die "Cannot make ISO image"
	;;
	sparc*)
		# Old silo (<=1.2.6) requires a specially built mkisofs
		# We try to autodetect this in a simple way, said mkisofs
		# should be in the cdtar, otherwise use the new style.
		if [ -x ${clst_target_path}/boot/mkisofs.sparc.fu ]
		then
			mv ${clst_target_path}/boot/mkisofs.sparc.fu /tmp
			echo "Running mkisofs.sparc.fu to create iso image...."
			echo "/tmp/mkisofs.sparc.fu ${mkisofs_zisofs_opts} -o ${1} -D -r -pad -quiet -S 'boot/cd.b' -B '/boot/second.b' -s '/boot/silo.conf' -V \"${clst_iso_volume_id}\" ${clst_target_path}"
			/tmp/mkisofs.sparc.fu ${mkisofs_zisofs_opts} -o ${1} -D -r -pad -quiet -S 'boot/cd.b' -B '/boot/second.b' -s '/boot/silo.conf' -V "${clst_iso_volume_id}" ${clst_target_path} || die "Cannot make ISO image"
			rm /tmp/mkisofs.sparc.fu
		else
			echo "Running mkisofs to create iso image...."
			echo "mkisofs -J -R -l ${mkisofs_zisofs_opts} -V \"${clst_iso_volume_id}\" -o ${1} -G \"${clst_target_path}/boot/isofs.b\" -B ... ${clst_target_path}"
			mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} -G "${clst_target_path}/boot/isofs.b" -B ... ${clst_target_path} || die "CAnnot make ISO image"
		fi

	;;
	x86|amd64)
		if [ -e ${clst_target_path}/boot/elilo.efi ]
		then
			if [ ! -e ${clst_target_path}/gentoo.efimg ]
			then
				iaSizeTemp=$(du -sk ${clst_target_path}/boot 2>/dev/null)
				iaSizeB=$(echo ${iaSizeTemp} | cut '-d ' -f1)
				iaSize=$((${iaSizeB}+32)) # Add slack

				dd if=/dev/zero of=${clst_target_path}/gentoo.efimg bs=1k \
					count=${iaSize}
				mkdosfs -F 16 -n GENTOO ${clst_target_path}/gentoo.efimg

				mkdir ${clst_target_path}/gentoo.efimg.mountPoint
				mount -t vfat -o loop ${clst_target_path}/gentoo.efimg \
					${clst_target_path}/gentoo.efimg.mountPoint

				echo "Populating EFI image"
				cp -rv ${clst_target_path}/boot/* \
					${clst_target_path}/gentoo.efimg.mountPoint

				umount ${clst_target_path}/gentoo.efimg.mountPoint
				rmdir ${clst_target_path}/gentoo.efimg.mountPoint
				if [ ! -e ${clst_target_path}/boot/grub/stage2_eltorito ]
				then
					echo "Removing /boot"
					rm -rf ${clst_target_path}/boot
				fi
			else
				echo "Found populated EFI image at \
					${clst_target_path}/gentoo.efimg"
			fi
		fi

		if [ -e ${clst_target_path}/isolinux/isolinux.bin ]
		then
			if [ -d ${clst_target_path}/boot ]
			then
				if [ -n "$(ls ${clst_target_path}/boot)" ]
				then
					mv ${clst_target_path}/boot/* ${clst_target_path}/isolinux
					rm -r ${clst_target_path}/boot
					echo "Creating ISO using ISOLINUX bootloader"
					echo "mkisofs -J -R -l ${mkisofs_zisofs_opts} -V \"${clst_iso_volume_id}\" -o ${1} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${clst_target_path}"
					mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${clst_target_path} || die "Cannot make ISO image"
					isohybrid ${1}
				elif [ -e ${clst_target_path}/gentoo.efimg ]
				then
					echo "Creating ISO using both ISOLINUX and EFI bootloader"
					echo "mkisofs -J -R -l ${mkisofs_zisofs_opts} -V \"${clst_iso_volume_id}\" -o ${1} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -b gentoo.efimg -c boot.cat -no-emul-boot -z ${clst_target_path}"
					mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -b gentoo.efimg -c boot.cat -no-emul-boot -z ${clst_target_path} || die "Cannot make ISO image"
				fi
			else
				echo "Creating ISO using ISOLINUX bootloader"
				echo "mkisofs -J -R -l ${mkisofs_zisofs_opts} -V \"${clst_iso_volume_id}\" -o ${1} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${clst_target_path}"
				mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${clst_target_path} || die "Cannot make ISO image"
				isohybrid ${1}
			fi
		elif [ -e ${clst_target_path}/boot/grub/stage2_eltorito ]
		then
			echo "Creating ISO using GRUB bootloader"
			echo "mkisofs -J -R -l ${mkisofs_zisofs_opts} -V \"${clst_iso_volume_id}\" -o ${1} -b boot/grub/stage2_eltorito -c boot/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${clst_target_path}"
			mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} -b boot/grub/stage2_eltorito -c boot/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${clst_target_path} || die "Cannot make ISO image"
		elif [ -e ${clst_target_path}/gentoo.efimg ]
		then
			echo 'Creating ISO using EFI bootloader'
			echo "mkisofs -J -R -l ${mkisofs_zisofs_opts} -V \"${clst_iso_volume_id}\" -o ${1} -b gentoo.efimg -c boot.cat -no-emul-boot ${clst_target_path}"
			mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} -b gentoo.efimg -c boot.cat -no-emul-boot ${clst_target_path} || die "Cannot make ISO image"
		else
			echo "mkisofs -J -R -l ${mkisofs_zisofs_opts} -V \"${clst_iso_volume_id}\" -o ${1} ${clst_target_path}"
			mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} ${clst_target_path} || die "Cannot make ISO image"
		fi
	;;
esac
exit  $?