]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - release/ia64/mkisoimages.sh
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / release / ia64 / mkisoimages.sh
1 #!/bin/sh
2 #
3 # Module: mkisoimages.sh
4 # Author: Jordan K Hubbard
5 # Date:   22 June 2001
6 #
7 # $FreeBSD$
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
26 set -e
27
28 if [ "x$1" = "x-b" ]; then
29     bootable=yes
30     shift
31 else
32     bootable=no
33 fi
34
35 if [ $# -lt 3 ]; then
36     echo usage: $0 '[-b] label iso-name base-dir [extra-dir]'
37     exit 1
38 fi
39
40 LABEL=$1; shift
41 NAME=$1; shift
42 BASE=$1; shift
43
44 MKISOFS=mkisofs
45 MKISOFS_PKG=cdrtools
46 MKISOFS_PORT=/usr/ports/sysutils/${MKISOFS_PKG}
47
48 if ! 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
63 fi
64
65 EFIPART=efipart.sys
66
67 # To create a bootable CD under EFI, the boot image should be an EFI
68 # system partition.
69 if [ $bootable = yes ]; then
70     EFISZ=65536
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/kernel/ispfw.ko $MNT/boot/kernel
80     cp $BASE/boot/device.hints $MNT/boot
81     cp $BASE/boot/loader.* $MNT/boot
82     cp $BASE/boot/mfsroot.gz $MNT/boot
83     cp $BASE/boot/support.4th $MNT/boot
84     mv $MNT/boot/loader.efi $MNT/efi/boot/bootia64.efi
85     umount $MNT
86     mdconfig -d -u $md
87     BOOTOPTS="-b $EFIPART -no-emul-boot"
88 else
89     BOOTOPTS=""
90 fi
91
92 publisher="The FreeBSD Project.  http://www.freebsd.org/"
93
94 $MKISOFS $BOOTOPTS -r -J -V $LABEL -publisher "$publisher" -o $NAME $BASE $*
95 rm -f $BASE/$EFIPART
96 exit 0