3 . ${clst_sharedir}/targets/support/functions.sh
4 . ${clst_sharedir}/targets/support/filesystem-functions.sh
8 # Check for our CD ISO creation tools
9 case ${clst_hostarch} in
12 cdmakerpkg="sys-boot/sgibootcd"
16 cdmakerpkg="app-cdr/cdrtools"
20 [ ! -f /usr/bin/${cdmaker} ] \
21 && echo && echo && die \
22 "!!! /usr/bin/${cdmaker} is not found. Have you merged ${cdmakerpkg}?" \
25 # If not volume ID is set, make up a sensible default
26 if [ -z "${clst_iso_volume_id}" ]
28 case ${clst_livecd_type} in
30 case ${clst_hostarch} in
32 clst_iso_volume_id="Gentoo Linux - Alpha"
35 clst_iso_volume_id="Gentoo Linux - AMD64"
38 clst_iso_volume_id="Gentoo Linux - ARM"
41 clst_iso_volume_id="Gentoo Linux - HPPA"
44 clst_iso_volume_id="Gentoo Linux - IA64"
47 clst_iso_volume_id="Gentoo Linux - M68K"
50 clst_iso_volume_id="Gentoo Linux - MIPS"
53 clst_iso_volume_id="Gentoo Linux - PPC"
56 clst_iso_volume_id="Gentoo Linux - PPC64"
59 clst_iso_volume_id="Gentoo Linux - S390"
62 clst_iso_volume_id="Gentoo Linux - SH"
65 clst_iso_volume_id="Gentoo Linux - SPARC"
68 clst_iso_volume_id="Gentoo Linux - X86"
71 clst_iso_volume_id="Catalyst LiveCD"
77 # Here we actually create the ISO images for each architecture
78 case ${clst_hostarch} in
80 case ${clst_fstype} in
82 echo "Running mkisofs to create iso image...."
83 echo "mkisofs -J -R -l -z -V \"${clst_iso_volume_id}\" -o \
84 ${1} ${clst_target_path}"
85 mkisofs -J -R -l -z -V "${clst_iso_volume_id}" -o ${1} \
86 ${clst_target_path} || die "Cannot make ISO image"
89 echo "Running mkisofs to create iso image...."
90 echo "mkisofs -J -R -l -V \"${clst_iso_volume_id}\" -o ${1} \
92 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o ${1} \
93 ${clst_target_path} || die "Cannot make ISO image"
96 isomarkboot ${1} /boot/bootlx
101 case ${clst_fstype} in
103 echo "Running mkisofs to create iso image...."
104 echo "mkisofs -J -R -l -z -V \"${clst_iso_volume_id}\" -o \
105 ${1} ${clst_target_path}"
106 mkisofs -J -R -l -z -V "${clst_iso_volume_id}" -o ${1} \
107 ${clst_target_path} || die "Cannot make ISO image"
110 echo "Running mkisofs to create iso image...."
111 echo "mkisofs -J -R -l -V \"${clst_iso_volume_id}\" -o ${1} \
113 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o ${1} \
114 ${clst_target_path} || die "Cannot make ISO image"
117 palo -f boot/palo.conf -C ${1}
120 if [ ! -e ${clst_target_path}/gentoo.efimg ]
122 iaSizeTemp=$(du -sk ${clst_target_path}/boot 2>/dev/null)
123 iaSizeB=$(echo ${iaSizeTemp} | cut '-d ' -f1)
124 iaSize=$((${iaSizeB}+32)) # Add slack
126 dd if=/dev/zero of=${clst_target_path}/gentoo.efimg bs=1k \
128 mkdosfs -F 16 -n GENTOO ${clst_target_path}/gentoo.efimg
130 mkdir ${clst_target_path}/gentoo.efimg.mountPoint
131 mount -t vfat -o loop ${clst_target_path}/gentoo.efimg \
132 ${clst_target_path}/gentoo.efimg.mountPoint
134 echo '>> Populating EFI image...'
135 cp -pPRv ${clst_target_path}/boot/* \
136 ${clst_target_path}/gentoo.efimg.mountPoint
138 umount ${clst_target_path}/gentoo.efimg.mountPoint
139 rmdir ${clst_target_path}/gentoo.efimg.mountPoint
141 echo ">> Found populated EFI image at \
142 ${clst_target_path}/gentoo.efimg"
144 echo '>> Removing /boot...'
145 rm -rf ${clst_target_path}/boot
147 echo '>> Generating ISO...'
148 echo "mkisofs -J -R -l -V \"${clst_iso_volume_id}\" -o ${1} -b \
149 gentoo.efimg -c boot.cat -no-emul-boot ${clst_target_path}"
150 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o ${1} -b gentoo.efimg -c \
151 boot.cat -no-emul-boot \
152 ${clst_target_path} || die "Cannot make ISO image"
155 case ${clst_fstype} in
157 # $clst_target_path/[kernels|arcload] already exists, create loopback and sgibootcd
158 [ ! -d "${clst_target_path}/loopback" ] && mkdir ${clst_target_path}/loopback
159 [ ! -d "${clst_target_path}/sgibootcd" ] && mkdir ${clst_target_path}/sgibootcd
162 [ -f "${clst_target_path}/livecd" ] && rm -f ${clst_target_path}/livecd
163 img="${clst_target_path}/loopback/image.squashfs"
164 knl="${clst_target_path}/kernels"
165 arc="${clst_target_path}/arcload"
166 cfg="${clst_target_path}/sgibootcd/sgibootcd.cfg"
169 # If the image file exists in $clst_target_path, move it to the loopback dir
170 [ -e "${clst_target_path}/image.squashfs" ] \
171 && mv -f ${clst_target_path}/image.squashfs ${clst_target_path}/loopback
173 # An sgibootcd config is essentially a collection of commandline params
174 # stored in a text file. We could pass these on the command line, but it's
175 # far easier to generate a config file and pass it to sgibootcd versus using a
176 # ton of commandline params.
178 # f= indicates files to go into DVH (disk volume header) in an SGI disklabel
179 # format: f=</path/to/file>@<DVH name>
180 # p0= the first partition holds the LiveCD rootfs image
181 # format: p0=</path/to/image>
182 # p8= the eighth partition is the DVH partition
183 # p10= the tenth partition is the disk volume partition
184 # format: p8= is always "#dvh" and p10= is always "#volume"
186 # Add the kernels to the sgibootcd config
187 for x in ${clst_boot_kernel}; do
188 echo -e "f=${knl}/${x}@${x}" >> ${cfg}
191 # Next, the bootloader binaries and config
192 echo -e "f=${arc}/sash64@sash64" >> ${cfg}
193 echo -e "f=${arc}/sashARCS@sashARCS" >> ${cfg}
194 echo -e "f=${arc}/arc.cf@arc.cf" >> ${cfg}
196 # Next, the Loopback Image
197 echo -e "p0=${img}" >> ${cfg}
199 # Finally, the required SGI Partitions (dvh, volume)
200 echo -e "p8=#dvh" >> ${cfg}
201 echo -e "p10=#volume" >> ${cfg}
203 # All done; feed the config to sgibootcd and end up with an image
205 # o= output image (burnable to CD; readable by fdisk)
206 /usr/bin/sgibootcd c=${cfg} o=${clst_iso}
208 *) die "SGI LiveCDs only support the 'normal' fstype!" ;;
212 case ${clst_fstype} in
214 echo "Running mkisofs to create iso image...."
215 echo "mkisofs -J -r -l -z -chrp-boot -netatalk -hfs -probe \
216 -map ${clst_target_path}boot/map.hfs -part -no-desktop \
217 -hfs-volid \"${clst_iso_volume_id}\" -hfs-bless \
218 ${clst_target_path}boot -V \"${clst_iso_volume_id}\" -o \
219 ${1} ${clst_target_path}"
220 mkisofs -J -r -l -z -chrp-boot -netatalk -hfs -probe -map \
221 ${clst_target_path}boot/map.hfs -part -no-desktop \
222 -hfs-volid "${clst_iso_volume_id}" -hfs-bless \
223 ${clst_target_path}boot -V "${clst_iso_volume_id}" -o \
224 ${1} ${clst_target_path} || die "Cannot make ISO image"
227 echo "Running mkisofs to create iso image...."
228 echo "mkisofs -J -r -l -chrp-boot -netatalk -hfs -probe -map \
229 ${clst_target_path}boot/map.hfs -part -no-desktop \
230 -hfs-volid \"${clst_iso_volume_id}\" -hfs-bless \
231 ${clst_target_path}boot -V \"${clst_iso_volume_id}\" -o \
232 ${1} ${clst_target_path}"
233 mkisofs -J -r -l -chrp-boot -netatalk -hfs -probe -map \
234 ${clst_target_path}boot/map.hfs -part -no-desktop \
235 -hfs-volid "${clst_iso_volume_id}" -hfs-bless \
236 ${clst_target_path}boot -V "${clst_iso_volume_id}" -o \
237 ${1} ${clst_target_path} || die "Cannot make ISO image"
242 if [ -f ${clst_target_path}/ppc/bootinfo.txt ]
244 echo "bootinfo.txt found .. updating it"
246 's#^<description>.*</description>$#<description>'"${clst_iso_volume_id}"'</description>#' \
247 ${clst_target_path}/ppc/bootinfo.txt
249 's#^<os-name>.*</os-name>$#<os-name>'"${clst_iso_volume_id}"'</os-name>#' \
250 ${clst_target_path}/ppc/bootinfo.txt
253 case ${clst_fstype} in
255 echo "Running mkisofs to create iso image...."
256 echo "mkisofs -J -r -U -z -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\" -V \"${clst_iso_volume_id}\" -o ${1} ${clst_target_path}"
257 mkisofs -J -r -U -z -chrp-boot -netatalk -hfs -probe -map \
258 ${clst_target_path}boot/map.hfs -part -no-desktop \
259 -hfs-volid "${clst_iso_volume_id}" -hfs-bless \
260 ${clst_target_path}boot -hide-hfs "zisofs" -hide-hfs "stages" \
261 -hide-hfs "distfiles" -hide-hfs "snapshots" \
262 -V "${clst_iso_volume_id}" -o \
263 ${1} ${clst_target_path} || die "Cannot make ISO image"
266 echo "Running mkisofs to create iso image...."
267 echo "mkisofs -J -r -U -chrp-boot -netatalk -hfs -probe -map \
268 ${clst_target_path}boot/map.hfs -part -no-desktop \
269 -hfs-volid \"${clst_iso_volume_id}\" -hfs-bless \
270 ${clst_target_path}boot -V \"${clst_iso_volume_id}\" \
271 -hide-hfs \"stages\" -hide-hfs \"distfiles\" -hide-hfs \"snapshots\" \
272 -hide-hfs \"image.loop\" -hide-hfs \"image.squashfs\" -hide-hfs \"image.jffs\" \
273 -hide-hfs \"image.cramfs\" \
274 -o ${1} ${clst_target_path}"
275 mkisofs -J -r -U -chrp-boot -netatalk -hfs -probe -map \
276 ${clst_target_path}boot/map.hfs -part -no-desktop \
277 -hfs-volid "${clst_iso_volume_id}" -hfs-bless \
278 ${clst_target_path}boot -V "${clst_iso_volume_id}" \
279 -hide-hfs "stages" -hide-hfs "distfiles" -hide-hfs "snapshots" \
280 -hide-hfs "image.loop" -hide-hfs "image.squashfs" -hide-hfs "image.jffs" \
281 -hide-hfs "image.cramfs" \
282 -o ${1} ${clst_target_path} || die "Cannot make ISO image"
287 # Old silo (<=1.2.6) requires a specially built mkisofs
288 # We try to autodetect this in a simple way, said mkisofs
289 # should be in the cdtar, otherwise use the new style.
290 if [ -x ${clst_target_path}/boot/mkisofs.sparc.fu ]
292 mv ${clst_target_path}/boot/mkisofs.sparc.fu /tmp
293 case ${clst_fstype} in
295 echo "Running mkisofs.sparc.fu to create iso image...."
296 echo "/tmp/mkisofs.sparc.fu -z -o ${1} -D -r -pad -quiet -S \
297 'boot/cd.b' -B '/boot/second.b' -s '/boot/silo.conf'"
298 echo "-V \"${clst_iso_volume_id}\" ${clst_target_path}"
299 /tmp/mkisofs.sparc.fu -z -o ${1} -D -r -pad -quiet -S 'boot/cd.b' \
300 -B '/boot/second.b' -s '/boot/silo.conf'\
301 -V "${clst_iso_volume_id}" ${clst_target_path} \
302 || die "Cannot make ISO image"
305 echo "Running mkisofs.sparc.fu to create iso image...."
306 echo "/tmp/mkisofs.sparc.fu -o ${1} -D -r -pad -quiet -S \
307 'boot/cd.b' -B '/boot/second.b' -s '/boot/silo.conf'"
308 echo "-V \"${clst_iso_volume_id}\" ${clst_target_path}"
309 /tmp/mkisofs.sparc.fu -o ${1} -D -r -pad -quiet -S 'boot/cd.b' \
310 -B '/boot/second.b' -s '/boot/silo.conf'\
311 -V "${clst_iso_volume_id}" ${clst_target_path} \
312 || die "Cannot make ISO image"
315 rm /tmp/mkisofs.sparc.fu
317 case ${clst_fstype} in
319 echo "Running mkisofs to create iso image...."
320 echo "mkisofs -J -R -l -z -V \"${clst_iso_volume_id}\" -o ${1} \
321 -G \"${clst_target_path}/boot/isofs.b\" -B ... \
323 mkisofs -J -R -l -z -V "${clst_iso_volume_id}" -o ${1} \
324 -G "${clst_target_path}/boot/isofs.b" -B ... \
325 ${clst_target_path} || die "CAnnot make ISO image"
328 echo "Running mkisofs to create iso image...."
329 echo "mkisofs -J -R -l -V \"${clst_iso_volume_id}\" -o ${1} \
330 -G \"${clst_target_path}/boot/isofs.b\" -B ... \
332 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o ${1} \
333 -G "${clst_target_path}/boot/isofs.b" -B ... \
334 ${clst_target_path} || die "CAnnot make ISO image"
341 if [ -e ${clst_target_path}/boot/elilo.efi ]
343 if [ ! -e ${clst_target_path}/gentoo.efimg ]
345 iaSizeTemp=$(du -sk ${clst_target_path}/boot 2>/dev/null)
346 iaSizeB=$(echo ${iaSizeTemp} | cut '-d ' -f1)
347 iaSize=$((${iaSizeB}+32)) # Add slack
349 dd if=/dev/zero of=${clst_target_path}/gentoo.efimg bs=1k \
351 mkdosfs -F 16 -n GENTOO ${clst_target_path}/gentoo.efimg
353 mkdir ${clst_target_path}/gentoo.efimg.mountPoint
354 mount -t vfat -o loop ${clst_target_path}/gentoo.efimg \
355 ${clst_target_path}/gentoo.efimg.mountPoint
357 echo "Populating EFI image"
358 cp -pPRv ${clst_target_path}/boot/* \
359 ${clst_target_path}/gentoo.efimg.mountPoint
361 umount ${clst_target_path}/gentoo.efimg.mountPoint
362 rmdir ${clst_target_path}/gentoo.efimg.mountPoint
364 echo "Found populated EFI image at \
365 ${clst_target_path}/gentoo.efimg"
367 if [ ! -e ${clst_target_path}/boot/grub/stage2_eltorito ]
369 echo "Removing /boot"
370 rm -rf ${clst_target_path}/boot
374 if [ -e ${clst_target_path}/isolinux/isolinux.bin ]
376 if [ -d ${clst_target_path}/boot ]
378 if [ -n "$(ls ${clst_target_path}/boot)" ]
380 mv ${clst_target_path}/boot/* ${clst_target_path}/isolinux
381 rm -r ${clst_target_path}/boot
382 echo "Creating ISO using ISOLINUX bootloader"
383 case ${clst_fstype} in
385 echo "mkisofs -J -R -l -V \
386 \"${clst_iso_volume_id}\" -o ${1} -b \
387 isolinux/isolinux.bin -c isolinux/boot.cat \
388 -no-emul-boot -boot-load-size 4 \
389 -boot-info-table -z ${clst_target_path}"
390 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o \
391 ${1} -b isolinux/isolinux.bin -c \
392 isolinux/boot.cat -no-emul-boot \
393 -boot-load-size 4 -boot-info-table -z \
394 ${clst_target_path} \
395 || die "Cannot make ISO image"
398 echo "mkisofs -J -R -l -V \
399 \"${clst_iso_volume_id}\" -o ${1} -b \
400 isolinux/isolinux.bin -c isolinux/boot.cat \
401 -no-emul-boot -boot-load-size 4 \
402 -boot-info-table ${clst_target_path}"
403 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o \
404 ${1} -b isolinux/isolinux.bin -c \
405 isolinux/boot.cat -no-emul-boot \
406 -boot-load-size 4 -boot-info-table \
407 ${clst_target_path} \
408 || die "Cannot make ISO image"
411 elif [ -e ${clst_target_path}/gentoo.efimg ]
413 echo "Creating ISO using both ISOLINUX and EFI bootloader"
414 case ${clst_fstype} in
416 echo "mkisofs -J -R -l -V \
417 \"${clst_iso_volume_id}\" -o ${1} -b \
418 isolinux/isolinux.bin -c isolinux/boot.cat \
419 -no-emul-boot -boot-load-size 4 \
420 -boot-info-table -eltorito-alt-boot -b \
421 gentoo.efimg -c boot.cat \
422 -no-emul-boot -z ${clst_target_path}"
423 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o \
424 ${1} -b isolinux/isolinux.bin -c \
425 isolinux/boot.cat -no-emul-boot \
426 -boot-load-size 4 -boot-info-table \
427 -eltorito-alt-boot -b gentoo.efimg -c \
428 boot.cat -no-emul-boot -z ${clst_target_path} \
429 || die "Cannot make ISO image"
432 echo "mkisofs -J -R -l -V \
433 \"${clst_iso_volume_id}\" -o ${1} -b \
434 isolinux/isolinux.bin -c isolinux/boot.cat \
435 -no-emul-boot -boot-load-size 4 \
436 -boot-info-table -eltorito-alt-boot -b \
437 gentoo.efimg -c boot.cat \
438 -no-emul-boot ${clst_target_path}"
439 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o \
440 ${1} -b isolinux/isolinux.bin -c \
441 isolinux/boot.cat -no-emul-boot \
442 -boot-load-size 4 -boot-info-table \
443 -eltorito-alt-boot -b gentoo.efimg -c boot.cat \
444 -no-emul-boot ${clst_target_path} \
445 || die "Cannot make ISO image"
450 echo "Creating ISO using ISOLINUX bootloader"
451 case ${clst_fstype} in
453 echo "mkisofs -J -R -l -V \
454 \"${clst_iso_volume_id}\" -o ${1} -b \
455 isolinux/isolinux.bin -c isolinux/boot.cat \
456 -no-emul-boot -boot-load-size 4 \
457 -boot-info-table -z ${clst_target_path}"
458 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o \
459 ${1} -b isolinux/isolinux.bin -c \
460 isolinux/boot.cat -no-emul-boot \
461 -boot-load-size 4 -boot-info-table -z \
462 ${clst_target_path} \
463 || die "Cannot make ISO image"
466 echo "mkisofs -J -R -l -V \
467 \"${clst_iso_volume_id}\" -o ${1} -b \
468 isolinux/isolinux.bin -c isolinux/boot.cat \
469 -no-emul-boot -boot-load-size 4 \
470 -boot-info-table ${clst_target_path}"
471 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o \
472 ${1} -b isolinux/isolinux.bin -c \
473 isolinux/boot.cat -no-emul-boot \
474 -boot-load-size 4 -boot-info-table \
475 ${clst_target_path} \
476 || die "Cannot make ISO image"
480 elif [ -e ${clst_target_path}/boot/grub/stage2_eltorito ]
482 echo "Creating ISO using GRUB bootloader"
483 case ${clst_fstype} in
485 echo "mkisofs -J -R -l -V \"${clst_iso_volume_id}\" -o \
486 ${1} -b boot/grub/stage2_eltorito -c boot/boot.cat \
487 -no-emul-boot -boot-load-size 4 -boot-info-table -z \
489 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o ${1} -b \
490 boot/grub/stage2_eltorito -c boot/boot.cat \
491 -no-emul-boot -boot-load-size 4 -boot-info-table -z \
492 ${clst_target_path} || die "Cannot make ISO image"
495 echo "mkisofs -J -R -l -V \"${clst_iso_volume_id}\" -o \
496 ${1} -b boot/grub/stage2_eltorito -c boot/boot.cat \
497 -no-emul-boot -boot-load-size 4 -boot-info-table \
499 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o ${1} -b \
500 boot/grub/stage2_eltorito -c boot/boot.cat \
501 -no-emul-boot -boot-load-size 4 -boot-info-table \
502 ${clst_target_path} || die "Cannot make ISO image"
505 elif [ -e ${clst_target_path}/gentoo.efimg ]
507 echo 'Creating ISO using EFI bootloader'
508 echo "mkisofs -J -R -l -V \"${clst_iso_volume_id}\" -o ${1} -b \
509 gentoo.efimg -c boot.cat -no-emul-boot ${clst_target_path}"
510 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o ${1} -b \
511 gentoo.efimg -c boot.cat -no-emul-boot ${clst_target_path} \
512 || die "Cannot make ISO image"
514 case ${clst_fstype} in
516 echo "mkisofs -J -R -l -V \"${clst_iso_volume_id}\" -o \
517 ${1} -z ${clst_target_path}"
518 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o ${1} \
519 -z ${clst_target_path} || die "Cannot make ISO image"
522 echo "mkisofs -J -R -l -V \"${clst_iso_volume_id}\" -o \
523 ${1} ${clst_target_path}"
524 mkisofs -J -R -l -V "${clst_iso_volume_id}" -o ${1} \
525 ${clst_target_path} || die "Cannot make ISO image"