mkisoimages.sh revision 133426
1#!/bin/sh 2# 3# Module: mkisoimages.sh 4# Author: Jordan K Hubbard 5# Date: 22 June 2001 6# 7# $FreeBSD: head/release/ia64/mkisoimages.sh 133426 2004-08-10 05:43:40Z marcel $ 8# 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. 14# 15# Usage: 16# 17# mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir] 18# 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. 25 26set -e 27 28if [ "x$1" = "x-b" ]; then 29 bootable=yes 30 shift 31else 32 bootable=no 33fi 34 35if [ $# -lt 3 ]; then 36 echo usage: $0 '[-b] label iso-name base-dir [extra-dir]' 37 exit 1 38fi 39 40LABEL=$1; shift 41NAME=$1; shift 42BASE=$1; shift 43 44MKISOFS=mkisofs 45MKISOFS_PKG=cdrtools 46MKISOFS_PORT=/usr/ports/sysutils/${MKISOFS_PKG} 47 48if ! which ${MKISOFS} > /dev/null; then 49 echo -n "${MKISOFS}(8) does not exist: " 50 if [ -f ${MKISOFS_PORT}/Makefile ]; then 51 echo building the port... 52 if ! (cd ${MKISOFS_PORT} && make install BATCH=yes && make clean); then 53 echo "error: cannot build ${MKISOFS}(8). Bailing out..." 54 exit 2 55 fi 56 else 57 echo fetching the package... 58 if ! pkg_add -r ${MKISOFS_PKG}; then 59 echo "error: cannot fetch ${MKISOFS}(8). Bailing out..." 60 exit 2 61 fi 62 fi 63fi 64 65EFIPART=efipart.sys 66 67# To create a bootable CD under EFI, the boot image should be an EFI 68# system partition. 69if [ $bootable = yes ]; then 70 EFISZ=32768 71 MNT=/mnt 72 dd if=/dev/zero of=$BASE/$EFIPART count=$EFISZ 73 md=`mdconfig -a -t vnode -f $BASE/$EFIPART` 74 newfs_msdos -F 12 -S 512 -h 4 -o 0 -s $EFISZ -u 16 $md 75 mount -t msdosfs /dev/$md $MNT 76 mkdir -p $MNT/efi/boot $MNT/boot $MNT/boot/kernel 77 cp -R $BASE/boot/defaults $MNT/boot 78 cp $BASE/boot/kernel/kernel $MNT/boot/kernel 79 cp $BASE/boot/device.hints $MNT/boot 80 cp $BASE/boot/loader.* $MNT/boot 81 cp $BASE/boot/mfsroot.gz $MNT/boot 82 cp $BASE/boot/support.4th $MNT/boot 83 mv $MNT/boot/loader.efi $MNT/efi/boot/bootia64.efi 84 umount $MNT 85 mdconfig -d -u $md 86 BOOTOPTS="-b $EFIPART -no-emul-boot" 87else 88 BOOTOPTS="" 89fi 90 91publisher="The FreeBSD Project. http://www.freebsd.org/" 92 93$MKISOFS $BOOTOPTS -r -J -V $LABEL -P "$publisher" -o $NAME $BASE $* 94rm -f $BASE/$EFIPART 95exit 0 96