Deleted Added
sdiff udiff text old ( 262509 ) new ( 262810 )
full compact
1#!/bin/sh
2#-
3# Copyright (c) 2013, 2014 The FreeBSD Foundation
4# Copyright (c) 2013 Glen Barber
5# Copyright (c) 2011 Nathan Whitehorn
6# All rights reserved.
7#
8# Portions of this software were developed by Glen Barber

--- 19 unchanged lines hidden (view full) ---

28# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30# SUCH DAMAGE.
31#
32# release.sh: check out source trees, and build release components with
33# totally clean, fresh trees.
34# Based on release/generate-release.sh written by Nathan Whitehorn
35#
36# $FreeBSD: head/release/release.sh 262509 2014-02-26 01:06:41Z gjb $
37#
38
39PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
40export PATH
41
42# The directory within which the release will be built.
43CHROOTDIR="/scratch"
44
45# The default version control system command to obtain the sources.
46VCSCMD="svn checkout"
47
48# The default svn checkout server, and svn branches for src/, doc/,
49# and ports/.
50SVNROOT="svn://svn.FreeBSD.org/"
51SRCBRANCH="base/head@rHEAD"
52DOCBRANCH="doc/head@rHEAD"
53PORTBRANCH="ports/head@rHEAD"
54
55# Sometimes one needs to checkout src with --force svn option.
56# If custom kernel configs copied to src tree before checkout, e.g.
57SRC_FORCE_CHECKOUT=
58
59# The default make.conf and src.conf to use. Set to /dev/null
60# by default to avoid polluting the chroot(8) environment with
61# non-default settings.
62MAKE_CONF="/dev/null"

--- 40 unchanged lines hidden (view full) ---

103done
104shift $(($OPTIND - 1))
105
106# Prefix the branches with the SVNROOT for the full checkout URL.
107SRCBRANCH="${SVNROOT}${SRCBRANCH}"
108DOCBRANCH="${SVNROOT}${DOCBRANCH}"
109PORTBRANCH="${SVNROOT}${PORTBRANCH}"
110
111# If PORTS is set and NODOC is unset, force NODOC=yes because the ports tree
112# is required to build the documentation set.
113if [ "x${NOPORTS}" != "x" ] && [ "x${NODOC}" = "x" ]; then
114 echo "*** NOTICE: Setting NODOC=1 since ports tree is required"
115 echo " and NOPORTS is set."
116 NODOC=yes
117fi
118
119# If NOPORTS and/or NODOC are unset, they must not pass to make as variables.
120# The release makefile verifies definedness of NOPORTS/NODOC variables
121# instead of their values.
122DOCPORTS=
123if [ "x${NOPORTS}" != "x" ]; then
124 DOCPORTS="NOPORTS=yes "
125fi
126if [ "x${NODOC}" != "x" ]; then
127 DOCPORTS="${DOCPORTS}NODOC=yes"
128fi
129
130# The aggregated build-time flags based upon variables defined within
131# this file, unless overridden by release.conf. In most cases, these
132# will not need to be changed.
133CONF_FILES="__MAKE_CONF=${MAKE_CONF} SRCCONF=${SRC_CONF}"
134if [ "x${TARGET}" != "x" ] && [ "x${TARGET_ARCH}" != "x" ]; then
135 ARCH_FLAGS="TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}"
136else
137 ARCH_FLAGS=
138fi
139CHROOT_MAKEENV="MAKEOBJDIRPREFIX=${CHROOTDIR}/tmp/obj"
140CHROOT_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${CONF_FILES}"
141CHROOT_IMAKEFLAGS="${CONF_FILES}"
142CHROOT_DMAKEFLAGS="${CONF_FILES}"
143RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} ${CONF_FILES}"
144RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}"
145RELEASE_RMAKEFLAGS="${ARCH_FLAGS} KERNCONF=\"${KERNEL}\" ${CONF_FILES} \
146 ${DOCPORTS} WITH_DVD=${WITH_DVD}"
147
148# Force src checkout if configured
149FORCE_SRC_KEY=
150if [ "x${SRC_FORCE_CHECKOUT}" != "x" ]; then
151 FORCE_SRC_KEY="--force"
152fi
153
154if [ ! ${CHROOTDIR} ]; then
155 echo "Please set CHROOTDIR."
156 exit 1
157fi
158
159if [ $(id -u) -ne 0 ]; then
160 echo "Needs to be run as root."
161 exit 1
162fi
163
164set -e # Everything must succeed
165
166mkdir -p ${CHROOTDIR}/usr
167
168${VCSCMD} ${FORCE_SRC_KEY} ${SRCBRANCH} ${CHROOTDIR}/usr/src
169if [ "x${NODOC}" = "x" ]; then
170 ${VCSCMD} ${DOCBRANCH} ${CHROOTDIR}/usr/doc
171fi
172if [ "x${NOPORTS}" = "x" ]; then
173 ${VCSCMD} ${PORTBRANCH} ${CHROOTDIR}/usr/ports
174fi
175
176cd ${CHROOTDIR}/usr/src
177env ${CHROOT_MAKEENV} make ${CHROOT_WMAKEFLAGS} buildworld
178env ${CHROOT_MAKEENV} make ${CHROOT_IMAKEFLAGS} installworld \
179 DESTDIR=${CHROOTDIR}
180env ${CHROOT_MAKEENV} make ${CHROOT_DMAKEFLAGS} distribution \
181 DESTDIR=${CHROOTDIR}
182mount -t devfs devfs ${CHROOTDIR}/dev
183cp /etc/resolv.conf ${CHROOTDIR}/etc/resolv.conf
184trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit
185
186# If MAKE_CONF and/or SRC_CONF are set and not character devices (/dev/null),
187# copy them to the chroot.
188if [ -e ${MAKE_CONF} ] && [ ! -c ${MAKE_CONF} ]; then
189 mkdir -p ${CHROOTDIR}/$(dirname ${MAKE_CONF})
190 cp ${MAKE_CONF} ${CHROOTDIR}/${MAKE_CONF}
191fi
192if [ -e ${SRC_CONF} ] && [ ! -c ${SRC_CONF} ]; then
193 mkdir -p ${CHROOTDIR}/$(dirname ${SRC_CONF})
194 cp ${SRC_CONF} ${CHROOTDIR}/${SRC_CONF}
195fi
196
197if [ -d ${CHROOTDIR}/usr/ports ]; then
198 # Run ldconfig(8) in the chroot directory so /var/run/ld-elf*.so.hints
199 # is created. This is needed by ports-mgmt/pkg.
200 chroot ${CHROOTDIR} /etc/rc.d/ldconfig forcerestart
201
202 ## Trick the ports 'run-autotools-fixup' target to do the right thing.
203 _OSVERSION=$(sysctl -n kern.osreldate)
204 if [ -d ${CHROOTDIR}/usr/doc ] && [ "x${NODOC}" = "x" ]; then
205 PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes"
206 PBUILD_FLAGS="${PBUILD_FLAGS}"
207 chroot ${CHROOTDIR} make -C /usr/ports/textproc/docproj \
208 ${PBUILD_FLAGS} OPTIONS_UNSET="FOP IGOR" install clean distclean
209 fi
210fi
211
212if [ "x${RELSTRING}" = "x" ]; then
213 RELSTRING="$(chroot ${CHROOTDIR} uname -s)-${OSRELEASE}-${TARGET_ARCH}"
214fi
215
216eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld
217eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel
218eval chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
219 release RELSTRING=${RELSTRING}
220eval chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
221 install DESTDIR=/R RELSTRING=${RELSTRING}