release.sh revision 293859
137535Sdes#!/bin/sh
2135546Sdes#-
337535Sdes# Copyright (c) 2013-2015 The FreeBSD Foundation
437535Sdes# Copyright (c) 2013 Glen Barber
537535Sdes# Copyright (c) 2011 Nathan Whitehorn
637535Sdes# All rights reserved.
737535Sdes#
837535Sdes# Portions of this software were developed by Glen Barber
937535Sdes# under sponsorship from the FreeBSD Foundation.
1037535Sdes#
1137535Sdes# Redistribution and use in source and binary forms, with or without
1237535Sdes# modification, are permitted provided that the following conditions
1337535Sdes# are met:
1437535Sdes# 1. Redistributions of source code must retain the above copyright
1563012Sdes#    notice, this list of conditions and the following disclaimer.
1637535Sdes# 2. Redistributions in binary form must reproduce the above copyright
1737535Sdes#    notice, this list of conditions and the following disclaimer in the
1837535Sdes#    documentation and/or other materials provided with the distribution.
1937535Sdes#
2037535Sdes# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2137535Sdes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2237535Sdes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2337535Sdes# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2437535Sdes# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2537535Sdes# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2637535Sdes# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2737535Sdes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2837535Sdes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2984203Sdillon# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3084203Sdillon# SUCH DAMAGE.
3184203Sdillon#
3263236Sdes# release.sh: check out source trees, and build release components with
3363236Sdes#  totally clean, fresh trees.
3463236Sdes# Based on release/generate-release.sh written by Nathan Whitehorn
3563236Sdes#
3663236Sdes# $FreeBSD: stable/10/release/release.sh 293859 2016-01-14 00:26:31Z gjb $
3763236Sdes#
3863236Sdes
3963236Sdesexport PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
4063236Sdes
4163236SdesVERSION=2
4263236Sdes
4363236Sdes# Prototypes that can be redefined per-chroot or per-target.
4463236Sdesload_chroot_env() { }
4563236Sdesload_target_env() { }
4663236Sdesbuildenv_setup() { }
4763236Sdes
4863236Sdesusage() {
4990267Sdes	echo "Usage: $0 [-c release.conf]"
5063236Sdes	exit 1
5163236Sdes}
5263236Sdes
5363236Sdes# env_setup(): Set up the default build environment variables, such as the
5463236Sdes# CHROOTDIR, VCSCMD, SVNROOT, etc.  This is called before the release.conf
5563236Sdes# file is sourced, if '-c <release.conf>' is specified.
5663236Sdesenv_setup() {
5763236Sdes	# The directory within which the release will be built.
5863236Sdes	CHROOTDIR="/scratch"
5963236Sdes	RELENGDIR="$(dirname $(realpath ${0}))"
6063236Sdes
6163236Sdes	# The default version control system command to obtain the sources.
6263236Sdes	for _dir in /usr/bin /usr/local/bin; do
6363236Sdes		for _svn in svn svnlite; do
6437535Sdes			[ -x "${_dir}/${_svn}" ] && VCSCMD="${_dir}/${_svn}"
6560737Sume			[ ! -z "${VCSCMD}" ] && break 2
6637535Sdes		done
6763012Sdes	done
6837535Sdes	VCSCMD="${VCSCMD} checkout"
6963012Sdes
7060376Sdes	# The default svn checkout server, and svn branches for src/, doc/,
7160189Sdes	# and ports/.
7237608Sdes	SVNROOT="svn://svn.FreeBSD.org/"
7337535Sdes	SRCBRANCH="base/head@rHEAD"
7437535Sdes	DOCBRANCH="doc/head@rHEAD"
7537535Sdes	PORTBRANCH="ports/head@rHEAD"
7660376Sdes
7737535Sdes	# Set for embedded device builds.
7837535Sdes	EMBEDDEDBUILD=
79141958Skbyanc
80141958Skbyanc	# Sometimes one needs to checkout src with --force svn option.
81141958Skbyanc	# If custom kernel configs copied to src tree before checkout, e.g.
8237535Sdes	SRC_FORCE_CHECKOUT=
8340939Sdes
8441862Sdes	# The default make.conf and src.conf to use.  Set to /dev/null
8537535Sdes	# by default to avoid polluting the chroot(8) environment with
8663012Sdes	# non-default settings.
8763012Sdes	MAKE_CONF="/dev/null"
8837535Sdes	SRC_CONF="/dev/null"
8963012Sdes
9063012Sdes	# The number of make(1) jobs, defaults to the number of CPUs available
9163012Sdes	# for buildworld, and half of number of CPUs available for buildkernel.
9263012Sdes	WORLD_FLAGS="-j$(sysctl -n hw.ncpu)"
9363012Sdes	KERNEL_FLAGS="-j$(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2))"
9463012Sdes
9563012Sdes	MAKE_FLAGS="-s"
9687317Sdes
97125696Sdes	# The name of the kernel to build, defaults to GENERIC.
9863012Sdes	KERNEL="GENERIC"
9960196Sdes
10063012Sdes	# Set to non-empty value to disable checkout of doc/ and/or ports/.
10190267Sdes	# Disabling ports/ checkout also forces NODOC to be set.
10290267Sdes	NODOC=
10363012Sdes	NOPORTS=
10488771Sdes
10563012Sdes	# Set to non-empty value to build dvd1.iso as part of the release.
10690267Sdes	WITH_DVD=
10763012Sdes	WITH_COMPRESSED_IMAGES=
10863012Sdes
10963012Sdes	# Set to non-empty value to build virtual machine images as part of
11063012Sdes	# the release.
11197859Sdes	WITH_VMIMAGES=
11237535Sdes	WITH_COMPRESSED_VMIMAGES=
11397858Sdes	XZ_THREADS=0
11497866Sdes
11597858Sdes	# Set to non-empty value to build virtual machine images for various
11697866Sdes	# cloud providers as part of the release.
11797866Sdes	WITH_CLOUDWARE=
11897866Sdes
11997858Sdes	return 0
12097858Sdes} # env_setup()
12197858Sdes
12263281Sdes# env_check(): Perform sanity tests on the build environment, such as ensuring
12390267Sdes# files/directories exist, as well as adding backwards-compatibility hacks if
12463012Sdes# necessary.  This is called unconditionally, and overrides the defaults set
12537535Sdes# in env_setup() if '-c <release.conf>' is specified.
12637535Sdesenv_check() {
12737608Sdes	chroot_build_release_cmd="chroot_build_release"
12863012Sdes	# Fix for backwards-compatibility with release.conf that does not have
12937608Sdes	# the trailing '/'.
13037608Sdes	case ${SVNROOT} in
13197859Sdes		*svn*)
13237608Sdes			SVNROOT="${SVNROOT}/"
13390267Sdes			;;
13490267Sdes		*)
13597859Sdes			;;
13690267Sdes	esac
13790267Sdes
13897859Sdes	# Prefix the branches with the SVNROOT for the full checkout URL.
13990267Sdes	SRCBRANCH="${SVNROOT}${SRCBRANCH}"
14090267Sdes	DOCBRANCH="${SVNROOT}${DOCBRANCH}"
14197859Sdes	PORTBRANCH="${SVNROOT}${PORTBRANCH}"
14290267Sdes
14390267Sdes	if [ -n "${EMBEDDEDBUILD}" ]; then
14490267Sdes		WITH_DVD=
14590267Sdes		WITH_COMPRESSED_IMAGES=
14690267Sdes		NODOC=yes
14797859Sdes		case ${EMBEDDED_TARGET}:${EMBEDDED_TARGET_ARCH} in
14890267Sdes			arm:armv6)
14990267Sdes				chroot_build_release_cmd="chroot_arm_armv6_build_release"
15097859Sdes				;;
15190267Sdes			*)
15290267Sdes		esac
15390267Sdes	fi
15490267Sdes
15563281Sdes	# If PORTS is set and NODOC is unset, force NODOC=yes because the ports
15690267Sdes	# tree is required to build the documentation set.
15797859Sdes	if [ -n "${NOPORTS}" ] && [ -z "${NODOC}" ]; then
15897859Sdes		echo "*** NOTICE: Setting NODOC=1 since ports tree is required"
159106207Sdes		echo "            and NOPORTS is set."
16090267Sdes		NODOC=yes
161106207Sdes	fi
162106207Sdes
163106207Sdes	# If NOPORTS and/or NODOC are unset, they must not pass to make as
16490267Sdes	# variables.  The release makefile verifies definedness of the
16563012Sdes	# NOPORTS/NODOC variables instead of their values.
16690267Sdes	DOCPORTS=
16797859Sdes	if [ -n "${NOPORTS}" ]; then
16837608Sdes		DOCPORTS="NOPORTS=yes "
16937608Sdes	fi
17037608Sdes	if [ -n "${NODOC}" ]; then
17197866Sdes		DOCPORTS="${DOCPORTS}NODOC=yes"
17297866Sdes	fi
17397866Sdes
17497866Sdes	# The aggregated build-time flags based upon variables defined within
17597866Sdes	# this file, unless overridden by release.conf.  In most cases, these
17697866Sdes	# will not need to be changed.
17797866Sdes	CONF_FILES="__MAKE_CONF=${MAKE_CONF} SRCCONF=${SRC_CONF}"
17897866Sdes	if [ -n "${TARGET}" ] && [ -n "${TARGET_ARCH}" ]; then
17997866Sdes		ARCH_FLAGS="TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}"
18097866Sdes	else
18197866Sdes		ARCH_FLAGS=
18297866Sdes	fi
18397866Sdes	# Force src checkout if configured
18497866Sdes	FORCE_SRC_KEY=
185106044Sdes	if [ -n "${SRC_FORCE_CHECKOUT}" ]; then
18697866Sdes		FORCE_SRC_KEY="--force"
18797866Sdes	fi
18897866Sdes
18937608Sdes	if [ -z "${CHROOTDIR}" ]; then
19037608Sdes		echo "Please set CHROOTDIR."
19163012Sdes		exit 1
19297866Sdes	fi
19337535Sdes
19497859Sdes	if [ $(id -u) -ne 0 ]; then
19590267Sdes		echo "Needs to be run as root."
19697859Sdes		exit 1
19790267Sdes	fi
19890267Sdes
19997866Sdes	CHROOT_MAKEENV="${CHROOT_MAKEENV} \
20097866Sdes		MAKEOBJDIRPREFIX=${CHROOTDIR}/tmp/obj"
20197866Sdes	CHROOT_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${CONF_FILES}"
202106185Sdes	CHROOT_IMAKEFLAGS="${CONF_FILES}"
203106185Sdes	CHROOT_DMAKEFLAGS="${CONF_FILES}"
20497866Sdes	RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} \
205106185Sdes		${CONF_FILES}"
20697866Sdes	RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} \
20797866Sdes		KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}"
20897866Sdes	RELEASE_RMAKEFLAGS="${ARCH_FLAGS} \
20997866Sdes		KERNCONF=\"${KERNEL}\" ${CONF_FILES} ${DOCPORTS} \
21097859Sdes		WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES} \
21197859Sdes		WITH_CLOUDWARE=${WITH_CLOUDWARE} XZ_THREADS=${XZ_THREADS}"
21290267Sdes
21397859Sdes	return 0
21490267Sdes} # env_check()
21590267Sdes
21697859Sdes# chroot_setup(): Prepare the build chroot environment for the release build.
21790267Sdeschroot_setup() {
21890267Sdes	load_chroot_env
21937535Sdes	mkdir -p ${CHROOTDIR}/usr
22063012Sdes
22197866Sdes	if [ -z "${SRC_UPDATE_SKIP}" ]; then
22297866Sdes		${VCSCMD} ${FORCE_SRC_KEY} ${SRCBRANCH} ${CHROOTDIR}/usr/src
22397866Sdes	fi
22490267Sdes	if [ -z "${NODOC}" ] && [ -z "${DOC_UPDATE_SKIP}" ]; then
225106185Sdes		${VCSCMD} ${DOCBRANCH} ${CHROOTDIR}/usr/doc
226106185Sdes	fi
22797866Sdes	if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then
228106185Sdes		${VCSCMD} ${PORTBRANCH} ${CHROOTDIR}/usr/ports
22997866Sdes	fi
23090267Sdes
23197859Sdes	if [ -z "${CHROOTBUILD_SKIP}" ]; then
23297856Sdes		cd ${CHROOTDIR}/usr/src
23397856Sdes		env ${CHROOT_MAKEENV} make ${CHROOT_WMAKEFLAGS} buildworld
23497866Sdes		env ${CHROOT_MAKEENV} make ${CHROOT_IMAKEFLAGS} installworld \
23597856Sdes			DESTDIR=${CHROOTDIR}
23690267Sdes		env ${CHROOT_MAKEENV} make ${CHROOT_DMAKEFLAGS} distribution \
23790267Sdes			DESTDIR=${CHROOTDIR}
23890267Sdes	fi
23997866Sdes
24090267Sdes	return 0
24197866Sdes} # chroot_setup()
24237535Sdes
24337535Sdes# extra_chroot_setup(): Prepare anything additional within the build
24437608Sdes# necessary for the release build.
24537608Sdesextra_chroot_setup() {
24637608Sdes	mkdir -p ${CHROOTDIR}/dev
24737535Sdes	mount -t devfs devfs ${CHROOTDIR}/dev
24863012Sdes	[ -e /etc/resolv.conf ] && cp /etc/resolv.conf \
24937535Sdes		${CHROOTDIR}/etc/resolv.conf
25097859Sdes	# Run ldconfig(8) in the chroot directory so /var/run/ld-elf*.so.hints
25190267Sdes	# is created.  This is needed by ports-mgmt/pkg.
25263012Sdes	eval chroot ${CHROOTDIR} /etc/rc.d/ldconfig forcerestart
25397859Sdes
25490267Sdes	# If MAKE_CONF and/or SRC_CONF are set and not character devices
25597859Sdes	# (/dev/null), copy them to the chroot.
25690267Sdes	if [ -e ${MAKE_CONF} ] && [ ! -c ${MAKE_CONF} ]; then
25763012Sdes		mkdir -p ${CHROOTDIR}/$(dirname ${MAKE_CONF})
25890267Sdes		cp ${MAKE_CONF} ${CHROOTDIR}/${MAKE_CONF}
25990267Sdes	fi
26097866Sdes	if [ -e ${SRC_CONF} ] && [ ! -c ${SRC_CONF} ]; then
26197866Sdes		mkdir -p ${CHROOTDIR}/$(dirname ${SRC_CONF})
26290267Sdes		cp ${SRC_CONF} ${CHROOTDIR}/${SRC_CONF}
26397866Sdes	fi
26490267Sdes
26590267Sdes	if [ -d ${CHROOTDIR}/usr/ports ]; then
26697866Sdes		# Trick the ports 'run-autotools-fixup' target to do the right
26797866Sdes		# thing.
26890267Sdes		_OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U)
26937535Sdes		REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION)
27097859Sdes		BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH)
27190267Sdes		UNAME_r=${REVISION}-${BRANCH}
27290267Sdes		if [ -d ${CHROOTDIR}/usr/doc ] && [ -z "${NODOC}" ]; then
27337535Sdes			PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes"
27437535Sdes			PBUILD_FLAGS="${PBUILD_FLAGS} UNAME_r=${UNAME_r}"
27537608Sdes			PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}"
27637608Sdes			chroot ${CHROOTDIR} make -C /usr/ports/textproc/docproj \
27737608Sdes				${PBUILD_FLAGS} OPTIONS_UNSET="FOP IGOR" \
27837535Sdes				FORCE_PKG_REGISTER=1 \
27963012Sdes				install clean distclean
28037535Sdes		fi
28197859Sdes	fi
28290267Sdes
28397866Sdes	if [ ! -z "${EMBEDDEDPORTS}" ]; then
28437535Sdes		for _PORT in ${EMBEDDEDPORTS}; do
28537535Sdes			eval chroot ${CHROOTDIR} make -C /usr/ports/${_PORT} \
28637608Sdes				BATCH=1 FORCE_PKG_REGISTER=1 install clean distclean
28737608Sdes		done
28837608Sdes	fi
28937535Sdes
29063012Sdes	buildenv_setup
29137535Sdes
29297859Sdes	return 0
29390267Sdes} # extra_chroot_setup()
29463012Sdes
29597859Sdes# chroot_build_target(): Build the userland and kernel for the build target.
29697859Sdeschroot_build_target() {
29797859Sdes	load_target_env
29897859Sdes	if [ ! -z "${EMBEDDEDBUILD}" ]; then
29990267Sdes		RELEASE_WMAKEFLAGS="${RELEASE_WMAKEFLAGS} \
30037535Sdes			TARGET=${EMBEDDED_TARGET} \
30137535Sdes			TARGET_ARCH=${EMBEDDED_TARGET_ARCH}"
30237608Sdes		RELEASE_KMAKEFLAGS="${RELEASE_KMAKEFLAGS} \
30363012Sdes			TARGET=${EMBEDDED_TARGET} \
30437608Sdes			TARGET_ARCH=${EMBEDDED_TARGET_ARCH}"
30563012Sdes	fi
30697866Sdes	eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld
30737535Sdes	eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel
30897859Sdes
30990267Sdes	return 0
31063012Sdes} # chroot_build_target
311109967Sdes
31290267Sdes# chroot_build_release(): Invoke the 'make release' target.
31390267Sdeschroot_build_release() {
31490267Sdes	load_target_env
31597859Sdes	if [ ! -z "${WITH_VMIMAGES}" ]; then
31697866Sdes		if [ -z "${VMFORMATS}" ]; then
31797859Sdes			VMFORMATS="$(eval chroot ${CHROOTDIR} \
31890267Sdes				make -C /usr/src/release -V VMFORMATS)"
31990267Sdes		fi
32097859Sdes		if [ -z "${VMSIZE}" ]; then
32190267Sdes			VMSIZE="$(eval chroot ${CHROOTDIR} \
32290267Sdes				make -C /usr/src/release -V VMSIZE)"
32390267Sdes		fi
32463012Sdes		RELEASE_RMAKEFLAGS="${RELEASE_RMAKEFLAGS} \
32563012Sdes			VMFORMATS=\"${VMFORMATS}\" VMSIZE=${VMSIZE}"
32690267Sdes	fi
32763012Sdes	eval chroot ${CHROOTDIR} make -C /usr/src/release \
32863012Sdes		${RELEASE_RMAKEFLAGS} release
32963012Sdes	eval chroot ${CHROOTDIR} make -C /usr/src/release \
33063012Sdes		${RELEASE_RMAKEFLAGS} install DESTDIR=/R \
33163012Sdes		WITH_COMPRESSED_IMAGES=${WITH_COMPRESSED_IMAGES} \
33263012Sdes		WITH_COMPRESSED_VMIMAGES=${WITH_COMPRESSED_VMIMAGES}
33390267Sdes
33490267Sdes	return 0
33590267Sdes} # chroot_build_release()
33690267Sdes
33790267Sdes# chroot_arm_armv6_build_release(): Create arm/armv6 SD card image.
33890267Sdeschroot_arm_armv6_build_release() {
33990267Sdes	load_target_env
34090267Sdes	eval chroot ${CHROOTDIR} make -C /usr/src/release obj
34190267Sdes	if [ -e "${RELENGDIR}/tools/${EMBEDDED_TARGET}.subr" ]; then
34290267Sdes		. "${RELENGDIR}/tools/${EMBEDDED_TARGET}.subr"
34385093Sdes	fi
34463012Sdes	[ ! -z "${RELEASECONF}" ] && . "${RELEASECONF}"
34563012Sdes	WORLDDIR="$(eval chroot ${CHROOTDIR} make -C /usr/src/release -V WORLDDIR)"
34663012Sdes	OBJDIR="$(eval chroot ${CHROOTDIR} make -C /usr/src/release -V .OBJDIR)"
34790267Sdes	DESTDIR="${OBJDIR}/${KERNEL}"
34890267Sdes	IMGBASE="${CHROOTDIR}/${OBJDIR}/${KERNEL}.img"
34963012Sdes	OSRELEASE="$(eval chroot ${CHROOTDIR} make -C /usr/src/release \
35090267Sdes		TARGET=${EMBEDDED_TARGET} TARGET_ARCH=${EMBEDDED_TARGET_ARCH} \
35190267Sdes		-V OSRELEASE)"
35290267Sdes	chroot ${CHROOTDIR} mkdir -p ${DESTDIR}
35390267Sdes	chroot ${CHROOTDIR} truncate -s ${IMAGE_SIZE} ${IMGBASE##${CHROOTDIR}}
35490267Sdes	export mddev=$(chroot ${CHROOTDIR} \
35590267Sdes		mdconfig -f ${IMGBASE##${CHROOTDIR}} ${MD_ARGS})
35690267Sdes	arm_create_disk
35763012Sdes	arm_install_base
35863012Sdes	arm_install_uboot
35963012Sdes	mdconfig -d -u ${mddev}
36063012Sdes	chroot ${CHROOTDIR} rmdir ${DESTDIR}
36163012Sdes	mv ${IMGBASE} ${CHROOTDIR}/${OBJDIR}/${OSRELEASE}-${KERNEL}.img
36263012Sdes	chroot ${CHROOTDIR} mkdir -p /R
36397856Sdes	chroot ${CHROOTDIR} cp -p ${OBJDIR}/${OSRELEASE}-${KERNEL}.img \
36463012Sdes		/R/${OSRELEASE}-${KERNEL}.img
36590267Sdes	chroot ${CHROOTDIR} xz -T ${XZ_THREADS} /R/${OSRELEASE}-${KERNEL}.img
36690267Sdes	cd ${CHROOTDIR}/R && sha512 ${OSRELEASE}* \
36790267Sdes		> CHECKSUM.SHA512
36890267Sdes	cd ${CHROOTDIR}/R && sha256 ${OSRELEASE}* \
36963012Sdes		> CHECKSUM.SHA256
37090267Sdes
37190267Sdes	return 0
37290267Sdes} # chroot_arm_armv6_build_release()
37390267Sdes
37490267Sdes# main(): Start here.
37590267Sdesmain() {
37690267Sdes	set -e # Everything must succeed
37790267Sdes	env_setup
37890267Sdes	while getopts c: opt; do
37990267Sdes		case ${opt} in
38097856Sdes			c)
38190267Sdes				RELEASECONF="${OPTARG}"
38290267Sdes				;;
38390267Sdes			\?)
38490267Sdes				usage
38590267Sdes				;;
38690267Sdes		esac
38790267Sdes	done
38890267Sdes	shift $(($OPTIND - 1))
38963012Sdes	if [ ! -z "${RELEASECONF}" ]; then
39063012Sdes		if [ -e "${RELEASECONF}" ]; then
39163012Sdes			. ${RELEASECONF}
39263012Sdes		else
39363012Sdes			echo "Nonexistent configuration file: ${RELEASECONF}"
39463012Sdes			echo "Using default build environment."
39597856Sdes		fi
39663012Sdes	fi
39790267Sdes	env_check
39890267Sdes	trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit
39997856Sdes	chroot_setup
40090267Sdes	extra_chroot_setup
40190267Sdes	chroot_build_target
40290267Sdes	${chroot_build_release_cmd}
40390267Sdes
40490267Sdes	return 0
40590267Sdes} # main()
40690267Sdes
40790267Sdesmain "${@}"
40890267Sdes