1105060Sjake#!/bin/sh 2105060Sjake# 3105060Sjake# Module: mkisoimages.sh 4105060Sjake# Author: Jordan K Hubbard 5105060Sjake# Date: 22 June 2001 6105060Sjake# 7105060Sjake# $FreeBSD$ 8105060Sjake# 9105060Sjake# This script is used by release/Makefile to build the (optional) ISO images 10105060Sjake# for a FreeBSD release. It is considered architecture dependent since each 11105060Sjake# platform has a slightly unique way of making bootable CDs. This script 12105060Sjake# is also allowed to generate any number of images since that is more of 13105060Sjake# publishing decision than anything else. 14105060Sjake# 15105060Sjake# Usage: 16105060Sjake# 17105060Sjake# mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir] 18105060Sjake# 19105060Sjake# Where -b is passed if the ISO image should be made "bootable" by 20105060Sjake# whatever standards this architecture supports (may be unsupported), 21105060Sjake# image-label is the ISO image label, image-name is the filename of the 22105060Sjake# resulting ISO image, base-bits-dir contains the image contents and 23105060Sjake# extra-bits-dir, if provided, contains additional files to be merged 24105060Sjake# into base-bits-dir as part of making the image. 25105060Sjakeif [ $# -lt 3 ]; then 26290283Sdteske echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]" > /dev/stderr 27105060Sjake exit 1 28105060Sjakefi 29105060Sjake 30290283Sdteskecase "$1" in 31290283Sdteske-b) BOPT="$1"; shift ;; 32246283Shrsesac 33290283SdteskeLABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift 34290283SdteskeNAME="$1"; shift 35290283SdteskeBASEBITSDIR="$1" 36105060Sjake 37246283Shrs# Create an ISO image 38246283Shrspublisher="The FreeBSD Project. http://www.FreeBSD.org/" 39290283Sdteskeecho "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab" 40290283Sdteskemakefs -t cd9660 -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME.tmp" "$@" 41290283Sdteskerm "$BASEBITSDIR/etc/fstab" 42246283Shrs 43246283Shrsif [ "x$BOPT" != "x-b" ]; then 44290283Sdteske mv "$NAME.tmp" "$NAME" 45246283Shrs exit 0 46246283Shrsfi 47253676Smarius 48246283ShrsTMPIMGDIR=`mktemp -d /tmp/bootfs.XXXXXXXX` || exit 1 49290283SdteskeBOOTFSDIR="$TMPIMGDIR/bootfs" 50290283SdteskeBOOTFSIMG="$TMPIMGDIR/bootfs.img" 51246283Shrs 52246283Shrs# Create a boot filesystem 53290283Sdteskemkdir -p "$BOOTFSDIR/boot" 54290283Sdteskecp -p "$BASEBITSDIR/boot/loader" "$BOOTFSDIR/boot" 55290283Sdteskemakefs -t ffs -B be -M 512k "$BOOTFSIMG" "$BOOTFSDIR" 56290283Sdteskedd if="$BASEBITSDIR/boot/boot1" of="$BOOTFSIMG" bs=512 conv=notrunc,sync 57246283Shrs 58246283Shrs# Create a boot ISO image 59246283Shrs: ${CYLSIZE:=640} 60290283SdteskeISOSIZE=$(stat -f %z "$NAME.tmp") 61290283SdteskeISOBLKS=$((($ISOSIZE + 511) / 512)) 62290283SdteskeISOCYLS=$((($ISOBLKS + ($CYLSIZE - 1)) / $CYLSIZE)) 63246283Shrs 64290283SdteskeBOOTFSSIZE=$(stat -f %z "$BOOTFSIMG") 65290283SdteskeBOOTFSBLKS=$((($BOOTFSSIZE + 511) / 512)) 66290283SdteskeBOOTFSCYLS=$((($BOOTFSBLKS + ($CYLSIZE - 1)) / $CYLSIZE)) 67246283Shrs 68290283SdteskeENDCYL=$(($ISOCYLS + $BOOTFSCYLS)) 69290283SdteskeNSECTS=$(($ENDCYL * 1 * $CYLSIZE)) 70246283Shrs 71290283Sdteskedd if="$NAME.tmp" of="$NAME" bs="${CYLSIZE}b" conv=notrunc,sync 72290283Sdteskedd if="$BOOTFSIMG" of="$NAME" bs="${CYLSIZE}b" seek=$ISOCYLS conv=notrunc,sync 73246283Shrs# The number of alternative cylinders is always 2. 74290283Sdteskedd if=/dev/zero of="$NAME" bs="${CYLSIZE}b" seek=$ENDCYL count=2 conv=notrunc,sync 75290283Sdteskerm -rf "$NAME.tmp" "$TMPIMGDIR" 76246283Shrs 77246283Shrs# Write VTOC8 label to boot ISO image 78290283SdteskeMD=`mdconfig -a -t vnode -S 512 -y 1 -x "$CYLSIZE" -f "$NAME"` 79290283Sdteskegpart create -s VTOC8 $MD 80246283Shrs# !4: usr, for ISO image part 81290283Sdteskegpart add -i 1 -s "$(($ISOCYLS * $CYLSIZE * 512))b" -t \!4 $MD 82246283Shrs# !2: root, for bootfs part. 83290283Sdteskegpart add -i 6 -s "$(($BOOTFSCYLS * $CYLSIZE * 512))b" -t \!2 $MD 84246283Shrsmdconfig -d -u ${MD#md} 85