mkisoimages.sh revision 221497
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 221497 2011-05-05 14:16:40Z nwhitehorn $
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
44EFIPART=efipart.sys
45
46# To create a bootable CD under EFI, the boot image should be an EFI
47# system partition.
48if [ $bootable = yes ]; then
49    EFISZ=65536
50    MNT=/mnt
51    dd if=/dev/zero of=$BASE/$EFIPART count=$EFISZ
52    md=`mdconfig -a -t vnode -f $BASE/$EFIPART`
53    newfs_msdos -F 12 -S 512 -h 4 -o 0 -s $EFISZ -u 16 $md
54    mount -t msdosfs /dev/$md $MNT
55    mkdir -p $MNT/efi/boot $MNT/boot $MNT/boot/kernel
56    cp -R $BASE/boot/defaults $MNT/boot
57    cp $BASE/boot/kernel/kernel $MNT/boot/kernel
58    cp $BASE/boot/kernel/ispfw.ko $MNT/boot/kernel
59    cp $BASE/boot/device.hints $MNT/boot
60    cp $BASE/boot/loader.* $MNT/boot
61    cp $BASE/boot/mfsroot.gz $MNT/boot
62    cp $BASE/boot/support.4th $MNT/boot
63    mv $MNT/boot/loader.efi $MNT/efi/boot/bootia64.efi
64    umount $MNT
65    mdconfig -d -u $md
66    BOOTOPTS="-b bootimage=i386;$EFIPART -o no-emul-boot"
67else
68    BOOTOPTS=""
69fi
70
71echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab
72makefs -t cd9660 $BOOTOPTS -o rockridge -o label=$LABEL $NAME $BASE $*
73rm -f $BASE/$EFIPART
74rm $1/etc/fstab
75exit 0
76