180183Sjkh#!/bin/sh 280183Sjkh# 380183Sjkh# Module: mkisoimages.sh 480183Sjkh# Author: Jordan K Hubbard 580183Sjkh# Date: 22 June 2001 680183Sjkh# 780183Sjkh# $FreeBSD: stable/11/release/amd64/mkisoimages.sh 333006 2018-04-25 18:53:02Z benno $ 880183Sjkh# 980183Sjkh# This script is used by release/Makefile to build the (optional) ISO images 1080183Sjkh# for a FreeBSD release. It is considered architecture dependent since each 1180183Sjkh# platform has a slightly unique way of making bootable CDs. This script 1280183Sjkh# is also allowed to generate any number of images since that is more of 1380183Sjkh# publishing decision than anything else. 1480183Sjkh# 1580183Sjkh# Usage: 1680183Sjkh# 1780183Sjkh# mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir] 1880183Sjkh# 1980183Sjkh# Where -b is passed if the ISO image should be made "bootable" by 2080183Sjkh# whatever standards this architecture supports (may be unsupported), 2180183Sjkh# image-label is the ISO image label, image-name is the filename of the 2280183Sjkh# resulting ISO image, base-bits-dir contains the image contents and 2380183Sjkh# extra-bits-dir, if provided, contains additional files to be merged 2480183Sjkh# into base-bits-dir as part of making the image. 2580183Sjkh 26333006Sbennoif [ -z $ETDUMP ]; then 27333006Sbenno ETDUMP=etdump 28333006Sbennofi 29333006Sbenno 30333006Sbennoif [ -z $MAKEFS ]; then 31333006Sbenno MAKEFS=makefs 32333006Sbennofi 33333006Sbenno 34333006Sbennoif [ -z $MKIMG ]; then 35333006Sbenno MKIMG=mkimg 36333006Sbennofi 37333006Sbenno 3880183Sjkhif [ "x$1" = "x-b" ]; then 3980183Sjkh # This is highly x86-centric and will be used directly below. 40221466Snwhitehorn bootable="-o bootimage=i386;$4/boot/cdboot -o no-emul-boot" 41264995Snwhitehorn 42264995Snwhitehorn # Make EFI system partition (should be done with makefs in the future) 43293831Ssmh dd if=/dev/zero of=efiboot.img bs=4k count=200 44264995Snwhitehorn device=`mdconfig -a -t vnode -f efiboot.img` 45264995Snwhitehorn newfs_msdos -F 12 -m 0xf8 /dev/$device 46264995Snwhitehorn mkdir efi 47264995Snwhitehorn mount -t msdosfs /dev/$device efi 48264995Snwhitehorn mkdir -p efi/efi/boot 49287635Sdteske cp "$4/boot/loader.efi" efi/efi/boot/bootx64.efi 50264995Snwhitehorn umount efi 51264995Snwhitehorn rmdir efi 52264995Snwhitehorn mdconfig -d -u $device 53333006Sbenno bootable="$bootable -o bootimage=i386;efiboot.img -o no-emul-boot -o platformid=efi" 54264995Snwhitehorn 5580183Sjkh shift 5680183Sjkhelse 5780183Sjkh bootable="" 5880183Sjkhfi 5980183Sjkh 6080183Sjkhif [ $# -lt 3 ]; then 61287635Sdteske echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]" 6280183Sjkh exit 1 6380183Sjkhfi 6480183Sjkh 65287635SdteskeLABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift 66287635SdteskeNAME="$1"; shift 6780183Sjkh 68246283Shrspublisher="The FreeBSD Project. http://www.FreeBSD.org/" 69287635Sdteskeecho "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$1/etc/fstab" 70333006Sbenno$MAKEFS -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" 71293223Sgjbrm -f "$1/etc/fstab" 72264995Snwhitehornrm -f efiboot.img 73333006Sbenno 74333006Sbennoif [ "$bootable" != "" ]; then 75333006Sbenno # Look for the EFI System Partition image we dropped in the ISO image. 76333006Sbenno for entry in `$ETDUMP --format shell $NAME`; do 77333006Sbenno eval $entry 78333006Sbenno if [ "$et_platform" = "efi" ]; then 79333006Sbenno espstart=`expr $et_lba \* 2048` 80333006Sbenno espsize=`expr $et_sectors \* 512` 81333006Sbenno espparam="-p efi::$espsize:$espstart" 82333006Sbenno break 83333006Sbenno fi 84333006Sbenno done 85333006Sbenno 86333006Sbenno # Create a GPT image containing the partitions we need for hybrid boot. 87333006Sbenno imgsize=`stat -f %z $NAME` 88333006Sbenno $MKIMG -s gpt \ 89333006Sbenno --capacity $imgsize \ 90333006Sbenno -b $4/boot/pmbr \ 91333006Sbenno $espparam \ 92333006Sbenno -p freebsd-boot:=$4/boot/isoboot \ 93333006Sbenno -o hybrid.img 94333006Sbenno 95333006Sbenno # Drop the PMBR, GPT, and boot code into the System Area of the ISO. 96333006Sbenno dd if=hybrid.img of=$NAME bs=32k count=1 conv=notrunc 97333006Sbenno rm -f hybrid.img 98333006Sbennofi 99