1251652Sgjb#!/bin/sh 2251652Sgjb#- 3278206Sgjb# Copyright (c) 2013-2015 The FreeBSD Foundation 4251652Sgjb# Copyright (c) 2013 Glen Barber 5251652Sgjb# Copyright (c) 2011 Nathan Whitehorn 6251652Sgjb# All rights reserved. 7251652Sgjb# 8262499Sgjb# Portions of this software were developed by Glen Barber 9262499Sgjb# under sponsorship from the FreeBSD Foundation. 10262499Sgjb# 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: releng/11.0/release/release.sh 304015 2016-08-12 19:26:12Z gjb $ 37251652Sgjb# 38251652Sgjb 39282693Sgjbexport PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin" 40251652Sgjb 41282693SgjbVERSION=2 42282693Sgjb 43269639Sgjb# Prototypes that can be redefined per-chroot or per-target. 44269639Sgjbload_chroot_env() { } 45269639Sgjbload_target_env() { } 46281802Sgjbbuildenv_setup() { } 47269639Sgjb 48282693Sgjbusage() { 49282693Sgjb echo "Usage: $0 [-c release.conf]" 50282693Sgjb exit 1 51282693Sgjb} 52251652Sgjb 53282693Sgjb# env_setup(): Set up the default build environment variables, such as the 54282693Sgjb# CHROOTDIR, VCSCMD, SVNROOT, etc. This is called before the release.conf 55282693Sgjb# file is sourced, if '-c <release.conf>' is specified. 56282693Sgjbenv_setup() { 57282693Sgjb # The directory within which the release will be built. 58282693Sgjb CHROOTDIR="/scratch" 59282693Sgjb RELENGDIR="$(dirname $(realpath ${0}))" 60262499Sgjb 61282693Sgjb # The default version control system command to obtain the sources. 62282693Sgjb for _dir in /usr/bin /usr/local/bin; do 63282693Sgjb for _svn in svn svnlite; do 64282693Sgjb [ -x "${_dir}/${_svn}" ] && VCSCMD="${_dir}/${_svn}" 65282693Sgjb [ ! -z "${VCSCMD}" ] && break 2 66282693Sgjb done 67282693Sgjb done 68282693Sgjb VCSCMD="${VCSCMD} checkout" 69251652Sgjb 70282693Sgjb # The default svn checkout server, and svn branches for src/, doc/, 71282693Sgjb # and ports/. 72282693Sgjb SVNROOT="svn://svn.FreeBSD.org/" 73282693Sgjb SRCBRANCH="base/head@rHEAD" 74282693Sgjb DOCBRANCH="doc/head@rHEAD" 75282693Sgjb PORTBRANCH="ports/head@rHEAD" 76262810Sgjb 77282693Sgjb # Set for embedded device builds. 78282693Sgjb EMBEDDEDBUILD= 79252846Sgjb 80282693Sgjb # Sometimes one needs to checkout src with --force svn option. 81282693Sgjb # If custom kernel configs copied to src tree before checkout, e.g. 82282693Sgjb SRC_FORCE_CHECKOUT= 83251652Sgjb 84282693Sgjb # The default make.conf and src.conf to use. Set to /dev/null 85282693Sgjb # by default to avoid polluting the chroot(8) environment with 86282693Sgjb # non-default settings. 87282693Sgjb MAKE_CONF="/dev/null" 88282693Sgjb SRC_CONF="/dev/null" 89262509Sgjb 90282693Sgjb # The number of make(1) jobs, defaults to the number of CPUs available 91282693Sgjb # for buildworld, and half of number of CPUs available for buildkernel. 92282693Sgjb WORLD_FLAGS="-j$(sysctl -n hw.ncpu)" 93282693Sgjb KERNEL_FLAGS="-j$(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2))" 94251652Sgjb 95282693Sgjb MAKE_FLAGS="-s" 96251652Sgjb 97282693Sgjb # The name of the kernel to build, defaults to GENERIC. 98282693Sgjb KERNEL="GENERIC" 99251652Sgjb 100282693Sgjb # Set to non-empty value to disable checkout of doc/ and/or ports/. 101282693Sgjb # Disabling ports/ checkout also forces NODOC to be set. 102282693Sgjb NODOC= 103282693Sgjb NOPORTS= 104259079Sgjb 105301280Sgarga # Set to non-empty value to disable distributing source tree. 106301280Sgarga NOSRC= 107301280Sgarga 108282693Sgjb # Set to non-empty value to build dvd1.iso as part of the release. 109282693Sgjb WITH_DVD= 110282693Sgjb WITH_COMPRESSED_IMAGES= 111272414Sgjb 112282693Sgjb # Set to non-empty value to build virtual machine images as part of 113282693Sgjb # the release. 114282693Sgjb WITH_VMIMAGES= 115282693Sgjb WITH_COMPRESSED_VMIMAGES= 116282693Sgjb XZ_THREADS=0 117277458Sgjb 118282693Sgjb # Set to non-empty value to build virtual machine images for various 119282693Sgjb # cloud providers as part of the release. 120282693Sgjb WITH_CLOUDWARE= 121251652Sgjb 122282693Sgjb return 0 123282693Sgjb} # env_setup() 124282693Sgjb 125282693Sgjb# env_check(): Perform sanity tests on the build environment, such as ensuring 126282693Sgjb# files/directories exist, as well as adding backwards-compatibility hacks if 127282693Sgjb# necessary. This is called unconditionally, and overrides the defaults set 128282693Sgjb# in env_setup() if '-c <release.conf>' is specified. 129282693Sgjbenv_check() { 130282693Sgjb chroot_build_release_cmd="chroot_build_release" 131282693Sgjb # Fix for backwards-compatibility with release.conf that does not have 132282693Sgjb # the trailing '/'. 133282693Sgjb case ${SVNROOT} in 134282693Sgjb *svn*) 135282693Sgjb SVNROOT="${SVNROOT}/" 136282693Sgjb ;; 137282693Sgjb *) 138282693Sgjb ;; 139251652Sgjb esac 140251652Sgjb 141282693Sgjb # Prefix the branches with the SVNROOT for the full checkout URL. 142282693Sgjb SRCBRANCH="${SVNROOT}${SRCBRANCH}" 143282693Sgjb DOCBRANCH="${SVNROOT}${DOCBRANCH}" 144282693Sgjb PORTBRANCH="${SVNROOT}${PORTBRANCH}" 145262862Sgjb 146282693Sgjb if [ -n "${EMBEDDEDBUILD}" ]; then 147282693Sgjb WITH_DVD= 148282693Sgjb WITH_COMPRESSED_IMAGES= 149282693Sgjb NODOC=yes 150282693Sgjb case ${EMBEDDED_TARGET}:${EMBEDDED_TARGET_ARCH} in 151282693Sgjb arm:armv6) 152282693Sgjb chroot_build_release_cmd="chroot_arm_armv6_build_release" 153282693Sgjb ;; 154282693Sgjb *) 155282693Sgjb esac 156282693Sgjb fi 157262499Sgjb 158282693Sgjb # If PORTS is set and NODOC is unset, force NODOC=yes because the ports 159282693Sgjb # tree is required to build the documentation set. 160282693Sgjb if [ -n "${NOPORTS}" ] && [ -z "${NODOC}" ]; then 161282693Sgjb echo "*** NOTICE: Setting NODOC=1 since ports tree is required" 162282693Sgjb echo " and NOPORTS is set." 163282693Sgjb NODOC=yes 164282693Sgjb fi 165262810Sgjb 166301280Sgarga # If NOSRC, NOPORTS and/or NODOC are unset, they must not pass to make 167301280Sgarga # as variables. The release makefile verifies definedness of the 168282693Sgjb # NOPORTS/NODOC variables instead of their values. 169301280Sgarga SRCDOCPORTS= 170282693Sgjb if [ -n "${NOPORTS}" ]; then 171301280Sgarga SRCDOCPORTS="NOPORTS=yes" 172282693Sgjb fi 173282693Sgjb if [ -n "${NODOC}" ]; then 174301280Sgarga SRCDOCPORTS="${SRCDOCPORTS}${SRCDOCPORTS:+ }NODOC=yes" 175282693Sgjb fi 176301280Sgarga if [ -n "${NOSRC}" ]; then 177301280Sgarga SRCDOCPORTS="${SRCDOCPORTS}${SRCDOCPORTS:+ }NOSRC=yes" 178301280Sgarga fi 179252846Sgjb 180282693Sgjb # The aggregated build-time flags based upon variables defined within 181282693Sgjb # this file, unless overridden by release.conf. In most cases, these 182282693Sgjb # will not need to be changed. 183282693Sgjb CONF_FILES="__MAKE_CONF=${MAKE_CONF} SRCCONF=${SRC_CONF}" 184282693Sgjb if [ -n "${TARGET}" ] && [ -n "${TARGET_ARCH}" ]; then 185282693Sgjb ARCH_FLAGS="TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}" 186282693Sgjb else 187282693Sgjb ARCH_FLAGS= 188282693Sgjb fi 189282693Sgjb # Force src checkout if configured 190282693Sgjb FORCE_SRC_KEY= 191282693Sgjb if [ -n "${SRC_FORCE_CHECKOUT}" ]; then 192282693Sgjb FORCE_SRC_KEY="--force" 193282693Sgjb fi 194252846Sgjb 195282693Sgjb if [ -z "${CHROOTDIR}" ]; then 196282693Sgjb echo "Please set CHROOTDIR." 197282693Sgjb exit 1 198282693Sgjb fi 199251652Sgjb 200282693Sgjb if [ $(id -u) -ne 0 ]; then 201282693Sgjb echo "Needs to be run as root." 202282693Sgjb exit 1 203282693Sgjb fi 204251652Sgjb 205282693Sgjb CHROOT_MAKEENV="${CHROOT_MAKEENV} \ 206282693Sgjb MAKEOBJDIRPREFIX=${CHROOTDIR}/tmp/obj" 207282693Sgjb CHROOT_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${CONF_FILES}" 208282693Sgjb CHROOT_IMAKEFLAGS="${CONF_FILES}" 209282693Sgjb CHROOT_DMAKEFLAGS="${CONF_FILES}" 210282693Sgjb RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} \ 211282693Sgjb ${CONF_FILES}" 212282693Sgjb RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} \ 213282693Sgjb KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}" 214282693Sgjb RELEASE_RMAKEFLAGS="${ARCH_FLAGS} \ 215301280Sgarga KERNCONF=\"${KERNEL}\" ${CONF_FILES} ${SRCDOCPORTS} \ 216282693Sgjb WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES} \ 217282693Sgjb WITH_CLOUDWARE=${WITH_CLOUDWARE} XZ_THREADS=${XZ_THREADS}" 218251652Sgjb 219282693Sgjb return 0 220282693Sgjb} # env_check() 221251652Sgjb 222282693Sgjb# chroot_setup(): Prepare the build chroot environment for the release build. 223282693Sgjbchroot_setup() { 224282693Sgjb load_chroot_env 225282693Sgjb mkdir -p ${CHROOTDIR}/usr 226251652Sgjb 227282693Sgjb if [ -z "${SRC_UPDATE_SKIP}" ]; then 228282693Sgjb ${VCSCMD} ${FORCE_SRC_KEY} ${SRCBRANCH} ${CHROOTDIR}/usr/src 229282693Sgjb fi 230282693Sgjb if [ -z "${NODOC}" ] && [ -z "${DOC_UPDATE_SKIP}" ]; then 231282693Sgjb ${VCSCMD} ${DOCBRANCH} ${CHROOTDIR}/usr/doc 232282693Sgjb fi 233282693Sgjb if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then 234282693Sgjb ${VCSCMD} ${PORTBRANCH} ${CHROOTDIR}/usr/ports 235282693Sgjb fi 236251652Sgjb 237282693Sgjb if [ -z "${CHROOTBUILD_SKIP}" ]; then 238282693Sgjb cd ${CHROOTDIR}/usr/src 239282693Sgjb env ${CHROOT_MAKEENV} make ${CHROOT_WMAKEFLAGS} buildworld 240282693Sgjb env ${CHROOT_MAKEENV} make ${CHROOT_IMAKEFLAGS} installworld \ 241282693Sgjb DESTDIR=${CHROOTDIR} 242282693Sgjb env ${CHROOT_MAKEENV} make ${CHROOT_DMAKEFLAGS} distribution \ 243282693Sgjb DESTDIR=${CHROOTDIR} 244282693Sgjb fi 245251652Sgjb 246282693Sgjb return 0 247282693Sgjb} # chroot_setup() 248251652Sgjb 249282693Sgjb# extra_chroot_setup(): Prepare anything additional within the build 250282693Sgjb# necessary for the release build. 251282693Sgjbextra_chroot_setup() { 252282693Sgjb mkdir -p ${CHROOTDIR}/dev 253282693Sgjb mount -t devfs devfs ${CHROOTDIR}/dev 254282693Sgjb [ -e /etc/resolv.conf ] && cp /etc/resolv.conf \ 255282693Sgjb ${CHROOTDIR}/etc/resolv.conf 256282693Sgjb # Run ldconfig(8) in the chroot directory so /var/run/ld-elf*.so.hints 257282693Sgjb # is created. This is needed by ports-mgmt/pkg. 258282693Sgjb eval chroot ${CHROOTDIR} /etc/rc.d/ldconfig forcerestart 259259955Sgjb 260282693Sgjb # If MAKE_CONF and/or SRC_CONF are set and not character devices 261282693Sgjb # (/dev/null), copy them to the chroot. 262282693Sgjb if [ -e ${MAKE_CONF} ] && [ ! -c ${MAKE_CONF} ]; then 263282693Sgjb mkdir -p ${CHROOTDIR}/$(dirname ${MAKE_CONF}) 264282693Sgjb cp ${MAKE_CONF} ${CHROOTDIR}/${MAKE_CONF} 265282693Sgjb fi 266282693Sgjb if [ -e ${SRC_CONF} ] && [ ! -c ${SRC_CONF} ]; then 267282693Sgjb mkdir -p ${CHROOTDIR}/$(dirname ${SRC_CONF}) 268282693Sgjb cp ${SRC_CONF} ${CHROOTDIR}/${SRC_CONF} 269282693Sgjb fi 270282693Sgjb 271282693Sgjb if [ -d ${CHROOTDIR}/usr/ports ]; then 272282693Sgjb # Trick the ports 'run-autotools-fixup' target to do the right 273282693Sgjb # thing. 274282693Sgjb _OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U) 275282693Sgjb REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION) 276282693Sgjb BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH) 277282693Sgjb UNAME_r=${REVISION}-${BRANCH} 278282693Sgjb if [ -d ${CHROOTDIR}/usr/doc ] && [ -z "${NODOC}" ]; then 279282693Sgjb PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes" 280282693Sgjb PBUILD_FLAGS="${PBUILD_FLAGS} UNAME_r=${UNAME_r}" 281282693Sgjb PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}" 282282693Sgjb chroot ${CHROOTDIR} make -C /usr/ports/textproc/docproj \ 283282693Sgjb ${PBUILD_FLAGS} OPTIONS_UNSET="FOP IGOR" \ 284293452Sgjb FORCE_PKG_REGISTER=1 \ 285282693Sgjb install clean distclean 286282693Sgjb fi 287282693Sgjb fi 288282693Sgjb 289282693Sgjb if [ ! -z "${EMBEDDEDPORTS}" ]; then 290304015Sgjb _OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U) 291304015Sgjb REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION) 292304015Sgjb BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH) 293304015Sgjb PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes" 294304015Sgjb PBUILD_FLAGS="${PBUILD_FLAGS} UNAME_r=${UNAME_r}" 295304015Sgjb PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}" 296282693Sgjb for _PORT in ${EMBEDDEDPORTS}; do 297282693Sgjb eval chroot ${CHROOTDIR} make -C /usr/ports/${_PORT} \ 298304015Sgjb FORCE_PKG_REGISTER=1 ${PBUILD_FLAGS} install clean distclean 299282693Sgjb done 300282693Sgjb fi 301282693Sgjb 302282500Sgjb buildenv_setup 303282693Sgjb 304282693Sgjb return 0 305282693Sgjb} # extra_chroot_setup() 306282693Sgjb 307282693Sgjb# chroot_build_target(): Build the userland and kernel for the build target. 308282693Sgjbchroot_build_target() { 309269639Sgjb load_target_env 310282693Sgjb if [ ! -z "${EMBEDDEDBUILD}" ]; then 311282693Sgjb RELEASE_WMAKEFLAGS="${RELEASE_WMAKEFLAGS} \ 312282693Sgjb TARGET=${EMBEDDED_TARGET} \ 313282693Sgjb TARGET_ARCH=${EMBEDDED_TARGET_ARCH}" 314282693Sgjb RELEASE_KMAKEFLAGS="${RELEASE_KMAKEFLAGS} \ 315282693Sgjb TARGET=${EMBEDDED_TARGET} \ 316282693Sgjb TARGET_ARCH=${EMBEDDED_TARGET_ARCH}" 317262810Sgjb fi 318282693Sgjb eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld 319282693Sgjb eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel 320262810Sgjb 321282693Sgjb return 0 322282693Sgjb} # chroot_build_target 323257641Sgjb 324282693Sgjb# chroot_build_release(): Invoke the 'make release' target. 325282693Sgjbchroot_build_release() { 326282693Sgjb load_target_env 327288345Sgjb if [ ! -z "${WITH_VMIMAGES}" ]; then 328288345Sgjb if [ -z "${VMFORMATS}" ]; then 329288345Sgjb VMFORMATS="$(eval chroot ${CHROOTDIR} \ 330288345Sgjb make -C /usr/src/release -V VMFORMATS)" 331288345Sgjb fi 332288345Sgjb if [ -z "${VMSIZE}" ]; then 333288345Sgjb VMSIZE="$(eval chroot ${CHROOTDIR} \ 334288345Sgjb make -C /usr/src/release -V VMSIZE)" 335288345Sgjb fi 336288347Sgjb RELEASE_RMAKEFLAGS="${RELEASE_RMAKEFLAGS} \ 337288347Sgjb VMFORMATS=\"${VMFORMATS}\" VMSIZE=${VMSIZE}" 338288345Sgjb fi 339282693Sgjb eval chroot ${CHROOTDIR} make -C /usr/src/release \ 340282693Sgjb ${RELEASE_RMAKEFLAGS} release 341282693Sgjb eval chroot ${CHROOTDIR} make -C /usr/src/release \ 342282693Sgjb ${RELEASE_RMAKEFLAGS} install DESTDIR=/R \ 343282693Sgjb WITH_COMPRESSED_IMAGES=${WITH_COMPRESSED_IMAGES} \ 344282693Sgjb WITH_COMPRESSED_VMIMAGES=${WITH_COMPRESSED_VMIMAGES} 345282693Sgjb 346282693Sgjb return 0 347282693Sgjb} # chroot_build_release() 348282693Sgjb 349282693Sgjb# chroot_arm_armv6_build_release(): Create arm/armv6 SD card image. 350282693Sgjbchroot_arm_armv6_build_release() { 351282693Sgjb load_target_env 352282693Sgjb eval chroot ${CHROOTDIR} make -C /usr/src/release obj 353282693Sgjb if [ -e "${RELENGDIR}/tools/${EMBEDDED_TARGET}.subr" ]; then 354282693Sgjb . "${RELENGDIR}/tools/${EMBEDDED_TARGET}.subr" 355251652Sgjb fi 356282693Sgjb [ ! -z "${RELEASECONF}" ] && . "${RELEASECONF}" 357282693Sgjb WORLDDIR="$(eval chroot ${CHROOTDIR} make -C /usr/src/release -V WORLDDIR)" 358282693Sgjb OBJDIR="$(eval chroot ${CHROOTDIR} make -C /usr/src/release -V .OBJDIR)" 359282693Sgjb DESTDIR="${OBJDIR}/${KERNEL}" 360282693Sgjb IMGBASE="${CHROOTDIR}/${OBJDIR}/${KERNEL}.img" 361282693Sgjb OSRELEASE="$(eval chroot ${CHROOTDIR} make -C /usr/src/release \ 362282693Sgjb TARGET=${EMBEDDED_TARGET} TARGET_ARCH=${EMBEDDED_TARGET_ARCH} \ 363282693Sgjb -V OSRELEASE)" 364282693Sgjb chroot ${CHROOTDIR} mkdir -p ${DESTDIR} 365282693Sgjb chroot ${CHROOTDIR} truncate -s ${IMAGE_SIZE} ${IMGBASE##${CHROOTDIR}} 366282693Sgjb export mddev=$(chroot ${CHROOTDIR} \ 367282693Sgjb mdconfig -f ${IMGBASE##${CHROOTDIR}} ${MD_ARGS}) 368282693Sgjb arm_create_disk 369282693Sgjb arm_install_base 370282693Sgjb arm_install_uboot 371282693Sgjb mdconfig -d -u ${mddev} 372282693Sgjb chroot ${CHROOTDIR} rmdir ${DESTDIR} 373282693Sgjb mv ${IMGBASE} ${CHROOTDIR}/${OBJDIR}/${OSRELEASE}-${KERNEL}.img 374282693Sgjb chroot ${CHROOTDIR} mkdir -p /R 375282693Sgjb chroot ${CHROOTDIR} cp -p ${OBJDIR}/${OSRELEASE}-${KERNEL}.img \ 376282693Sgjb /R/${OSRELEASE}-${KERNEL}.img 377282693Sgjb chroot ${CHROOTDIR} xz -T ${XZ_THREADS} /R/${OSRELEASE}-${KERNEL}.img 378289337Sgjb cd ${CHROOTDIR}/R && sha512 ${OSRELEASE}* \ 379289337Sgjb > CHECKSUM.SHA512 380282693Sgjb cd ${CHROOTDIR}/R && sha256 ${OSRELEASE}* \ 381282693Sgjb > CHECKSUM.SHA256 382252101Sgjb 383282693Sgjb return 0 384282693Sgjb} # chroot_arm_armv6_build_release() 385282693Sgjb 386282693Sgjb# main(): Start here. 387282693Sgjbmain() { 388282693Sgjb set -e # Everything must succeed 389282693Sgjb env_setup 390282693Sgjb while getopts c: opt; do 391282693Sgjb case ${opt} in 392282693Sgjb c) 393282693Sgjb RELEASECONF="${OPTARG}" 394282693Sgjb ;; 395282693Sgjb \?) 396282693Sgjb usage 397282693Sgjb ;; 398282693Sgjb esac 399282693Sgjb done 400282693Sgjb shift $(($OPTIND - 1)) 401282693Sgjb if [ ! -z "${RELEASECONF}" ]; then 402282693Sgjb if [ -e "${RELEASECONF}" ]; then 403282693Sgjb . ${RELEASECONF} 404282693Sgjb else 405282693Sgjb echo "Nonexistent configuration file: ${RELEASECONF}" 406282693Sgjb echo "Using default build environment." 407282693Sgjb fi 408282693Sgjb fi 409282693Sgjb env_check 410282693Sgjb trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit 411282693Sgjb chroot_setup 412282693Sgjb extra_chroot_setup 413282693Sgjb chroot_build_target 414282693Sgjb ${chroot_build_release_cmd} 415282693Sgjb 416282693Sgjb return 0 417282693Sgjb} # main() 418282693Sgjb 419282693Sgjbmain "${@}" 420