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 26251812Shrs echo Usage: $0 '[-b] image-label image-name base-bits-dir [extra-bits-dir]' > /dev/stderr 27105060Sjake exit 1 28105060Sjakefi 29105060Sjake 30251812Shrscase $1 in 31251812Shrs-b) BOPT=$1; shift ;; 32251812Shrsesac 33251812ShrsLABEL=`echo $1 | tr '[:lower:]' '[:upper:]'`; shift 34105060SjakeNAME=$1; shift 35253799SmariusBASEBITSDIR=$1 36105060Sjake 37251812Shrs# Create an ISO image 38251812Shrspublisher="The FreeBSD Project. http://www.FreeBSD.org/" 39253799Smariusecho "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "${BASEBITSDIR}/etc/fstab" 40253799Smariusmakefs -t cd9660 -o rockridge -o label="$LABEL" -o publisher="$publisher" ${NAME}.tmp $* 41253799Smariusrm "${BASEBITSDIR}/etc/fstab" 42251812Shrs 43251812Shrsif [ "x$BOPT" != "x-b" ]; then 44251812Shrs mv ${NAME}.tmp ${NAME} 45251812Shrs exit 0 46251812Shrsfi 47253799Smarius 48251812ShrsTMPIMGDIR=`mktemp -d /tmp/bootfs.XXXXXXXX` || exit 1 49251812ShrsBOOTFSDIR="${TMPIMGDIR}/bootfs" 50251812ShrsBOOTFSIMG="${TMPIMGDIR}/bootfs.img" 51251812Shrs 52251812Shrs# Create a boot filesystem 53251812Shrsmkdir -p "${BOOTFSDIR}/boot" 54253799Smariuscp -p "${BASEBITSDIR}/boot/loader" "${BOOTFSDIR}/boot" 55251812Shrsmakefs -t ffs -B be -M 512k "${BOOTFSIMG}" "${BOOTFSDIR}" 56253799Smariusdd if="${BASEBITSDIR}/boot/boot1" of="${BOOTFSIMG}" bs=512 conv=notrunc,sync 57251812Shrs 58251812Shrs# Create a boot ISO image 59251812Shrs: ${CYLSIZE:=640} 60251812ShrsISOSIZE=$(stat -f %z ${NAME}.tmp) 61251812ShrsISOBLKS=$(((${ISOSIZE} + 511) / 512)) 62251812ShrsISOCYLS=$(((${ISOBLKS} + (${CYLSIZE} - 1)) / ${CYLSIZE})) 63251812Shrs 64251812ShrsBOOTFSSIZE=$(stat -f %z "${BOOTFSIMG}") 65251812ShrsBOOTFSBLKS=$(((${BOOTFSSIZE} + 511) / 512)) 66251812ShrsBOOTFSCYLS=$(((${BOOTFSBLKS} + (${CYLSIZE} - 1)) / ${CYLSIZE})) 67251812Shrs 68251812ShrsENDCYL=$((${ISOCYLS} + ${BOOTFSCYLS})) 69251812ShrsNSECTS=$((${ENDCYL} * 1 * ${CYLSIZE})) 70251812Shrs 71251812Shrsdd if=${NAME}.tmp of=${NAME} bs=${CYLSIZE}b conv=notrunc,sync 72251812Shrsdd if=${BOOTFSIMG} of=${NAME} bs=${CYLSIZE}b seek=${ISOCYLS} conv=notrunc,sync 73251812Shrs# The number of alternative cylinders is always 2. 74251812Shrsdd if=/dev/zero of=${NAME} bs=${CYLSIZE}b seek=${ENDCYL} count=2 conv=notrunc,sync 75251812Shrsrm -rf ${NAME}.tmp ${TMPIMGDIR} 76251812Shrs 77251812Shrs# Write VTOC8 label to boot ISO image 78251812ShrsMD=`mdconfig -a -t vnode -S 512 -y 1 -x ${CYLSIZE} -f ${NAME}` 79251812Shrsgpart create -s VTOC8 ${MD} 80251812Shrs# !4: usr, for ISO image part 81251812Shrsgpart add -i 1 -s $((${ISOCYLS} * ${CYLSIZE} * 512))b -t \!4 ${MD} 82251812Shrs# !2: root, for bootfs part. 83251812Shrsgpart add -i 6 -s $((${BOOTFSCYLS} * ${CYLSIZE} * 512))b -t \!2 ${MD} 84251812Shrsmdconfig -d -u ${MD#md} 85