#!/bin/sh1#2# Module: mkisoimages.sh3# Author: Jordan K Hubbard4# Date: 22 June 20015#6#7# This script is used by release/Makefile to build the (optional) ISO images8# for a FreeBSD release. It is considered architecture dependent since each9# platform has a slightly unique way of making bootable CDs. This script10# is also allowed to generate any number of images since that is more of11# publishing decision than anything else.12#13# Usage:14#15# mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir]16#17# Where -b is passed if the ISO image should be made "bootable" by18# whatever standards this architecture supports (may be unsupported),19# image-label is the ISO image label, image-name is the filename of the20# resulting ISO image, base-bits-dir contains the image contents and21# extra-bits-dir, if provided, contains additional files to be merged22# into base-bits-dir as part of making the image.2324set -e2526scriptdir=$(dirname $(realpath $0))27. ${scriptdir}/../scripts/tools.subr2829if [ "$1" = "-b" ]; then30MAKEFSARG="$4"31else32MAKEFSARG="$3"33fi3435if [ -f ${MAKEFSARG} ]; then36BASEBITSDIR=`dirname ${MAKEFSARG}`37METALOG=${MAKEFSARG}38elif [ -d ${MAKEFSARG} ]; then39BASEBITSDIR=${MAKEFSARG}40METALOG=41else42echo "${MAKEFSARG} must exist"43exit 144fi4546if [ "$1" = "-b" ]; then47# This is highly x86-centric and will be used directly below.48bootable="-o bootimage=i386;$BASEBITSDIR/boot/cdboot -o no-emul-boot"49shift50else51bootable=""52fi5354if [ $# -lt 3 ]; then55echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]"56exit 157fi5859LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift60NAME="$1"; shift61# MAKEFSARG extracted already62shift6364publisher="The FreeBSD Project. https://www.FreeBSD.org/"65echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab"66if [ -n "${METALOG}" ]; then67metalogfilename=$(mktemp /tmp/metalog.XXXXXX)68cat ${METALOG} > ${metalogfilename}69echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename}70MAKEFSARG=${metalogfilename}71fi72${MAKEFS} -D -N ${BASEBITSDIR}/etc -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$MAKEFSARG" "$@"73rm -f "$BASEBITSDIR/etc/fstab"74if [ -n "${METALOG}" ]; then75rm ${metalogfilename}76fi777879