svn commit: r251812 - in stable/9/release: . amd64 i386 ia64 pc98 powerpc sparc64

Hiroki Sato hrs at FreeBSD.org
Sun Jun 16 18:27:55 UTC 2013


Author: hrs
Date: Sun Jun 16 18:27:53 2013
New Revision: 251812
URL: http://svnweb.freebsd.org/changeset/base/251812

Log:
  MFC r245177,r245346,r246283,r251650:
  
  - Set WITHOUT_SVN=yes for textproc/docproj.
  - Add CHECKSUM.* support in Makefile.
  - Use ln -fs to create a symlink.
  - Remove pkgadd for docports.
  - Use WITHOUT_JADETEX=yes instead of WITH_JADETEX=no.
  - Add {WORLD,KERNEL}_FLAGS to [BTWK]MAKE.
  - Use makefs(8) and gpart(8) for sparc64 ISO image.
  - Add publisher option to makefs(8).
  - Add missing copyright notice.
  - ISO 9660 specification allows only "d-characters" and "a-characters"
    in the Volume Descriptor (section 7.4).  In short, uppercase
    alphanumeric + some symbols only.  While the makefs utility automatically
    converts the characters, $LABEL should be consistent in the scripts.
  
  These fix a specification violation in 9.X iso9660 images, and cdrtools
  dependency and endianness issue for sparc64 release media.  The label is
  now in uppercase letters only in all platforms.

Modified:
  stable/9/release/Makefile
  stable/9/release/amd64/mkisoimages.sh
  stable/9/release/generate-release.sh
  stable/9/release/i386/mkisoimages.sh
  stable/9/release/ia64/mkisoimages.sh
  stable/9/release/pc98/mkisoimages.sh
  stable/9/release/powerpc/mkisoimages.sh
  stable/9/release/sparc64/mkisoimages.sh
Directory Properties:
  stable/9/release/   (props changed)

