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 262810 2014-03-05 23:17:53Z 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"
44RELENGDIR="$(realpath $(dirname $(basename ${0})))"
45
46# The default version control system command to obtain the sources.
47VCSCMD="svn checkout"
48
49# The default svn checkout server, and svn branches for src/, doc/,
50# and ports/.
51SVNROOT="svn://svn.FreeBSD.org/"
52SRCBRANCH="base/head@rHEAD"
53DOCBRANCH="doc/head@rHEAD"
54PORTBRANCH="ports/head@rHEAD"
55
56# Set for embedded device builds.
57EMBEDDEDBUILD=
58
59# Sometimes one needs to checkout src with --force svn option.
60# If custom kernel configs copied to src tree before checkout, e.g.
61SRC_FORCE_CHECKOUT=
62
63# The default make.conf and src.conf to use. Set to /dev/null
64# by default to avoid polluting the chroot(8) environment with
65# non-default settings.
66MAKE_CONF="/dev/null"
--- 40 unchanged lines hidden (view full) ---
107done
108shift $(($OPTIND - 1))
109
110# Prefix the branches with the SVNROOT for the full checkout URL.
111SRCBRANCH="${SVNROOT}${SRCBRANCH}"
112DOCBRANCH="${SVNROOT}${DOCBRANCH}"
113PORTBRANCH="${SVNROOT}${PORTBRANCH}"
114
115if [ -n "${EMBEDDEDBUILD}" ]; then
116 if [ -z "${XDEV}" ] || [ -z "${XDEV_ARCH}" ]; then
117 echo "ERROR: XDEV and XDEV_ARCH must be set in ${RELEASECONF}."
118 exit 1
119 fi
120 WITH_DVD=
121 NODOC=yes
122fi
123
124# If PORTS is set and NODOC is unset, force NODOC=yes because the ports tree
125# is required to build the documentation set.
126if [ -n "${NOPORTS}" ] && [ -z "${NODOC}" ]; then
127 echo "*** NOTICE: Setting NODOC=1 since ports tree is required"
128 echo " and NOPORTS is set."
129 NODOC=yes
130fi
131
132# If NOPORTS and/or NODOC are unset, they must not pass to make as variables.
133# The release makefile verifies definedness of NOPORTS/NODOC variables
134# instead of their values.
135DOCPORTS=
136if [ -n "${NOPORTS}" ]; then
137 DOCPORTS="NOPORTS=yes "
138fi
139if [ -n "${NODOC}" ]; then
140 DOCPORTS="${DOCPORTS}NODOC=yes"
141fi
142
143# The aggregated build-time flags based upon variables defined within
144# this file, unless overridden by release.conf. In most cases, these
145# will not need to be changed.
146CONF_FILES="__MAKE_CONF=${MAKE_CONF} SRCCONF=${SRC_CONF}"
147if [ -n "${TARGET}" ] && [ -n "${TARGET_ARCH}" ]; then
148 ARCH_FLAGS="TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}"
149else
150 ARCH_FLAGS=
151fi
152CHROOT_MAKEENV="${CHROOT_MAKEENV} MAKEOBJDIRPREFIX=${CHROOTDIR}/tmp/obj"
153CHROOT_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${CONF_FILES}"
154CHROOT_IMAKEFLAGS="${CONF_FILES}"
155CHROOT_DMAKEFLAGS="${CONF_FILES}"
156RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} ${CONF_FILES}"
157RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}"
158RELEASE_RMAKEFLAGS="${ARCH_FLAGS} KERNCONF=\"${KERNEL}\" ${CONF_FILES} \
159 ${DOCPORTS} WITH_DVD=${WITH_DVD}"
160
161# Force src checkout if configured
162FORCE_SRC_KEY=
163if [ -n "${SRC_FORCE_CHECKOUT}" ]; then
164 FORCE_SRC_KEY="--force"
165fi
166
167if [ -z "${CHROOTDIR}" ]; then
168 echo "Please set CHROOTDIR."
169 exit 1
170fi
171
172if [ $(id -u) -ne 0 ]; then
173 echo "Needs to be run as root."
174 exit 1
175fi
176
177set -e # Everything must succeed
178
179mkdir -p ${CHROOTDIR}/usr
180
181${VCSCMD} ${FORCE_SRC_KEY} ${SRCBRANCH} ${CHROOTDIR}/usr/src
182if [ -z "${NODOC}" ]; then
183 ${VCSCMD} ${DOCBRANCH} ${CHROOTDIR}/usr/doc
184fi
185if [ -z "${NOPORTS}" ]; then
186 ${VCSCMD} ${PORTBRANCH} ${CHROOTDIR}/usr/ports
187fi
188
189if [ -z "${CHROOTBUILD_SKIP}" ]; then
190 cd ${CHROOTDIR}/usr/src
191 env ${CHROOT_MAKEENV} make ${CHROOT_WMAKEFLAGS} buildworld
192 env ${CHROOT_MAKEENV} make ${CHROOT_IMAKEFLAGS} installworld \
193 DESTDIR=${CHROOTDIR}
194 env ${CHROOT_MAKEENV} make ${CHROOT_DMAKEFLAGS} distribution \
195 DESTDIR=${CHROOTDIR}
196fi
197mount -t devfs devfs ${CHROOTDIR}/dev
198cp /etc/resolv.conf ${CHROOTDIR}/etc/resolv.conf
199trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit
200
201# If MAKE_CONF and/or SRC_CONF are set and not character devices (/dev/null),
202# copy them to the chroot.
203if [ -e ${MAKE_CONF} ] && [ ! -c ${MAKE_CONF} ]; then
204 mkdir -p ${CHROOTDIR}/$(dirname ${MAKE_CONF})
205 cp ${MAKE_CONF} ${CHROOTDIR}/${MAKE_CONF}
206fi
207if [ -e ${SRC_CONF} ] && [ ! -c ${SRC_CONF} ]; then
208 mkdir -p ${CHROOTDIR}/$(dirname ${SRC_CONF})
209 cp ${SRC_CONF} ${CHROOTDIR}/${SRC_CONF}
210fi
211
212# Embedded builds do not use the 'make release' target.
213if [ -n "${EMBEDDEDBUILD}" ]; then
214 # If a crochet configuration file exists in *this* checkout of
215 # release/, copy it to the /tmp/external directory within the chroot.
216 # This allows building embedded releases without relying on updated
217 # scripts and/or configurations to exist in the branch being built.
218 if [ -e ${RELENGDIR}/tools/${XDEV}/crochet-${KERNEL}.conf ] && \
219 [ -e ${RELENGDIR}/${XDEV}/release.sh ]; then
220 mkdir -p ${CHROOTDIR}/tmp/external/${XDEV}/
221 cp ${RELENGDIR}/tools/${XDEV}/crochet-${KERNEL}.conf \
222 ${CHROOTDIR}/tmp/external/${XDEV}/crochet-${KERNEL}.conf
223 /bin/sh ${RELENGDIR}/${XDEV}/release.sh
224 fi
225 # If the script does not exist for this architecture, exit.
226 # This probably should be checked earlier, but allowing the rest
227 # of the build process to get this far will at least set up the
228 # chroot environment for testing.
229 exit 0
230else
231 # Not embedded.
232 continue
233fi
234
235if [ -d ${CHROOTDIR}/usr/ports ]; then
236 # Run ldconfig(8) in the chroot directory so /var/run/ld-elf*.so.hints
237 # is created. This is needed by ports-mgmt/pkg.
238 chroot ${CHROOTDIR} /etc/rc.d/ldconfig forcerestart
239
240 ## Trick the ports 'run-autotools-fixup' target to do the right thing.
241 _OSVERSION=$(sysctl -n kern.osreldate)
242 if [ -d ${CHROOTDIR}/usr/doc ] && [ -z "${NODOC}" ]; then
243 PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes"
244 PBUILD_FLAGS="${PBUILD_FLAGS}"
245 chroot ${CHROOTDIR} make -C /usr/ports/textproc/docproj \
246 ${PBUILD_FLAGS} OPTIONS_UNSET="FOP IGOR" install clean distclean
247 fi
248fi
249
250eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld
251eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel
252eval chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
253 release
254eval chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
255 install DESTDIR=/R
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 262810 2014-03-05 23:17:53Z 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"
44RELENGDIR="$(realpath $(dirname $(basename ${0})))"
45
46# The default version control system command to obtain the sources.
47VCSCMD="svn checkout"
48
49# The default svn checkout server, and svn branches for src/, doc/,
50# and ports/.
51SVNROOT="svn://svn.FreeBSD.org/"
52SRCBRANCH="base/head@rHEAD"
53DOCBRANCH="doc/head@rHEAD"
54PORTBRANCH="ports/head@rHEAD"
55
56# Set for embedded device builds.
57EMBEDDEDBUILD=
58
59# Sometimes one needs to checkout src with --force svn option.
60# If custom kernel configs copied to src tree before checkout, e.g.
61SRC_FORCE_CHECKOUT=
62
63# The default make.conf and src.conf to use. Set to /dev/null
64# by default to avoid polluting the chroot(8) environment with
65# non-default settings.
66MAKE_CONF="/dev/null"
--- 40 unchanged lines hidden (view full) ---
107done
108shift $(($OPTIND - 1))
109
110# Prefix the branches with the SVNROOT for the full checkout URL.
111SRCBRANCH="${SVNROOT}${SRCBRANCH}"
112DOCBRANCH="${SVNROOT}${DOCBRANCH}"
113PORTBRANCH="${SVNROOT}${PORTBRANCH}"
114
115if [ -n "${EMBEDDEDBUILD}" ]; then
116 if [ -z "${XDEV}" ] || [ -z "${XDEV_ARCH}" ]; then
117 echo "ERROR: XDEV and XDEV_ARCH must be set in ${RELEASECONF}."
118 exit 1
119 fi
120 WITH_DVD=
121 NODOC=yes
122fi
123
124# If PORTS is set and NODOC is unset, force NODOC=yes because the ports tree
125# is required to build the documentation set.
126if [ -n "${NOPORTS}" ] && [ -z "${NODOC}" ]; then
127 echo "*** NOTICE: Setting NODOC=1 since ports tree is required"
128 echo " and NOPORTS is set."
129 NODOC=yes
130fi
131
132# If NOPORTS and/or NODOC are unset, they must not pass to make as variables.
133# The release makefile verifies definedness of NOPORTS/NODOC variables
134# instead of their values.
135DOCPORTS=
136if [ -n "${NOPORTS}" ]; then
137 DOCPORTS="NOPORTS=yes "
138fi
139if [ -n "${NODOC}" ]; then
140 DOCPORTS="${DOCPORTS}NODOC=yes"
141fi
142
143# The aggregated build-time flags based upon variables defined within
144# this file, unless overridden by release.conf. In most cases, these
145# will not need to be changed.
146CONF_FILES="__MAKE_CONF=${MAKE_CONF} SRCCONF=${SRC_CONF}"
147if [ -n "${TARGET}" ] && [ -n "${TARGET_ARCH}" ]; then
148 ARCH_FLAGS="TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}"
149else
150 ARCH_FLAGS=
151fi
152CHROOT_MAKEENV="${CHROOT_MAKEENV} MAKEOBJDIRPREFIX=${CHROOTDIR}/tmp/obj"
153CHROOT_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${CONF_FILES}"
154CHROOT_IMAKEFLAGS="${CONF_FILES}"
155CHROOT_DMAKEFLAGS="${CONF_FILES}"
156RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} ${CONF_FILES}"
157RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}"
158RELEASE_RMAKEFLAGS="${ARCH_FLAGS} KERNCONF=\"${KERNEL}\" ${CONF_FILES} \
159 ${DOCPORTS} WITH_DVD=${WITH_DVD}"
160
161# Force src checkout if configured
162FORCE_SRC_KEY=
163if [ -n "${SRC_FORCE_CHECKOUT}" ]; then
164 FORCE_SRC_KEY="--force"
165fi
166
167if [ -z "${CHROOTDIR}" ]; then
168 echo "Please set CHROOTDIR."
169 exit 1
170fi
171
172if [ $(id -u) -ne 0 ]; then
173 echo "Needs to be run as root."
174 exit 1
175fi
176
177set -e # Everything must succeed
178
179mkdir -p ${CHROOTDIR}/usr
180
181${VCSCMD} ${FORCE_SRC_KEY} ${SRCBRANCH} ${CHROOTDIR}/usr/src
182if [ -z "${NODOC}" ]; then
183 ${VCSCMD} ${DOCBRANCH} ${CHROOTDIR}/usr/doc
184fi
185if [ -z "${NOPORTS}" ]; then
186 ${VCSCMD} ${PORTBRANCH} ${CHROOTDIR}/usr/ports
187fi
188
189if [ -z "${CHROOTBUILD_SKIP}" ]; then
190 cd ${CHROOTDIR}/usr/src
191 env ${CHROOT_MAKEENV} make ${CHROOT_WMAKEFLAGS} buildworld
192 env ${CHROOT_MAKEENV} make ${CHROOT_IMAKEFLAGS} installworld \
193 DESTDIR=${CHROOTDIR}
194 env ${CHROOT_MAKEENV} make ${CHROOT_DMAKEFLAGS} distribution \
195 DESTDIR=${CHROOTDIR}
196fi
197mount -t devfs devfs ${CHROOTDIR}/dev
198cp /etc/resolv.conf ${CHROOTDIR}/etc/resolv.conf
199trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit
200
201# If MAKE_CONF and/or SRC_CONF are set and not character devices (/dev/null),
202# copy them to the chroot.
203if [ -e ${MAKE_CONF} ] && [ ! -c ${MAKE_CONF} ]; then
204 mkdir -p ${CHROOTDIR}/$(dirname ${MAKE_CONF})
205 cp ${MAKE_CONF} ${CHROOTDIR}/${MAKE_CONF}
206fi
207if [ -e ${SRC_CONF} ] && [ ! -c ${SRC_CONF} ]; then
208 mkdir -p ${CHROOTDIR}/$(dirname ${SRC_CONF})
209 cp ${SRC_CONF} ${CHROOTDIR}/${SRC_CONF}
210fi
211
212# Embedded builds do not use the 'make release' target.
213if [ -n "${EMBEDDEDBUILD}" ]; then
214 # If a crochet configuration file exists in *this* checkout of
215 # release/, copy it to the /tmp/external directory within the chroot.
216 # This allows building embedded releases without relying on updated
217 # scripts and/or configurations to exist in the branch being built.
218 if [ -e ${RELENGDIR}/tools/${XDEV}/crochet-${KERNEL}.conf ] && \
219 [ -e ${RELENGDIR}/${XDEV}/release.sh ]; then
220 mkdir -p ${CHROOTDIR}/tmp/external/${XDEV}/
221 cp ${RELENGDIR}/tools/${XDEV}/crochet-${KERNEL}.conf \
222 ${CHROOTDIR}/tmp/external/${XDEV}/crochet-${KERNEL}.conf
223 /bin/sh ${RELENGDIR}/${XDEV}/release.sh
224 fi
225 # If the script does not exist for this architecture, exit.
226 # This probably should be checked earlier, but allowing the rest
227 # of the build process to get this far will at least set up the
228 # chroot environment for testing.
229 exit 0
230else
231 # Not embedded.
232 continue
233fi
234
235if [ -d ${CHROOTDIR}/usr/ports ]; then
236 # Run ldconfig(8) in the chroot directory so /var/run/ld-elf*.so.hints
237 # is created. This is needed by ports-mgmt/pkg.
238 chroot ${CHROOTDIR} /etc/rc.d/ldconfig forcerestart
239
240 ## Trick the ports 'run-autotools-fixup' target to do the right thing.
241 _OSVERSION=$(sysctl -n kern.osreldate)
242 if [ -d ${CHROOTDIR}/usr/doc ] && [ -z "${NODOC}" ]; then
243 PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes"
244 PBUILD_FLAGS="${PBUILD_FLAGS}"
245 chroot ${CHROOTDIR} make -C /usr/ports/textproc/docproj \
246 ${PBUILD_FLAGS} OPTIONS_UNSET="FOP IGOR" install clean distclean
247 fi
248fi
249
250eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld
251eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel
252eval chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
253 release
254eval chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
255 install DESTDIR=/R