mkisoimages.sh revision 221825
1239310Sdim#!/bin/sh
2239310Sdim#
3239310Sdim# Module: mkisoimages.sh
4239310Sdim# Author: Jordan K Hubbard
5239310Sdim# Date:   22 June 2001
6239310Sdim#
7239310Sdim# $FreeBSD: head/release/powerpc/mkisoimages.sh 221825 2011-05-12 22:31:13Z nwhitehorn $
8239310Sdim#
9239310Sdim# This script is used by release/Makefile to build the (optional) ISO images
10239310Sdim# for a FreeBSD release.  It is considered architecture dependent since each
11249423Sdim# platform has a slightly unique way of making bootable CDs.  This script
12249423Sdim# is also allowed to generate any number of images since that is more of
13249423Sdim# publishing decision than anything else.
14239310Sdim#
15239310Sdim# Usage:
16239310Sdim#
17239310Sdim# mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir]
18239310Sdim#
19243830Sdim# Where -b is passed if the ISO image should be made "bootable" by
20249423Sdim# whatever standards this architecture supports (may be unsupported),
21249423Sdim# image-label is the ISO image label, image-name is the filename of the
22249423Sdim# resulting ISO image, base-bits-dir contains the image contents and
23239310Sdim# extra-bits-dir, if provided, contains additional files to be merged
24239310Sdim# into base-bits-dir as part of making the image.
25243830Sdim
26239310Sdimif [ "x$1" = "x-b" ]; then
27239310Sdim	# Apple boot code
28239310Sdim	uudecode -o /tmp/hfs-boot-block.bz2 `dirname $0`/hfs-boot.bz2.uu
29239310Sdim	bzip2 -d /tmp/hfs-boot-block.bz2
30239310Sdim	OFFSET=$(hd /tmp/hfs-boot-block | grep 'Loader START' | cut -f 1 -d ' ')
31239310Sdim	OFFSET=0x$(echo 0x$OFFSET | awk '{printf("%x\n",$1/512);}')
32239310Sdim	dd if=$4/boot/loader of=/tmp/hfs-boot-block seek=$OFFSET conv=notrunc
33239310Sdim
34239310Sdim	bootable="-o bootimage=macppc;/tmp/hfs-boot-block -o no-emul-boot"
35239310Sdim
36239310Sdim	# pSeries/PAPR boot code
37239310Sdim	mkdir -p $4/ppc/chrp
38239310Sdim	cp $4/boot/loader $4/ppc/chrp
39239310Sdim	cat > $4/ppc/bootinfo.txt << EOF
40239310Sdim<chrp-boot>
41239310Sdim<description>FreeBSD Install</description>
42239310Sdim<os-name>FreeBSD</os-name>
43239310Sdim<boot-script>boot &device;:&partition;,\ppc\chrp\loader</boot-script>
44239310Sdim</chrp-boot>
45239310SdimEOF
46239310Sdim	shift
47239310Sdimelse
48239310Sdim	bootable=""
49239310Sdimfi
50239310Sdim
51239310Sdimif [ $# -lt 3 ]; then
52239310Sdim	echo Usage: $0 '[-b] image-label image-name base-bits-dir [extra-bits-dir]'
53239310Sdim	exit 1
54239310Sdimfi
55239310Sdim
56239310SdimLABEL=$1; shift
57243830SdimNAME=$1; shift
58243830Sdim
59243830Sdimecho "/dev/iso9660/`echo $LABEL | tr '[:lower:]' '[:upper:]'` / cd9660 ro 0 0" > $1/etc/fstab
60239310Sdimmakefs -t cd9660 $bootable -o rockridge -o label=$LABEL $NAME $*
61249423Sdimrm $1/etc/fstab
62249423Sdimrm /tmp/hfs-boot-block
63239310Sdimrm -rf $1/ppc
64239310Sdim
65239310Sdim