xref: /freebsd/release/i386/mkisoimages.sh (revision 4757b351ea9d59d71d4a38b82506d2d16fcd560d)
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
27scriptdir=$(dirname $(realpath $0))
28. ${scriptdir}/../scripts/tools.subr
29
30if [ "$1" = "-b" ]; then
31	MAKEFSARG="$4"
32else
33	MAKEFSARG="$3"
34fi
35
36if [ -f ${MAKEFSARG} ]; then
37	BASEBITSDIR=`dirname ${MAKEFSARG}`
38	METALOG=${MAKEFSARG}
39elif [ -d ${MAKEFSARG} ]; then
40	BASEBITSDIR=${MAKEFSARG}
41	METALOG=
42else
43	echo "${MAKEFSARG} must exist"
44	exit 1
45fi
46
47if [ "$1" = "-b" ]; then
48	# This is highly x86-centric and will be used directly below.
49	bootable="-o bootimage=i386;$BASEBITSDIR/boot/cdboot -o no-emul-boot"
50	shift
51else
52	bootable=""
53fi
54
55if [ $# -lt 3 ]; then
56	echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]"
57	exit 1
58fi
59
60LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift
61NAME="$1"; shift
62# MAKEFSARG extracted already
63shift
64
65publisher="The FreeBSD Project.  https://www.FreeBSD.org/"
66echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab"
67if [ -n "${METALOG}" ]; then
68	metalogfilename=$(mktemp /tmp/metalog.XXXXXX)
69	cat ${METALOG} > ${metalogfilename}
70	echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename}
71	MAKEFSARG=${metalogfilename}
72fi
73${MAKEFS} -D -N ${BASEBITSDIR}/etc -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$MAKEFSARG" "$@"
74rm -f "$BASEBITSDIR/etc/fstab"
75if [ -n "${METALOG}" ]; then
76	rm ${metalogfilename}
77fi
78