1#!/bin/sh
2#
3# Module: mkisoimages.sh
4# Author: Jordan K Hubbard
5# Date:   22 June 2001
6#
7#
8# This script is used by release/Makefile to build the (optional) ISO images
9# for a FreeBSD release.  It is considered architecture dependent since each
10# platform has a slightly unique way of making bootable CDs.  This script
11# is also allowed to generate any number of images since that is more of
12# publishing decision than anything else.
13#
14# Usage:
15#
16# mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir]
17#
18# Where -b is passed if the ISO image should be made "bootable" by
19# whatever standards this architecture supports (may be unsupported),
20# image-label is the ISO image label, image-name is the filename of the
21# resulting ISO image, base-bits-dir contains the image contents and
22# extra-bits-dir, if provided, contains additional files to be merged
23# into base-bits-dir as part of making the image.
24
25set -e
26
27if [ "$1" = "-b" ]; then
28	MAKEFSARG="$4"
29else
30	MAKEFSARG="$3"
31fi
32
33if [ -f ${MAKEFSARG} ]; then
34	BASEBITSDIR=`dirname ${MAKEFSARG}`
35	METALOG=${MAKEFSARG}
36elif [ -d ${MAKEFSARG} ]; then
37	BASEBITSDIR=${MAKEFSARG}
38	METALOG=
39else
40	echo "${MAKEFSARG} must exist"
41	exit 1
42fi
43
44if [ "$1" = "-b" ]; then
45	# This is highly x86-centric and will be used directly below.
46	bootable="-o bootimage=i386;$BASEBITSDIR/boot/cdboot -o no-emul-boot"
47	shift
48else
49	bootable=""
50fi
51
52if [ $# -lt 3 ]; then
53	echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]"
54	exit 1
55fi
56
57LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift
58NAME="$1"; shift
59# MAKEFSARG extracted already
60shift
61
62publisher="The FreeBSD Project.  https://www.FreeBSD.org/"
63echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab"
64if [ -n "${METALOG}" ]; then
65	metalogfilename=$(mktemp /tmp/metalog.XXXXXX)
66	cat ${METALOG} > ${metalogfilename}
67	echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename}
68	MAKEFSARG=${metalogfilename}
69fi
70makefs -D -N ${BASEBITSDIR}/etc -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$MAKEFSARG" "$@"
71rm -f "$BASEBITSDIR/etc/fstab"
72if [ -n "${METALOG}" ]; then
73	rm ${metalogfilename}
74fi
75