1133950Sgrehan#!/bin/sh
2133950Sgrehan#
3133950Sgrehan# Module: mkisoimages.sh
4133950Sgrehan# Author: Jordan K Hubbard
5133950Sgrehan# Date:   22 June 2001
6133950Sgrehan#
7133950Sgrehan# $FreeBSD$
8133950Sgrehan#
9133950Sgrehan# This script is used by release/Makefile to build the (optional) ISO images
10133950Sgrehan# for a FreeBSD release.  It is considered architecture dependent since each
11133950Sgrehan# platform has a slightly unique way of making bootable CDs.  This script
12133950Sgrehan# is also allowed to generate any number of images since that is more of
13133950Sgrehan# publishing decision than anything else.
14133950Sgrehan#
15133950Sgrehan# Usage:
16133950Sgrehan#
17133950Sgrehan# mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir]
18133950Sgrehan#
19133950Sgrehan# Where -b is passed if the ISO image should be made "bootable" by
20133950Sgrehan# whatever standards this architecture supports (may be unsupported),
21133950Sgrehan# image-label is the ISO image label, image-name is the filename of the
22133950Sgrehan# resulting ISO image, base-bits-dir contains the image contents and
23133950Sgrehan# extra-bits-dir, if provided, contains additional files to be merged
24133950Sgrehan# into base-bits-dir as part of making the image.
25133950Sgrehan
26133950Sgrehanif [ "x$1" = "x-b" ]; then
27221814Snwhitehorn	# Apple boot code
28287635Sdteske	uudecode -o /tmp/hfs-boot-block.bz2 "`dirname "$0"`/hfs-boot.bz2.uu"
29221465Snwhitehorn	bzip2 -d /tmp/hfs-boot-block.bz2
30221465Snwhitehorn	OFFSET=$(hd /tmp/hfs-boot-block | grep 'Loader START' | cut -f 1 -d ' ')
31221465Snwhitehorn	OFFSET=0x$(echo 0x$OFFSET | awk '{printf("%x\n",$1/512);}')
32287635Sdteske	dd if="$4/boot/loader" of=/tmp/hfs-boot-block seek=$OFFSET conv=notrunc
33221465Snwhitehorn
34221465Snwhitehorn	bootable="-o bootimage=macppc;/tmp/hfs-boot-block -o no-emul-boot"
35221814Snwhitehorn
36221814Snwhitehorn	# pSeries/PAPR boot code
37287635Sdteske	mkdir -p "$4/ppc/chrp"
38287635Sdteske	cp "$4/boot/loader" "$4/ppc/chrp"
39287635Sdteske	cat > "$4/ppc/bootinfo.txt" << EOF
40221825Snwhitehorn<chrp-boot>
41221825Snwhitehorn<description>FreeBSD Install</description>
42221825Snwhitehorn<os-name>FreeBSD</os-name>
43255641Snwhitehorn<boot-script>boot &device;:,\ppc\chrp\loader</boot-script>
44221825Snwhitehorn</chrp-boot>
45221814SnwhitehornEOF
46223001Snwhitehorn	bootable="$bootable -o chrp-boot"
47223001Snwhitehorn
48224866Snwhitehorn	# Playstation 3 boot code
49287635Sdteske	echo "FreeBSD Install='/boot/loader.ps3'" > "$4/etc/kboot.conf"
50224866Snwhitehorn
51133950Sgrehan	shift
52133950Sgrehanelse
53133950Sgrehan	bootable=""
54133950Sgrehanfi
55133950Sgrehan
56133950Sgrehanif [ $# -lt 3 ]; then
57287635Sdteske	echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]"
58133950Sgrehan	exit 1
59133950Sgrehanfi
60133950Sgrehan
61287635SdteskeLABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift
62287635SdteskeNAME="$1"; shift
63133950Sgrehan
64246283Shrspublisher="The FreeBSD Project.  http://www.FreeBSD.org/"
65287635Sdteskeecho "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$1/etc/fstab"
66287635Sdteskemakefs -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@"
67293223Sgjbrm -f "$1/etc/fstab"
68293223Sgjbrm -f /tmp/hfs-boot-block
69287635Sdteskerm -rf "$1/ppc"
70