release.sh revision 288435
1251652Sgjb#!/bin/sh
2251652Sgjb#-
3278985Sgjb# Copyright (c) 2013-2015 The FreeBSD Foundation
4251652Sgjb# Copyright (c) 2013 Glen Barber
5251652Sgjb# Copyright (c) 2011 Nathan Whitehorn
6251652Sgjb# All rights reserved.
7251652Sgjb#
8262761Sgjb# Portions of this software were developed by Glen Barber
9262761Sgjb# under sponsorship from the FreeBSD Foundation.
10262761Sgjb#
11251652Sgjb# Redistribution and use in source and binary forms, with or without
12251652Sgjb# modification, are permitted provided that the following conditions
13251652Sgjb# are met:
14251652Sgjb# 1. Redistributions of source code must retain the above copyright
15251652Sgjb#    notice, this list of conditions and the following disclaimer.
16251652Sgjb# 2. Redistributions in binary form must reproduce the above copyright
17251652Sgjb#    notice, this list of conditions and the following disclaimer in the
18251652Sgjb#    documentation and/or other materials provided with the distribution.
19251652Sgjb#
20251652Sgjb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21251652Sgjb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22251652Sgjb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23251652Sgjb# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24251652Sgjb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25251652Sgjb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26251652Sgjb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27251652Sgjb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28251652Sgjb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29251652Sgjb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30251652Sgjb# SUCH DAMAGE.
31251652Sgjb#
32251652Sgjb# release.sh: check out source trees, and build release components with
33251652Sgjb#  totally clean, fresh trees.
34251652Sgjb# Based on release/generate-release.sh written by Nathan Whitehorn
35251652Sgjb#
36251652Sgjb# $FreeBSD: stable/10/release/release.sh 288435 2015-10-01 00:47:30Z gjb $
37251652Sgjb#
38251652Sgjb
39283161Sgjbexport PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
40251652Sgjb
41283161SgjbVERSION=2
42251652Sgjb
43283161Sgjb# Prototypes that can be redefined per-chroot or per-target.
44283161Sgjbload_chroot_env() { }
45283161Sgjbload_target_env() { }
46283161Sgjbbuildenv_setup() { }
47262761Sgjb
48283161Sgjbusage() {
49283161Sgjb	echo "Usage: $0 [-c release.conf]"
50283161Sgjb	exit 1
51283161Sgjb}
52251652Sgjb
53283161Sgjb# env_setup(): Set up the default build environment variables, such as the
54283161Sgjb# CHROOTDIR, VCSCMD, SVNROOT, etc.  This is called before the release.conf
55283161Sgjb# file is sourced, if '-c <release.conf>' is specified.
56283161Sgjbenv_setup() {
57283161Sgjb	# The directory within which the release will be built.
58283161Sgjb	CHROOTDIR="/scratch"
59283161Sgjb	RELENGDIR="$(dirname $(realpath ${0}))"
60264106Sgjb
61283161Sgjb	# The default version control system command to obtain the sources.
62283161Sgjb	for _dir in /usr/bin /usr/local/bin; do
63283161Sgjb		for _svn in svn svnlite; do
64283161Sgjb			[ -x "${_dir}/${_svn}" ] && VCSCMD="${_dir}/${_svn}"
65283161Sgjb			[ ! -z "${VCSCMD}" ] && break 2
66283161Sgjb		done
67283161Sgjb	done
68283161Sgjb	VCSCMD="${VCSCMD} checkout"
69252846Sgjb
70283161Sgjb	# The default svn checkout server, and svn branches for src/, doc/,
71283161Sgjb	# and ports/.
72283161Sgjb	SVNROOT="svn://svn.FreeBSD.org/"
73283161Sgjb	SRCBRANCH="base/head@rHEAD"
74283161Sgjb	DOCBRANCH="doc/head@rHEAD"
75283161Sgjb	PORTBRANCH="ports/head@rHEAD"
76251652Sgjb
77283161Sgjb	# Set for embedded device builds.
78283161Sgjb	EMBEDDEDBUILD=
79262761Sgjb
80283161Sgjb	# Sometimes one needs to checkout src with --force svn option.
81283161Sgjb	# If custom kernel configs copied to src tree before checkout, e.g.
82283161Sgjb	SRC_FORCE_CHECKOUT=
83251652Sgjb
84283161Sgjb	# The default make.conf and src.conf to use.  Set to /dev/null
85283161Sgjb	# by default to avoid polluting the chroot(8) environment with
86283161Sgjb	# non-default settings.
87283161Sgjb	MAKE_CONF="/dev/null"
88283161Sgjb	SRC_CONF="/dev/null"
89251652Sgjb
90283161Sgjb	# The number of make(1) jobs, defaults to the number of CPUs available
91283161Sgjb	# for buildworld, and half of number of CPUs available for buildkernel.
92283161Sgjb	WORLD_FLAGS="-j$(sysctl -n hw.ncpu)"
93283161Sgjb	KERNEL_FLAGS="-j$(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2))"
94251652Sgjb
95283161Sgjb	MAKE_FLAGS="-s"
96259151Sgjb
97283161Sgjb	# The name of the kernel to build, defaults to GENERIC.
98283161Sgjb	KERNEL="GENERIC"
99273080Sgjb
100283161Sgjb	# Set to non-empty value to disable checkout of doc/ and/or ports/.
101283161Sgjb	# Disabling ports/ checkout also forces NODOC to be set.
102283161Sgjb	NODOC=
103283161Sgjb	NOPORTS=
104278985Sgjb
105283161Sgjb	# Set to non-empty value to build dvd1.iso as part of the release.
106283161Sgjb	WITH_DVD=
107283161Sgjb	WITH_COMPRESSED_IMAGES=
108251652Sgjb
109283161Sgjb	# Set to non-empty value to build virtual machine images as part of
110283161Sgjb	# the release.
111283161Sgjb	WITH_VMIMAGES=
112283161Sgjb	WITH_COMPRESSED_VMIMAGES=
113283161Sgjb	XZ_THREADS=0
114283161Sgjb
115283161Sgjb	# Set to non-empty value to build virtual machine images for various
116283161Sgjb	# cloud providers as part of the release.
117283161Sgjb	WITH_CLOUDWARE=
118283161Sgjb
119283161Sgjb	return 0
120283161Sgjb} # env_setup()
121283161Sgjb
122283161Sgjb# env_check(): Perform sanity tests on the build environment, such as ensuring
123283161Sgjb# files/directories exist, as well as adding backwards-compatibility hacks if
124283161Sgjb# necessary.  This is called unconditionally, and overrides the defaults set
125283161Sgjb# in env_setup() if '-c <release.conf>' is specified.
126283161Sgjbenv_check() {
127283161Sgjb	chroot_build_release_cmd="chroot_build_release"
128283161Sgjb	# Fix for backwards-compatibility with release.conf that does not have
129283161Sgjb	# the trailing '/'.
130283161Sgjb	case ${SVNROOT} in
131283161Sgjb		*svn*)
132283161Sgjb			SVNROOT="${SVNROOT}/"
133283161Sgjb			;;
134283161Sgjb		*)
135283161Sgjb			;;
136251652Sgjb	esac
137251652Sgjb
138283161Sgjb	# Prefix the branches with the SVNROOT for the full checkout URL.
139283161Sgjb	SRCBRANCH="${SVNROOT}${SRCBRANCH}"
140283161Sgjb	DOCBRANCH="${SVNROOT}${DOCBRANCH}"
141283161Sgjb	PORTBRANCH="${SVNROOT}${PORTBRANCH}"
142264106Sgjb
143283161Sgjb	if [ -n "${EMBEDDEDBUILD}" ]; then
144283161Sgjb		WITH_DVD=
145283161Sgjb		WITH_COMPRESSED_IMAGES=
146283161Sgjb		NODOC=yes
147283161Sgjb		case ${EMBEDDED_TARGET}:${EMBEDDED_TARGET_ARCH} in
148283161Sgjb			arm:armv6)
149283161Sgjb				chroot_build_release_cmd="chroot_arm_armv6_build_release"
150283161Sgjb				;;
151283161Sgjb			*)
152283161Sgjb		esac
153283161Sgjb	fi
154262761Sgjb
155283161Sgjb	# If PORTS is set and NODOC is unset, force NODOC=yes because the ports
156283161Sgjb	# tree is required to build the documentation set.
157283161Sgjb	if [ -n "${NOPORTS}" ] && [ -z "${NODOC}" ]; then
158283161Sgjb		echo "*** NOTICE: Setting NODOC=1 since ports tree is required"
159283161Sgjb		echo "            and NOPORTS is set."
160283161Sgjb		NODOC=yes
161283161Sgjb	fi
162283161Sgjb
163283161Sgjb	# If NOPORTS and/or NODOC are unset, they must not pass to make as
164283161Sgjb	# variables.  The release makefile verifies definedness of the
165283161Sgjb	# NOPORTS/NODOC variables instead of their values.
166283161Sgjb	DOCPORTS=
167283161Sgjb	if [ -n "${NOPORTS}" ]; then
168283161Sgjb		DOCPORTS="NOPORTS=yes "
169283161Sgjb	fi
170283161Sgjb	if [ -n "${NODOC}" ]; then
171283161Sgjb		DOCPORTS="${DOCPORTS}NODOC=yes"
172283161Sgjb	fi
173283161Sgjb
174283161Sgjb	# The aggregated build-time flags based upon variables defined within
175283161Sgjb	# this file, unless overridden by release.conf.  In most cases, these
176283161Sgjb	# will not need to be changed.
177283161Sgjb	CONF_FILES="__MAKE_CONF=${MAKE_CONF} SRCCONF=${SRC_CONF}"
178283161Sgjb	if [ -n "${TARGET}" ] && [ -n "${TARGET_ARCH}" ]; then
179283161Sgjb		ARCH_FLAGS="TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}"
180283161Sgjb	else
181283161Sgjb		ARCH_FLAGS=
182283161Sgjb	fi
183283161Sgjb	# Force src checkout if configured
184283161Sgjb	FORCE_SRC_KEY=
185283161Sgjb	if [ -n "${SRC_FORCE_CHECKOUT}" ]; then
186283161Sgjb		FORCE_SRC_KEY="--force"
187283161Sgjb	fi
188283161Sgjb
189283161Sgjb	if [ -z "${CHROOTDIR}" ]; then
190283161Sgjb		echo "Please set CHROOTDIR."
191264106Sgjb		exit 1
192264106Sgjb	fi
193264106Sgjb
194283161Sgjb	if [ $(id -u) -ne 0 ]; then
195283161Sgjb		echo "Needs to be run as root."
196283161Sgjb		exit 1
197283161Sgjb	fi
198252846Sgjb
199283161Sgjb	CHROOT_MAKEENV="${CHROOT_MAKEENV} \
200283161Sgjb		MAKEOBJDIRPREFIX=${CHROOTDIR}/tmp/obj"
201283161Sgjb	CHROOT_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${CONF_FILES}"
202283161Sgjb	CHROOT_IMAKEFLAGS="${CONF_FILES}"
203283161Sgjb	CHROOT_DMAKEFLAGS="${CONF_FILES}"
204283161Sgjb	RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} \
205283161Sgjb		${CONF_FILES}"
206283161Sgjb	RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} \
207283161Sgjb		KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}"
208283161Sgjb	RELEASE_RMAKEFLAGS="${ARCH_FLAGS} \
209283161Sgjb		KERNCONF=\"${KERNEL}\" ${CONF_FILES} ${DOCPORTS} \
210283161Sgjb		WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES} \
211283161Sgjb		WITH_CLOUDWARE=${WITH_CLOUDWARE} XZ_THREADS=${XZ_THREADS}"
212252846Sgjb
213283161Sgjb	return 0
214283161Sgjb} # env_check()
215251652Sgjb
216283161Sgjb# chroot_setup(): Prepare the build chroot environment for the release build.
217283161Sgjbchroot_setup() {
218283161Sgjb	load_chroot_env
219283161Sgjb	mkdir -p ${CHROOTDIR}/usr
220251652Sgjb
221283161Sgjb	if [ -z "${SRC_UPDATE_SKIP}" ]; then
222283161Sgjb		${VCSCMD} ${FORCE_SRC_KEY} ${SRCBRANCH} ${CHROOTDIR}/usr/src
223283161Sgjb	fi
224283161Sgjb	if [ -z "${NODOC}" ] && [ -z "${DOC_UPDATE_SKIP}" ]; then
225283161Sgjb		${VCSCMD} ${DOCBRANCH} ${CHROOTDIR}/usr/doc
226283161Sgjb	fi
227283161Sgjb	if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then
228283161Sgjb		${VCSCMD} ${PORTBRANCH} ${CHROOTDIR}/usr/ports
229283161Sgjb	fi
230251652Sgjb
231283161Sgjb	if [ -z "${CHROOTBUILD_SKIP}" ]; then
232283161Sgjb		cd ${CHROOTDIR}/usr/src
233283161Sgjb		env ${CHROOT_MAKEENV} make ${CHROOT_WMAKEFLAGS} buildworld
234283161Sgjb		env ${CHROOT_MAKEENV} make ${CHROOT_IMAKEFLAGS} installworld \
235283161Sgjb			DESTDIR=${CHROOTDIR}
236283161Sgjb		env ${CHROOT_MAKEENV} make ${CHROOT_DMAKEFLAGS} distribution \
237283161Sgjb			DESTDIR=${CHROOTDIR}
238283161Sgjb	fi
239251652Sgjb
240283161Sgjb	return 0
241283161Sgjb} # chroot_setup()
242251652Sgjb
243283161Sgjb# extra_chroot_setup(): Prepare anything additional within the build
244283161Sgjb# necessary for the release build.
245283161Sgjbextra_chroot_setup() {
246283161Sgjb	mkdir -p ${CHROOTDIR}/dev
247283161Sgjb	mount -t devfs devfs ${CHROOTDIR}/dev
248283161Sgjb	[ -e /etc/resolv.conf ] && cp /etc/resolv.conf \
249283161Sgjb		${CHROOTDIR}/etc/resolv.conf
250283161Sgjb	# Run ldconfig(8) in the chroot directory so /var/run/ld-elf*.so.hints
251283161Sgjb	# is created.  This is needed by ports-mgmt/pkg.
252283161Sgjb	eval chroot ${CHROOTDIR} /etc/rc.d/ldconfig forcerestart
253251652Sgjb
254283161Sgjb	# If MAKE_CONF and/or SRC_CONF are set and not character devices
255283161Sgjb	# (/dev/null), copy them to the chroot.
256283161Sgjb	if [ -e ${MAKE_CONF} ] && [ ! -c ${MAKE_CONF} ]; then
257283161Sgjb		mkdir -p ${CHROOTDIR}/$(dirname ${MAKE_CONF})
258283161Sgjb		cp ${MAKE_CONF} ${CHROOTDIR}/${MAKE_CONF}
259283161Sgjb	fi
260283161Sgjb	if [ -e ${SRC_CONF} ] && [ ! -c ${SRC_CONF} ]; then
261283161Sgjb		mkdir -p ${CHROOTDIR}/$(dirname ${SRC_CONF})
262283161Sgjb		cp ${SRC_CONF} ${CHROOTDIR}/${SRC_CONF}
263283161Sgjb	fi
264251652Sgjb
265283161Sgjb	if [ -d ${CHROOTDIR}/usr/ports ]; then
266283161Sgjb		# Trick the ports 'run-autotools-fixup' target to do the right
267283161Sgjb		# thing.
268283161Sgjb		_OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U)
269283161Sgjb		REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION)
270283161Sgjb		BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH)
271283161Sgjb		UNAME_r=${REVISION}-${BRANCH}
272283161Sgjb		if [ -d ${CHROOTDIR}/usr/doc ] && [ -z "${NODOC}" ]; then
273283161Sgjb			PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes"
274283161Sgjb			PBUILD_FLAGS="${PBUILD_FLAGS} UNAME_r=${UNAME_r}"
275283161Sgjb			PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}"
276283161Sgjb			chroot ${CHROOTDIR} make -C /usr/ports/textproc/docproj \
277283161Sgjb				${PBUILD_FLAGS} OPTIONS_UNSET="FOP IGOR" \
278283161Sgjb				install clean distclean
279283161Sgjb		fi
280283161Sgjb	fi
281251652Sgjb
282283161Sgjb	if [ ! -z "${EMBEDDEDPORTS}" ]; then
283283161Sgjb		for _PORT in ${EMBEDDEDPORTS}; do
284283161Sgjb			eval chroot ${CHROOTDIR} make -C /usr/ports/${_PORT} \
285283161Sgjb				BATCH=1 FORCE_PKG_REGISTER=1 install clean distclean
286283161Sgjb		done
287283161Sgjb	fi
288260071Sgjb
289283161Sgjb	buildenv_setup
290283161Sgjb
291283161Sgjb	return 0
292283161Sgjb} # extra_chroot_setup()
293283161Sgjb
294283161Sgjb# chroot_build_target(): Build the userland and kernel for the build target.
295283161Sgjbchroot_build_target() {
296283161Sgjb	load_target_env
297283161Sgjb	if [ ! -z "${EMBEDDEDBUILD}" ]; then
298283161Sgjb		RELEASE_WMAKEFLAGS="${RELEASE_WMAKEFLAGS} \
299283161Sgjb			TARGET=${EMBEDDED_TARGET} \
300283161Sgjb			TARGET_ARCH=${EMBEDDED_TARGET_ARCH}"
301283161Sgjb		RELEASE_KMAKEFLAGS="${RELEASE_KMAKEFLAGS} \
302283161Sgjb			TARGET=${EMBEDDED_TARGET} \
303283161Sgjb			TARGET_ARCH=${EMBEDDED_TARGET_ARCH}"
304264106Sgjb	fi
305283161Sgjb	eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld
306283161Sgjb	eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel
307264106Sgjb
308283161Sgjb	return 0
309283161Sgjb} # chroot_build_target
310257776Sgjb
311283161Sgjb# chroot_build_release(): Invoke the 'make release' target.
312283161Sgjbchroot_build_release() {
313283161Sgjb	load_target_env
314288435Sgjb	if [ ! -z "${WITH_VMIMAGES}" ]; then
315288435Sgjb		if [ -z "${VMFORMATS}" ]; then
316288435Sgjb			VMFORMATS="$(eval chroot ${CHROOTDIR} \
317288435Sgjb				make -C /usr/src/release -V VMFORMATS)"
318288435Sgjb		fi
319288435Sgjb		if [ -z "${VMSIZE}" ]; then
320288435Sgjb			VMSIZE="$(eval chroot ${CHROOTDIR} \
321288435Sgjb				make -C /usr/src/release -V VMSIZE)"
322288435Sgjb		fi
323288435Sgjb		RELEASE_RMAKEFLAGS="${RELEASE_RMAKEFLAGS} \
324288435Sgjb			VMFORMATS=\"${VMFORMATS}\" VMSIZE=${VMSIZE}"
325288435Sgjb	fi
326283161Sgjb	eval chroot ${CHROOTDIR} make -C /usr/src/release \
327283161Sgjb		${RELEASE_RMAKEFLAGS} release
328283161Sgjb	eval chroot ${CHROOTDIR} make -C /usr/src/release \
329283161Sgjb		${RELEASE_RMAKEFLAGS} install DESTDIR=/R \
330283161Sgjb		WITH_COMPRESSED_IMAGES=${WITH_COMPRESSED_IMAGES} \
331283161Sgjb		WITH_COMPRESSED_VMIMAGES=${WITH_COMPRESSED_VMIMAGES}
332283161Sgjb
333283161Sgjb	return 0
334283161Sgjb} # chroot_build_release()
335283161Sgjb
336283161Sgjb# chroot_arm_armv6_build_release(): Create arm/armv6 SD card image.
337283161Sgjbchroot_arm_armv6_build_release() {
338283161Sgjb	load_target_env
339283161Sgjb	eval chroot ${CHROOTDIR} make -C /usr/src/release obj
340283161Sgjb	if [ -e "${RELENGDIR}/tools/${EMBEDDED_TARGET}.subr" ]; then
341283161Sgjb		. "${RELENGDIR}/tools/${EMBEDDED_TARGET}.subr"
342251652Sgjb	fi
343283161Sgjb	[ ! -z "${RELEASECONF}" ] && . "${RELEASECONF}"
344283161Sgjb	WORLDDIR="$(eval chroot ${CHROOTDIR} make -C /usr/src/release -V WORLDDIR)"
345283161Sgjb	OBJDIR="$(eval chroot ${CHROOTDIR} make -C /usr/src/release -V .OBJDIR)"
346283161Sgjb	DESTDIR="${OBJDIR}/${KERNEL}"
347283161Sgjb	IMGBASE="${CHROOTDIR}/${OBJDIR}/${KERNEL}.img"
348283161Sgjb	OSRELEASE="$(eval chroot ${CHROOTDIR} make -C /usr/src/release \
349283161Sgjb		TARGET=${EMBEDDED_TARGET} TARGET_ARCH=${EMBEDDED_TARGET_ARCH} \
350283161Sgjb		-V OSRELEASE)"
351283161Sgjb	chroot ${CHROOTDIR} mkdir -p ${DESTDIR}
352283161Sgjb	chroot ${CHROOTDIR} truncate -s ${IMAGE_SIZE} ${IMGBASE##${CHROOTDIR}}
353283161Sgjb	export mddev=$(chroot ${CHROOTDIR} \
354283161Sgjb		mdconfig -f ${IMGBASE##${CHROOTDIR}} ${MD_ARGS})
355283161Sgjb	arm_create_disk
356283161Sgjb	arm_install_base
357283161Sgjb	arm_install_uboot
358283161Sgjb	mdconfig -d -u ${mddev}
359283161Sgjb	chroot ${CHROOTDIR} rmdir ${DESTDIR}
360283161Sgjb	mv ${IMGBASE} ${CHROOTDIR}/${OBJDIR}/${OSRELEASE}-${KERNEL}.img
361283161Sgjb	chroot ${CHROOTDIR} mkdir -p /R
362283161Sgjb	chroot ${CHROOTDIR} cp -p ${OBJDIR}/${OSRELEASE}-${KERNEL}.img \
363283161Sgjb		/R/${OSRELEASE}-${KERNEL}.img
364283161Sgjb	chroot ${CHROOTDIR} xz -T ${XZ_THREADS} /R/${OSRELEASE}-${KERNEL}.img
365283161Sgjb	cd ${CHROOTDIR}/R && sha256 ${OSRELEASE}* \
366283161Sgjb		> CHECKSUM.SHA256
367283161Sgjb	cd ${CHROOTDIR}/R && md5 ${OSRELEASE}* \
368283161Sgjb		> CHECKSUM.MD5
369252101Sgjb
370283161Sgjb	return 0
371283161Sgjb} # chroot_arm_armv6_build_release()
372283161Sgjb
373283161Sgjb# main(): Start here.
374283161Sgjbmain() {
375283161Sgjb	set -e # Everything must succeed
376283161Sgjb	env_setup
377283161Sgjb	while getopts c: opt; do
378283161Sgjb		case ${opt} in
379283161Sgjb			c)
380283161Sgjb				RELEASECONF="${OPTARG}"
381283161Sgjb				;;
382283161Sgjb			\?)
383283161Sgjb				usage
384283161Sgjb				;;
385283161Sgjb		esac
386283161Sgjb	done
387283161Sgjb	shift $(($OPTIND - 1))
388283161Sgjb	if [ ! -z "${RELEASECONF}" ]; then
389283161Sgjb		if [ -e "${RELEASECONF}" ]; then
390283161Sgjb			. ${RELEASECONF}
391283161Sgjb		else
392283161Sgjb			echo "Nonexistent configuration file: ${RELEASECONF}"
393283161Sgjb			echo "Using default build environment."
394283161Sgjb		fi
395283161Sgjb	fi
396283161Sgjb	env_check
397283161Sgjb	trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit
398283161Sgjb	chroot_setup
399283161Sgjb	extra_chroot_setup
400283161Sgjb	chroot_build_target
401283161Sgjb	${chroot_build_release_cmd}
402283161Sgjb
403283161Sgjb	return 0
404283161Sgjb} # main()
405283161Sgjb
406283161Sgjbmain "${@}"
407