3 # Module: mkisoimages.sh
4 # Author: Jordan K Hubbard
9 # This script is used by release/Makefile to build the (optional) ISO images
10 # for a FreeBSD release. It is considered architecture dependent since each
11 # platform has a slightly unique way of making bootable CDs. This script
12 # is also allowed to generate any number of images since that is more of
13 # publishing decision than anything else.
17 # mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir]
19 # Where -b is passed if the ISO image should be made "bootable" by
20 # whatever standards this architecture supports (may be unsupported),
21 # image-label is the ISO image label, image-name is the filename of the
22 # resulting ISO image, base-bits-dir contains the image contents and
23 # extra-bits-dir, if provided, contains additional files to be merged
24 # into base-bits-dir as part of making the image.
28 scriptdir=$(dirname $(realpath $0))
29 . ${scriptdir}/../../tools/boot/install-boot.sh
31 if [ -z $ETDUMP ]; then
35 if [ -z $MAKEFS ]; then
39 if [ -z $MKIMG ]; then
43 if [ "$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"
48 # Make EFI system partition (should be done with makefs in the future)
49 # The ISO file is a special case, in that it only has a maximum of
50 # 800 KB available for the boot code. So make an 800 KB ESP
51 espfilename=$(mktemp /tmp/efiboot.XXXXXX)
52 make_esp_file ${espfilename} 800 ${BASEBITSDIR}/boot/loader.efi
53 bootable="$bootable -o bootimage=i386;${espfilename} -o no-emul-boot -o platformid=efi"
62 echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]"
66 LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift
69 publisher="The FreeBSD Project. https://www.FreeBSD.org/"
70 echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab"
71 $MAKEFS -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@"
72 rm -f "$BASEBITSDIR/etc/fstab"
75 if [ "$bootable" != "" ]; then
76 # Look for the EFI System Partition image we dropped in the ISO image.
77 for entry in `$ETDUMP --format shell $NAME`; do
79 if [ "$et_platform" = "efi" ]; then
80 espstart=`expr $et_lba \* 2048`
81 espsize=`expr $et_sectors \* 512`
82 espparam="-p efi::$espsize:$espstart"
87 # Create a GPT image containing the partitions we need for hybrid boot.
88 imgsize=`stat -f %z "$NAME"`
91 -b "$BASEBITSDIR/boot/pmbr" \
93 -p freebsd-boot:="$BASEBITSDIR/boot/isoboot" \
96 # Drop the PMBR, GPT, and boot code into the System Area of the ISO.
97 dd if=hybrid.img of="$NAME" bs=32k count=1 conv=notrunc