mkisoimages.sh revision 246283
1#!/bin/sh 2# 3# Module: mkisoimages.sh 4# Author: Jordan K Hubbard 5# Date: 22 June 2001 6# 7# $FreeBSD: head/release/sparc64/mkisoimages.sh 246283 2013-02-03 10:26:24Z hrs $ 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. 25if [ $# -lt 3 ]; then 26 echo Usage: $0 '[-b] image-label image-name base-bits-dir [extra-bits-dir]' > /dev/stderr 27 exit 1 28fi 29 30case $1 in 31-b) BOPT=$1; shift ;; 32esac 33LABEL=`echo $1 | tr '[:lower:]' '[:upper:]'`; shift 34NAME=$1; shift 35 36# Create an ISO image 37publisher="The FreeBSD Project. http://www.FreeBSD.org/" 38echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab 39makefs -t cd9660 -B be -o rockridge -o label="$LABEL" -o publisher="$publisher" ${NAME}.tmp $* 40rm $1/etc/fstab 41 42if [ "x$BOPT" != "x-b" ]; then 43 mv ${NAME}.tmp ${NAME} 44 exit 0 45fi 46TMPIMGDIR=`mktemp -d /tmp/bootfs.XXXXXXXX` || exit 1 47BOOTFSDIR="${TMPIMGDIR}/bootfs" 48BOOTFSIMG="${TMPIMGDIR}/bootfs.img" 49 50# Create a boot filesystem 51mkdir -p "${BOOTFSDIR}/boot" 52cp $4/boot/loader "${BOOTFSDIR}/boot" 53makefs -t ffs -B be -M 512k "${BOOTFSIMG}" "${BOOTFSDIR}" 54dd if=$4/boot/boot1 of="${BOOTFSIMG}" bs=512 conv=notrunc,sync 55 56# Create a boot ISO image 57: ${CYLSIZE:=640} 58ISOSIZE=$(stat -f %z ${NAME}.tmp) 59ISOBLKS=$(((${ISOSIZE} + 511) / 512)) 60ISOCYLS=$(((${ISOBLKS} + (${CYLSIZE} - 1)) / ${CYLSIZE})) 61 62BOOTFSSIZE=$(stat -f %z "${BOOTFSIMG}") 63BOOTFSBLKS=$(((${BOOTFSSIZE} + 511) / 512)) 64BOOTFSCYLS=$(((${BOOTFSBLKS} + (${CYLSIZE} - 1)) / ${CYLSIZE})) 65 66ENDCYL=$((${ISOCYLS} + ${BOOTFSCYLS})) 67NSECTS=$((${ENDCYL} * 1 * ${CYLSIZE})) 68 69dd if=${NAME}.tmp of=${NAME} bs=${CYLSIZE}b conv=notrunc,sync 70dd if=${BOOTFSIMG} of=${NAME} bs=${CYLSIZE}b seek=${ISOCYLS} conv=notrunc,sync 71# The number of alternative cylinders is always 2. 72dd if=/dev/zero of=${NAME} bs=${CYLSIZE}b seek=${ENDCYL} count=2 conv=notrunc,sync 73rm -rf ${NAME}.tmp ${TMPIMGDIR} 74 75# Write VTOC8 label to boot ISO image 76MD=`mdconfig -a -t vnode -S 512 -y 1 -x ${CYLSIZE} -f ${NAME}` 77gpart create -s VTOC8 ${MD} 78# !4: usr, for ISO image part 79gpart add -i 1 -s $((${ISOCYLS} * ${CYLSIZE} * 512))b -t \!4 ${MD} 80# !2: root, for bootfs part. 81gpart add -i 6 -s $((${BOOTFSCYLS} * ${CYLSIZE} * 512))b -t \!2 ${MD} 82mdconfig -d -u ${MD#md} 83