mkisoimages.sh revision 253676
1168404Spjd#!/bin/sh 2168404Spjd# 3168404Spjd# Module: mkisoimages.sh 4168404Spjd# Author: Jordan K Hubbard 5168404Spjd# Date: 22 June 2001 6168404Spjd# 7168404Spjd# $FreeBSD: head/release/sparc64/mkisoimages.sh 253676 2013-07-26 14:23:25Z marius $ 8168404Spjd# 9168404Spjd# This script is used by release/Makefile to build the (optional) ISO images 10168404Spjd# for a FreeBSD release. It is considered architecture dependent since each 11168404Spjd# platform has a slightly unique way of making bootable CDs. This script 12168404Spjd# is also allowed to generate any number of images since that is more of 13168404Spjd# publishing decision than anything else. 14168404Spjd# 15168404Spjd# Usage: 16168404Spjd# 17168404Spjd# mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir] 18168404Spjd# 19168404Spjd# Where -b is passed if the ISO image should be made "bootable" by 20168404Spjd# whatever standards this architecture supports (may be unsupported), 21168404Spjd# image-label is the ISO image label, image-name is the filename of the 22185029Spjd# resulting ISO image, base-bits-dir contains the image contents and 23168404Spjd# extra-bits-dir, if provided, contains additional files to be merged 24168404Spjd# into base-bits-dir as part of making the image. 25168404Spjdif [ $# -lt 3 ]; then 26168404Spjd echo Usage: $0 '[-b] image-label image-name base-bits-dir [extra-bits-dir]' > /dev/stderr 27168404Spjd exit 1 28168404Spjdfi 29168404Spjd 30168404Spjdcase $1 in 31168404Spjd-b) BOPT=$1; shift ;; 32168404Spjdesac 33168404SpjdLABEL=`echo $1 | tr '[:lower:]' '[:upper:]'`; shift 34168404SpjdNAME=$1; shift 35168404SpjdBASEBITSDIR=$1 36168404Spjd 37168404Spjd# Create an ISO image 38168404Spjdpublisher="The FreeBSD Project. http://www.FreeBSD.org/" 39168404Spjdecho "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "${BASEBITSDIR}/etc/fstab" 40168404Spjdmakefs -t cd9660 -o rockridge -o label="$LABEL" -o publisher="$publisher" ${NAME}.tmp $* 41185029Spjdrm "${BASEBITSDIR}/etc/fstab" 42185029Spjd 43185029Spjdif [ "x$BOPT" != "x-b" ]; then 44185029Spjd mv ${NAME}.tmp ${NAME} 45185029Spjd exit 0 46185029Spjdfi 47168404Spjd 48168404SpjdTMPIMGDIR=`mktemp -d /tmp/bootfs.XXXXXXXX` || exit 1 49168404SpjdBOOTFSDIR="${TMPIMGDIR}/bootfs" 50168404SpjdBOOTFSIMG="${TMPIMGDIR}/bootfs.img" 51168404Spjd 52168404Spjd# Create a boot filesystem 53168404Spjdmkdir -p "${BOOTFSDIR}/boot" 54168404Spjdcp -p "${BASEBITSDIR}/boot/loader" "${BOOTFSDIR}/boot" 55makefs -t ffs -B be -M 512k "${BOOTFSIMG}" "${BOOTFSDIR}" 56dd if="${BASEBITSDIR}/boot/boot1" of="${BOOTFSIMG}" bs=512 conv=notrunc,sync 57 58# Create a boot ISO image 59: ${CYLSIZE:=640} 60ISOSIZE=$(stat -f %z ${NAME}.tmp) 61ISOBLKS=$(((${ISOSIZE} + 511) / 512)) 62ISOCYLS=$(((${ISOBLKS} + (${CYLSIZE} - 1)) / ${CYLSIZE})) 63 64BOOTFSSIZE=$(stat -f %z "${BOOTFSIMG}") 65BOOTFSBLKS=$(((${BOOTFSSIZE} + 511) / 512)) 66BOOTFSCYLS=$(((${BOOTFSBLKS} + (${CYLSIZE} - 1)) / ${CYLSIZE})) 67 68ENDCYL=$((${ISOCYLS} + ${BOOTFSCYLS})) 69NSECTS=$((${ENDCYL} * 1 * ${CYLSIZE})) 70 71dd if=${NAME}.tmp of=${NAME} bs=${CYLSIZE}b conv=notrunc,sync 72dd if=${BOOTFSIMG} of=${NAME} bs=${CYLSIZE}b seek=${ISOCYLS} conv=notrunc,sync 73# The number of alternative cylinders is always 2. 74dd if=/dev/zero of=${NAME} bs=${CYLSIZE}b seek=${ENDCYL} count=2 conv=notrunc,sync 75rm -rf ${NAME}.tmp ${TMPIMGDIR} 76 77# Write VTOC8 label to boot ISO image 78MD=`mdconfig -a -t vnode -S 512 -y 1 -x ${CYLSIZE} -f ${NAME}` 79gpart create -s VTOC8 ${MD} 80# !4: usr, for ISO image part 81gpart add -i 1 -s $((${ISOCYLS} * ${CYLSIZE} * 512))b -t \!4 ${MD} 82# !2: root, for bootfs part. 83gpart add -i 6 -s $((${BOOTFSCYLS} * ${CYLSIZE} * 512))b -t \!2 ${MD} 84mdconfig -d -u ${MD#md} 85