4 # This script is used by release/Makefile to build the (optional) ISO images
5 # for a FreeBSD release. It is considered architecture dependent since each
6 # platform has a slightly unique way of making bootable CDs. This script is
7 # also allowed to generate any number of images since that is more of
8 # publishing decision than anything else.
12 # mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir]
14 # Where -b is passed if the ISO image should be made "bootable" by
15 # whatever standards this architecture supports (may be unsupported),
16 # image-label is the ISO image label, image-name is the filename of the
17 # resulting ISO image, base-bits-dir contains the image contents and
18 # extra-bits-dir, if provided, contains additional files to be merged
19 # into base-bits-dir as part of making the image.
23 scriptdir=$(dirname $(realpath $0))
24 . ${scriptdir}/../../tools/boot/install-boot.sh
26 if [ -z $ETDUMP ]; then
30 if [ -z $MAKEFS ]; then
34 if [ -z $MKIMG ]; then
38 if [ "$1" = "-b" ]; then
44 if [ -f ${MAKEFSARG} ]; then
45 BASEBITSDIR=`dirname ${MAKEFSARG}`
47 elif [ -d ${MAKEFSARG} ]; then
48 BASEBITSDIR=${MAKEFSARG}
51 echo "${MAKEFSARG} must exist"
55 if [ "$1" = "-b" ]; then
56 # Make an EFI system partition.
57 espfilename=$(mktemp /tmp/efiboot.XXXXXX)
58 # ESP file size in KB.
60 make_esp_file ${espfilename} ${espsize} ${BASEBITSDIR}/boot/loader.efi
62 bootable="-o bootimage=efi;${espfilename} -o no-emul-boot -o platformid=efi"
70 echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]"
74 LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift
76 # MAKEFSARG extracted already
79 publisher="The FreeBSD Project. https://www.FreeBSD.org/"
80 echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab"
81 if [ -n "${METALOG}" ]; then
82 metalogfilename=$(mktemp /tmp/metalog.XXXXXX)
83 cat ${METALOG} > ${metalogfilename}
84 echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename}
85 MAKEFSARG=${metalogfilename}
87 $MAKEFS -D -N ${BASEBITSDIR}/etc -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$MAKEFSARG" "$@"
88 rm -f "$BASEBITSDIR/etc/fstab"
90 if [ -n "${METALOG}" ]; then
94 if [ "$bootable" != "" ]; then
95 # Look for the EFI System Partition image we dropped in the ISO image.
96 for entry in `$ETDUMP --format shell $NAME`; do
98 # XXX: etdump(8) returns "default" for the initial entry
99 if [ "$et_platform" = "default" ]; then
100 espstart=`expr $et_lba \* 2048`
101 espsize=`expr $et_sectors \* 512`
102 espparam="-p efi::$espsize:$espstart"
107 # Create a GPT image containing the EFI partition.
108 efifilename=$(mktemp /tmp/efi.img.XXXXXX)
109 if [ "$(uname -s)" = "Linux" ]; then
110 imgsize=`stat -c %s "$NAME"`
112 imgsize=`stat -f %z "$NAME"`
115 --capacity $imgsize \
119 # Drop the GPT into the System Area of the ISO.
120 dd if=$efifilename of="$NAME" bs=32k count=1 conv=notrunc