Modified: stable/9/release/Makefile
==============================================================================
--- stable/9/release/Makefile	Sun Jun 16 17:54:56 2013	(r251811)
+++ stable/9/release/Makefile	Sun Jun 16 18:27:53 2013	(r251812)
@@ -34,6 +34,20 @@ TARGET_ARCH?=	${TARGET}
 IMAKE=		${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
 DISTDIR=	dist
 
+# Define OSRELEASE by using newvars.sh
+.if !defined(OSRELEASE) || empty(OSRELEASE)
+.for _V in TYPE BRANCH REVISION
+${_V}!=	eval $$(awk '/^${_V}=/{print}' ${.CURDIR}/../sys/conf/newvers.sh); echo $$${_V}
+.endfor
+.for _V in ${TARGET_ARCH}
+.if !empty(TARGET:M${_V})
+OSRELEASE=	${TYPE}-${REVISION}-${BRANCH}-${TARGET}
+.else
+OSRELEASE=	${TYPE}-${REVISION}-${BRANCH}-${TARGET}-${TARGET_ARCH}
+.endif
+.endfor
+.endif
+
 .if !exists(${DOCDIR})
 NODOC= true
 .endif
@@ -117,7 +131,7 @@ system: packagesystem
 	cp reldoc/* release
 .endif
 # Set up installation environment
-	ln -s /tmp/bsdinstall_etc/resolv.conf release/etc/resolv.conf
+	ln -fs /tmp/bsdinstall_etc/resolv.conf release/etc/resolv.conf
 	echo sendmail_enable=\"NONE\" > release/etc/rc.conf
 	echo hostid_enable=\"NO\" >> release/etc/rc.conf
 	cp ${.CURDIR}/rc.local release/etc
@@ -142,7 +156,7 @@ bootonly: packagesystem
 	cp reldoc/* bootonly
 .endif
 # Set up installation environment
-	ln -s /tmp/bsdinstall_etc/resolv.conf bootonly/etc/resolv.conf
+	ln -fs /tmp/bsdinstall_etc/resolv.conf bootonly/etc/resolv.conf
 	echo sendmail_enable=\"NONE\" > bootonly/etc/rc.conf
 	echo hostid_enable=\"NO\" >> bootonly/etc/rc.conf
 	cp ${.CURDIR}/rc.local bootonly/etc
@@ -183,4 +197,9 @@ install:
 .if defined(DESTDIR) && !empty(DESTDIR)
 	mkdir -p ${DESTDIR}
 .endif
-	cp -a ${IMAGES} ftp ${DESTDIR}/
+	cp -a ftp ${DESTDIR}/
+.for I in ${IMAGES}
+	cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I}
+.endfor
+	cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256
+	cd ${DESTDIR} && md5 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.MD5

Modified: stable/9/release/amd64/mkisoimages.sh
==============================================================================
--- stable/9/release/amd64/mkisoimages.sh	Sun Jun 16 17:54:56 2013	(r251811)
+++ stable/9/release/amd64/mkisoimages.sh	Sun Jun 16 18:27:53 2013	(r251812)
@@ -36,9 +36,10 @@ if [ $# -lt 3 ]; then
 	exit 1
 fi
 
-LABEL=$1; shift
+LABEL=`echo $1 | tr '[:lower:]' '[:upper:]'`; shift
 NAME=$1; shift
 
-echo "/dev/iso9660/`echo $LABEL | tr '[:lower:]' '[:upper:]'` / cd9660 ro 0 0" > $1/etc/fstab
-makefs -t cd9660 $bootable -o rockridge -o label=$LABEL $NAME $*
+publisher="The FreeBSD Project.  http://www.FreeBSD.org/"
+echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab
+makefs -t cd9660 $bootable -o rockridge -o label=$LABEL -o publisher="$publisher" $NAME $*
 rm $1/etc/fstab

Modified: stable/9/release/generate-release.sh
==============================================================================
--- stable/9/release/generate-release.sh	Sun Jun 16 17:54:56 2013	(r251811)
+++ stable/9/release/generate-release.sh	Sun Jun 16 18:27:53 2013	(r251812)
@@ -1,89 +1,93 @@
 #!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
 
 # generate-release.sh: check out source trees, and build release components with
 #  totally clean, fresh trees.
 #
-#  Usage: generate-release.sh [-r revision] [-d docrevision] \
-#	[-p portsrevision] svn-branch scratch-dir
+#  Usage: generate-release.sh svn-branch[@revision] scratch-dir
 #
 # Environment variables:
-#  SVNROOT:    SVN URL to FreeBSD source repository (by default, 
-#   svn://svn.freebsd.org/base)
-#  MAKE_FLAGS: optional flags to pass to make (e.g. -j)
-#  RELSTRING:  optional base name for media images (e.g. FreeBSD-9.0-RC2-amd64)
-# 
-#  Note: Since this requires a chroot, release cross-builds will not work!
+#  SVNROOTBASE: SVN base URL to FreeBSD repository (svn://svn.freebsd.org)
+#  SVNROOTSRC:  URL to FreeBSD src tree (${SVNROOTBASE}/base)
+#  SVNROOTDOC:  URL to FreeBSD doc tree (${SVNROOTBASE}/doc)
+#  SVNROOTPORTS:URL to FreeBSD ports tree (${SVNROOTBASE}/ports)
+#  BRANCHSRC:   branch name of src (svn-branch[@revision])
+#  BRANCHDOC:   branch name of doc (head)
+#  BRANCHPORTS: branch name of ports (head)
+#  WORLD_FLAGS: optional flags to pass to buildworld (e.g. -j)
+#  KERNEL_FLAGS: optional flags to pass to buildkernel (e.g. -j)
 #
-# $FreeBSD$
-#
-
-unset B_ARCH
-unset ARCH
-unset MACHINE_ARCH
-
-HOST_ARCH=`uname -p`
 
 usage()
 {
-	echo "Usage: $0 [-a arch] [-r revision] [-d docrevision] [-p portsrevision] svn-branch scratch-dir"
+	echo "Usage: $0 svn-branch[@revision] scratch-dir" 2>&1
 	exit 1
 }
 
-arch_error ()
-{
-	echo "Architecture ${OPTARG} cannot be built on host architecture ${HOST_ARCH}"
-	exit 1
-}
-
-REVISION=
-DOCREVISION=
-PORTSREVISION=
-while getopts a:d:r:p: opt; do
-	case $opt in
-	a)
-		case "${OPTARG}" in
-			i386|amd64)
-				if [ "${HOST_ARCH}" != "amd64" ]; then
-					arch_error "${OPTARG}"
-				fi
-				;;
-			powerpc|powerpc64)
-				if [ "${HOST_ARCH}" != "powerpc64" ]; then
-					arch_error "${OPTARG}"
-				fi
-				;;
-			*)
-				arch_error "${OPTARG}"
-				;;
-		esac
-		B_ARCH="$OPTARG"
-		;;
-	d)
-		DOCREVISION="-r $OPTARG"
-		;;
-	r)
-		REVISION="-r $OPTARG"
-		;;
-	p)
-		PORTSREVISION="-r $OPTARG"
-		;;
-	\?)
-		usage
-		;;
-	esac
-done
-shift $(($OPTIND - 1))
-
-# If target architecture is not specified, use hw.machine_arch
-if [ "x${B_ARCH}" == "x" ]; then
-	B_ARCH="${HOST_ARCH}"
-fi
-ARCH_FLAGS="ARCH=${B_ARCH} TARGET_ARCH=${B_ARCH}"
-
 if [ $# -lt 2 ]; then
 	usage
 fi
 
+: ${SVNROOTBASE:=svn://svn.freebsd.org}
+: ${SVNROOTSRC:=${SVNROOTBASE}/base}
+: ${SVNROOTDOC:=${SVNROOTBASE}/doc}
+: ${SVNROOTPORTS:=${SVNROOTBASE}/ports}
+: ${SVNROOT:=${SVNROOTSRC}} # for backward compatibility
+: ${SVN_CMD:=/usr/local/bin/svn}
+BRANCHSRC=$1
+: ${BRANCHDOC:=head}
+: ${BRANCHPORTS:=head}
+: ${WORLD_FLAGS:=${MAKE_FLAGS}}
+: ${KERNEL_FLAGS:=${MAKE_FLAGS}}
+: ${CHROOTDIR:=$2}
+ 
+if [ ! -r "${CHROOTDIR}" ]; then
+	echo "${CHROOTDIR}: scratch dir not found."
+	exit 1
+fi
+
+CHROOT_CMD="/usr/sbin/chroot ${CHROOTDIR}"
+case ${TARGET} in
+"")	;;
+*)	SETENV_TARGET="TARGET=$TARGET" ;;
+esac
+case ${TARGET_ARCH} in
+"")	;;
+*)	SETENV_TARGET_ARCH="TARGET_ARCH=$TARGET_ARCH" ;;
+esac
+SETENV="env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin"
+CROSSENV="${SETENV_TARGET} ${SETENV_TARGET_ARCH}"
+WMAKE="make -C /usr/src ${WORLD_FLAGS}"
+NWMAKE="${WMAKE} __MAKE_CONF=/dev/null SRCCONF=/dev/null"
+KMAKE="make -C /usr/src ${KERNEL_FLAGS}"
+RMAKE="make -C /usr/src/release"
+
 if [ $(id -u) -ne 0 ]; then
 	echo "Needs to be run as root."
 	exit 1
@@ -91,93 +95,31 @@ fi
 
 set -e # Everything must succeed
 
-svn co ${SVNROOT:-svn://svn.freebsd.org/base}/$1 $2/usr/src
-svn co ${SVNROOT:-svn://svn.freebsd.org/doc}/head $2/usr/doc $DOCREVISION
-svn co ${SVNROOT:-svn://svn.freebsd.org/ports}/head $2/usr/ports $PORTSREVISION
-
-cd $2/usr/src
-make $MAKE_FLAGS ${ARCH_FLAGS} buildworld
-make $ARCH_FLAGS installworld distribution DESTDIR=$2
-mount -t devfs devfs $2/dev
-trap "umount $2/dev" EXIT # Clean up devfs mount on exit
-
-# Most commands below are run in chroot, so fake getosreldate(3) right now
-OSVERSION=$(grep '#define __FreeBSD_version' $2/usr/include/sys/param.h | awk '{print $3}')
-export OSVERSION
-BRANCH=$(grep '^BRANCH=' $2/usr/src/sys/conf/newvers.sh | awk -F\= '{print $2}')
-BRANCH=`echo ${BRANCH} | sed -e 's,",,g'`
-REVISION=$(grep '^REVISION=' $2/usr/src/sys/conf/newvers.sh | awk -F\= '{print $2}')
-REVISION=`echo ${REVISION} | sed -e 's,",,g'`
-OSRELEASE="${REVISION}-${BRANCH}"
-
-pkgng_install_docports ()
-{
-	# Attempt to install docproj port from pkgng package.
-	chroot ${CHROOTDIR} /bin/sh -c 'env ASSUME_ALWAYS_YES=1 /usr/sbin/pkg install -y docproj-nojadetex'
-	# Check if docproj was installed, since pkg(8) returns '0' if unable
-	# to install a package from the repository.  If it is not installed,
-	# fallback to installing using pkg_add(1).
-	chroot ${CHROOTDIR} /bin/sh -c '/usr/sbin/pkg info -q docproj-nojadetex' || \
-		pkgadd_install_docports
-}
-
-build_compat9_port ()
-{
-	chroot ${CHROOTDIR} /bin/sh -c 'make -C /usr/ports/misc/compat9x BATCH=yes install clean'
-}
-
-pkgadd_install_docports ()
-{
-	# Attempt to install docproj package with pkg_add(1).
-	# If not successful, build the docproj port.
-	if [ "${REVISION}" == "10.0" ]; then
-		# Packages for 10-CURRENT are still located in the 9-CURRENT
-		# directory.  Override environment to use correct package
-		# location if building for 10-CURRENT.
-		PACKAGESITE="ftp://ftp.freebsd.org/pub/FreeBSD/ports/${B_ARCH}/packages-9-current/Latest/"
-		export PACKAGESITE
-		PACKAGEROOT="ftp://ftp.freebsd.org/pub/FreeBSD/ports/${B_ARCH}/packages-9-current/"
-		export PACKAGEROOT
-		PKG_PATH="ftp://ftp.freebsd.org/pub/FreeBSD/ports/${B_ARCH}/packages-9-current/All/"
-		export PKG_PATH
-		build_compat9_port
-	fi
-	chroot ${CHROOTDIR} /bin/sh -c '/usr/sbin/pkg_add -r docproj-nojadetex' || \
-		build_docports
-}
-
-build_docports() 
-{
-	# Could not install textproc/docproj from pkg(8) or pkg_add(1).  Build
-	# the port as final fallback.
-	chroot ${CHROOTDIR} /bin/sh -c 'make -C /usr/ports/textproc/docproj BATCH=yes WITH_JADETEX=no WITHOUT_X11=yes WITHOUT_PYTHON=yes install clean' || \
-		{ echo "*** Could not build the textproj/docproj port.  Exiting."; exit 2; }
-}
+mkdir -p ${CHROOTDIR}/usr/src
+${SVN_CMD} co ${SVNROOT}/${BRANCHSRC} ${CHROOTDIR}/usr/src
+${SVN_CMD} co ${SVNROOTDOC}/${BRANCHDOC} ${CHROOTDIR}/usr/doc
+${SVN_CMD} co ${SVNROOTPORTS}/${BRANCHPORTS} ${CHROOTDIR}/usr/ports
+
+${SETENV} ${NWMAKE} -C ${CHROOTDIR}/usr/src ${WORLD_FLAGS} buildworld
+${SETENV} ${NWMAKE} -C ${CHROOTDIR}/usr/src installworld distribution DESTDIR=${CHROOTDIR}
+mount -t devfs devfs ${CHROOTDIR}/dev
+trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit
 
-if [ -d $2/usr/doc ]; then 
-	cp /etc/resolv.conf $2/etc/resolv.conf
+if [ -d ${CHROOTDIR}/usr/doc ]; then 
+	cp /etc/resolv.conf ${CHROOTDIR}/etc/resolv.conf
 
 	# Install docproj to build release documentation
-	CHROOTDIR="$2"
-	set +e
-	pkgng_install_docports "${CHROOTDIR}"
-	set -e
+	${CHROOT_CMD} /bin/sh -c \
+		'make -C /usr/ports/textproc/docproj \
+			BATCH=yes \
+			WITHOUT_SVN=yes \
+			WITHOUT_JADETEX=yes \
+			WITHOUT_X11=yes \
+			WITHOUT_PYTHON=yes \
+			install'
 fi
 
-chroot $2 make -C /usr/src $MAKE_FLAGS ${ARCH_FLAGS} buildworld buildkernel
-chroot $2 make -C /usr/src/release ${ARCH_FLAGS} release
-chroot $2 make -C /usr/src/release install DESTDIR=/R
-
-if [ "x${OSVERSION}" == "x" ]; then
-	OSRELEASE=`chroot $2 uname -r`
-fi
-
-: ${RELSTRING=`chroot $2 uname -s`-${OSRELEASE}-${B_ARCH}}
-
-cd $2/R
-for i in release.iso bootonly.iso memstick; do
-	mv $i $RELSTRING-$i
-done
-sha256 $RELSTRING-* > CHECKSUM.SHA256
-md5 $RELSTRING-* > CHECKSUM.MD5
-
+${CHROOT_CMD} ${SETENV} ${CROSSENV} ${WMAKE} buildworld
+${CHROOT_CMD} ${SETENV} ${CROSSENV} ${KMAKE} buildkernel
+${CHROOT_CMD} ${SETENV} ${CROSSENV} ${RMAKE} release
+${CHROOT_CMD} ${SETENV} ${CROSSENV} ${RMAKE} install DESTDIR=/R

Modified: stable/9/release/i386/mkisoimages.sh
==============================================================================
--- stable/9/release/i386/mkisoimages.sh	Sun Jun 16 17:54:56 2013	(r251811)
+++ stable/9/release/i386/mkisoimages.sh	Sun Jun 16 18:27:53 2013	(r251812)
@@ -36,9 +36,10 @@ if [ $# -lt 3 ]; then
 	exit 1
 fi
 
-LABEL=$1; shift
+LABEL=`echo $1 | tr '[:lower:]' '[:upper:]'`; shift
 NAME=$1; shift
 
-echo "/dev/iso9660/`echo $LABEL | tr '[:lower:]' '[:upper:]'` / cd9660 ro 0 0" > $1/etc/fstab
-makefs -t cd9660 $bootable -o rockridge -o label=$LABEL $NAME $*
+publisher="The FreeBSD Project.  http://www.FreeBSD.org/"
+echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab
+makefs -t cd9660 $bootable -o rockridge -o label=$LABEL -o publisher="$publisher" $NAME $*
 rm $1/etc/fstab

Modified: stable/9/release/ia64/mkisoimages.sh
==============================================================================
--- stable/9/release/ia64/mkisoimages.sh	Sun Jun 16 17:54:56 2013	(r251811)
+++ stable/9/release/ia64/mkisoimages.sh	Sun Jun 16 18:27:53 2013	(r251812)
@@ -37,7 +37,7 @@ if [ $# -lt 3 ]; then
     exit 1
 fi
 
-LABEL=$1; shift
+LABEL=`echo $1 | tr '[:lower:]' '[:upper:]'`; shift
 NAME=$1; shift
 BASE=$1; shift
 
@@ -74,8 +74,9 @@ else
     BOOTOPTS=""
 fi
 
+publisher="The FreeBSD Project.  http://www.FreeBSD.org/"
 echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $BASE/etc/fstab
-makefs -t cd9660 $BOOTOPTS -o rockridge -o label=$LABEL $NAME $BASE $*
+makefs -t cd9660 $BOOTOPTS -o rockridge -o label=$LABEL -o publisher="$publisher" $NAME $BASE $*
 rm $BASE/etc/fstab
 rm -f $EFIPART
 exit 0

Modified: stable/9/release/pc98/mkisoimages.sh
==============================================================================
--- stable/9/release/pc98/mkisoimages.sh	Sun Jun 16 17:54:56 2013	(r251811)
+++ stable/9/release/pc98/mkisoimages.sh	Sun Jun 16 18:27:53 2013	(r251812)
@@ -36,9 +36,10 @@ if [ $# -lt 3 ]; then
 	exit 1
 fi
 
-LABEL=$1; shift
+LABEL=`echo $1 | tr '[:lower:]' '[:upper:]'`; shift
 NAME=$1; shift
 
-echo "/dev/iso9660/`echo $LABEL | tr '[:lower:]' '[:upper:]'` / cd9660 ro 0 0" > $1/etc/fstab
-makefs -t cd9660 $bootable -o rockridge -o label=$LABEL $NAME $*
+publisher="The FreeBSD Project.  http://www.FreeBSD.org/"
+echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab
+makefs -t cd9660 $bootable -o rockridge -o label=$LABEL -o publisher="$publisher" $NAME $*
 rm $1/etc/fstab

Modified: stable/9/release/powerpc/mkisoimages.sh
==============================================================================
--- stable/9/release/powerpc/mkisoimages.sh	Sun Jun 16 17:54:56 2013	(r251811)
+++ stable/9/release/powerpc/mkisoimages.sh	Sun Jun 16 18:27:53 2013	(r251812)
@@ -58,12 +58,12 @@ if [ $# -lt 3 ]; then
 	exit 1
 fi
 
-LABEL=$1; shift
+LABEL=`echo $1 | tr '[:lower:]' '[:upper:]'`; shift
 NAME=$1; shift
 
-echo "/dev/iso9660/`echo $LABEL | tr '[:lower:]' '[:upper:]'` / cd9660 ro 0 0" > $1/etc/fstab
-makefs -t cd9660 $bootable -o rockridge -o label=$LABEL $NAME $*
+publisher="The FreeBSD Project.  http://www.FreeBSD.org/"
+echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab
+makefs -t cd9660 $bootable -o rockridge -o label=$LABEL -o publisher="$publisher" $NAME $*
 rm $1/etc/fstab
 rm /tmp/hfs-boot-block
 rm -rf $1/ppc
-

Modified: stable/9/release/sparc64/mkisoimages.sh
==============================================================================
--- stable/9/release/sparc64/mkisoimages.sh	Sun Jun 16 17:54:56 2013	(r251811)
+++ stable/9/release/sparc64/mkisoimages.sh	Sun Jun 16 18:27:53 2013	(r251812)
@@ -22,51 +22,61 @@
 # resulting ISO image, base-bits-dir contains the image contents and
 # extra-bits-dir, if provided, contains additional files to be merged
 # into base-bits-dir as part of making the image.
-
-publisher="The FreeBSD Project.  http://www.freebsd.org/"
-IMG=/tmp/bootfs
-MNT=/mnt
-
-if [ "x$1" = "x-b" ]; then
-	dd if=/dev/zero of=${IMG} bs=512 count=1024
-	MD=`mdconfig -a -t vnode -f ${IMG}`
-	sunlabel -w -B -b $4/boot/boot1 ${MD} auto
-	newfs -O1 -o space -m 0 /dev/${MD}
-	mount /dev/${MD} ${MNT}
-	mkdir ${MNT}/boot
-	cp $4/boot/loader ${MNT}/boot
-	umount ${MNT}
-	mdconfig -d -u ${MD#md}
-	bootable="-B ,,,,${IMG}"
-	shift
-else
-	bootable=""
-fi
-
 if [ $# -lt 3 ]; then
-	echo Usage: $0 '[-b] image-label image-name base-bits-dir [extra-bits-dir]'
-	rm -f ${IMG}
+	echo Usage: $0 '[-b] image-label image-name base-bits-dir [extra-bits-dir]' > /dev/stderr
 	exit 1
 fi
 
-type mkisofs 2>&1 | grep " is " >/dev/null
-if [ $? -ne 0 ]; then
-	echo The cdrtools port is not installed.  Trying to get it now.
-	if [ -f /usr/ports/sysutils/cdrtools/Makefile ]; then
-		cd /usr/ports/sysutils/cdrtools && make install BATCH=yes && make clean
-	else
-		if ! pkg_add -r cdrtools; then
-			echo "Could not get it via pkg_add - please go install this"
-			echo "from the ports collection and run this script again."
-			exit 2
-		fi
-	fi
-fi
-
-LABEL=$1; shift
+case $1 in
+-b)	BOPT=$1; shift ;;
+esac
+LABEL=`echo $1 | tr '[:lower:]' '[:upper:]'`; shift
 NAME=$1; shift
 
+# Create an ISO image
+publisher="The FreeBSD Project.  http://www.FreeBSD.org/"
 echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab
-mkisofs $bootable -r -J -V $LABEL -publisher "$publisher" -o $NAME $*
+makefs -t cd9660 -B be -o rockridge -o label="$LABEL" -o publisher="$publisher" ${NAME}.tmp $*
 rm $1/etc/fstab
-rm -f ${IMG}
+
+if [ "x$BOPT" != "x-b" ]; then
+	mv ${NAME}.tmp ${NAME}
+	exit 0
+fi
+TMPIMGDIR=`mktemp -d /tmp/bootfs.XXXXXXXX` || exit 1
+BOOTFSDIR="${TMPIMGDIR}/bootfs"
+BOOTFSIMG="${TMPIMGDIR}/bootfs.img"
+
+# Create a boot filesystem
+mkdir -p "${BOOTFSDIR}/boot"
+cp $4/boot/loader "${BOOTFSDIR}/boot"
+makefs -t ffs -B be -M 512k "${BOOTFSIMG}" "${BOOTFSDIR}"
+dd if=$4/boot/boot1 of="${BOOTFSIMG}" bs=512 conv=notrunc,sync
+
+# Create a boot ISO image
+: ${CYLSIZE:=640}
+ISOSIZE=$(stat -f %z ${NAME}.tmp)
+ISOBLKS=$(((${ISOSIZE} + 511) / 512))
+ISOCYLS=$(((${ISOBLKS} + (${CYLSIZE} - 1)) / ${CYLSIZE}))
+
+BOOTFSSIZE=$(stat -f %z "${BOOTFSIMG}")
+BOOTFSBLKS=$(((${BOOTFSSIZE} + 511) / 512))
+BOOTFSCYLS=$(((${BOOTFSBLKS} + (${CYLSIZE} - 1)) / ${CYLSIZE}))
+
+ENDCYL=$((${ISOCYLS} + ${BOOTFSCYLS}))
+NSECTS=$((${ENDCYL} * 1 * ${CYLSIZE}))
+
+dd if=${NAME}.tmp of=${NAME} bs=${CYLSIZE}b conv=notrunc,sync
+dd if=${BOOTFSIMG} of=${NAME} bs=${CYLSIZE}b seek=${ISOCYLS} conv=notrunc,sync
+# The number of alternative cylinders is always 2.
+dd if=/dev/zero of=${NAME} bs=${CYLSIZE}b seek=${ENDCYL} count=2 conv=notrunc,sync
+rm -rf ${NAME}.tmp ${TMPIMGDIR}
+
+# Write VTOC8 label to boot ISO image
+MD=`mdconfig -a -t vnode -S 512 -y 1 -x ${CYLSIZE} -f ${NAME}`
+gpart create -s VTOC8 ${MD}
+# !4: usr, for ISO image part
+gpart add -i 1 -s $((${ISOCYLS} * ${CYLSIZE} * 512))b -t \!4 ${MD}
+# !2: root, for bootfs part.
+gpart add -i 6 -s $((${BOOTFSCYLS} * ${CYLSIZE} * 512))b -t \!2 ${MD}
+mdconfig -d -u ${MD#md}


More information about the svn-src-stable-9 mailing list