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 echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]" > /dev/stderr
33 -b) BOPT="$1"; shift ;;
35 LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift
40 publisher="The FreeBSD Project. https://www.FreeBSD.org/"
41 echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab"
42 makefs -t cd9660 -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME.tmp" "$@"
43 rm -f "$BASEBITSDIR/etc/fstab"
45 if [ "$BOPT" != "-b" ]; then
46 mv "$NAME.tmp" "$NAME"
50 TMPIMGDIR=`mktemp -d /tmp/bootfs.XXXXXXXX` || exit 1
51 BOOTFSDIR="$TMPIMGDIR/bootfs"
52 BOOTFSIMG="$TMPIMGDIR/bootfs.img"
54 # Create a boot filesystem
55 mkdir -p "$BOOTFSDIR/boot"
56 cp -p "$BASEBITSDIR/boot/loader" "$BOOTFSDIR/boot"
57 makefs -t ffs -B be -M 512k "$BOOTFSIMG" "$BOOTFSDIR"
58 dd if="$BASEBITSDIR/boot/boot1" of="$BOOTFSIMG" bs=512 conv=notrunc,sync
60 # Create a boot ISO image
62 ISOSIZE=$(stat -f %z "$NAME.tmp")
63 ISOBLKS=$((($ISOSIZE + 511) / 512))
64 ISOCYLS=$((($ISOBLKS + ($CYLSIZE - 1)) / $CYLSIZE))
66 BOOTFSSIZE=$(stat -f %z "$BOOTFSIMG")
67 BOOTFSBLKS=$((($BOOTFSSIZE + 511) / 512))
68 BOOTFSCYLS=$((($BOOTFSBLKS + ($CYLSIZE - 1)) / $CYLSIZE))
70 ENDCYL=$(($ISOCYLS + $BOOTFSCYLS))
71 NSECTS=$(($ENDCYL * 1 * $CYLSIZE))
73 dd if="$NAME.tmp" of="$NAME" bs="${CYLSIZE}b" conv=notrunc,sync
74 dd if="$BOOTFSIMG" of="$NAME" bs="${CYLSIZE}b" seek=$ISOCYLS conv=notrunc,sync
75 # The number of alternative cylinders is always 2.
76 dd if=/dev/zero of="$NAME" bs="${CYLSIZE}b" seek=$ENDCYL count=2 conv=notrunc,sync
77 rm -rf "$NAME.tmp" "$TMPIMGDIR"
79 # Write VTOC8 label to boot ISO image
80 MD=`mdconfig -a -t vnode -S 512 -y 1 -x "$CYLSIZE" -f "$NAME"`
81 gpart create -s VTOC8 $MD
82 # !4: usr, for ISO image part
83 gpart add -i 1 -s "$(($ISOCYLS * $CYLSIZE * 512))b" -t \!4 $MD
84 # !2: root, for bootfs part.
85 gpart add -i 6 -s "$(($BOOTFSCYLS * $CYLSIZE * 512))b" -t \!2 $MD
86 mdconfig -d -u ${MD#md}