2011-03-11 16:58:21 +00:00
|
|
|
#!/bin/sh
|
2013-06-12 12:38:12 +00:00
|
|
|
#-
|
|
|
|
# Copyright (c) 2011 Nathan Whitehorn
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
# SUCH DAMAGE.
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
2011-03-11 16:58:21 +00:00
|
|
|
|
|
|
|
# generate-release.sh: check out source trees, and build release components with
|
2011-03-13 15:08:06 +00:00
|
|
|
# totally clean, fresh trees.
|
2011-03-11 16:58:21 +00:00
|
|
|
#
|
2013-02-03 10:26:24 +00:00
|
|
|
# Usage: generate-release.sh svn-branch[@revision] scratch-dir
|
2011-03-11 16:58:21 +00:00
|
|
|
#
|
|
|
|
# Environment variables:
|
2013-02-03 10:26:24 +00:00
|
|
|
# SVNROOTBASE: SVN base URL to FreeBSD repository (svn://svn.freebsd.org)
|
|
|
|
# SVNROOTSRC: URL to FreeBSD src tree (${SVNROOTBASE}/base)
|
|
|
|
# SVNROOTDOC: URL to FreeBSD doc tree (${SVNROOTBASE}/doc)
|
|
|
|
# SVNROOTPORTS:URL to FreeBSD ports tree (${SVNROOTBASE}/ports)
|
|
|
|
# BRANCHSRC: branch name of src (svn-branch[@revision])
|
|
|
|
# BRANCHDOC: branch name of doc (head)
|
|
|
|
# BRANCHPORTS: branch name of ports (head)
|
|
|
|
# WORLD_FLAGS: optional flags to pass to buildworld (e.g. -j)
|
|
|
|
# KERNEL_FLAGS: optional flags to pass to buildkernel (e.g. -j)
|
2011-03-11 16:58:21 +00:00
|
|
|
#
|
|
|
|
|
2012-01-14 09:57:13 +00:00
|
|
|
usage()
|
|
|
|
{
|
2013-02-03 10:26:24 +00:00
|
|
|
echo "Usage: $0 svn-branch[@revision] scratch-dir" 2>&1
|
2012-09-26 18:04:16 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2012-01-14 09:57:13 +00:00
|
|
|
if [ $# -lt 2 ]; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
2013-02-03 10:26:24 +00:00
|
|
|
: ${SVNROOTBASE:=svn://svn.freebsd.org}
|
|
|
|
: ${SVNROOTSRC:=${SVNROOTBASE}/base}
|
|
|
|
: ${SVNROOTDOC:=${SVNROOTBASE}/doc}
|
|
|
|
: ${SVNROOTPORTS:=${SVNROOTBASE}/ports}
|
|
|
|
: ${SVNROOT:=${SVNROOTSRC}} # for backward compatibility
|
|
|
|
: ${SVN_CMD:=/usr/local/bin/svn}
|
|
|
|
BRANCHSRC=$1
|
|
|
|
: ${BRANCHDOC:=head}
|
|
|
|
: ${BRANCHPORTS:=head}
|
|
|
|
: ${WORLD_FLAGS:=${MAKE_FLAGS}}
|
|
|
|
: ${KERNEL_FLAGS:=${MAKE_FLAGS}}
|
|
|
|
: ${CHROOTDIR:=$2}
|
|
|
|
|
|
|
|
if [ ! -r "${CHROOTDIR}" ]; then
|
|
|
|
echo "${CHROOTDIR}: scratch dir not found."
|
2012-09-26 18:04:16 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-02-03 10:26:24 +00:00
|
|
|
CHROOT_CMD="/usr/sbin/chroot ${CHROOTDIR}"
|
|
|
|
case ${TARGET} in
|
|
|
|
"") ;;
|
|
|
|
*) SETENV_TARGET="TARGET=$TARGET" ;;
|
2012-01-14 14:43:22 +00:00
|
|
|
esac
|
2013-02-03 10:26:24 +00:00
|
|
|
case ${TARGET_ARCH} in
|
|
|
|
"") ;;
|
|
|
|
*) SETENV_TARGET_ARCH="TARGET_ARCH=$TARGET_ARCH" ;;
|
|
|
|
esac
|
|
|
|
SETENV="env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin"
|
|
|
|
CROSSENV="${SETENV_TARGET} ${SETENV_TARGET_ARCH}"
|
|
|
|
WMAKE="make -C /usr/src ${WORLD_FLAGS}"
|
|
|
|
NWMAKE="${WMAKE} __MAKE_CONF=/dev/null SRCCONF=/dev/null"
|
|
|
|
KMAKE="make -C /usr/src ${KERNEL_FLAGS}"
|
|
|
|
RMAKE="make -C /usr/src/release"
|
2012-01-14 14:43:22 +00:00
|
|
|
|
2013-02-03 10:26:24 +00:00
|
|
|
if [ $(id -u) -ne 0 ]; then
|
|
|
|
echo "Needs to be run as root."
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-09-26 18:04:16 +00:00
|
|
|
|
2013-02-03 10:26:24 +00:00
|
|
|
set -e # Everything must succeed
|
2012-09-26 18:04:16 +00:00
|
|
|
|
2013-02-03 10:26:24 +00:00
|
|
|
mkdir -p ${CHROOTDIR}/usr/src
|
|
|
|
${SVN_CMD} co ${SVNROOT}/${BRANCHSRC} ${CHROOTDIR}/usr/src
|
|
|
|
${SVN_CMD} co ${SVNROOTDOC}/${BRANCHDOC} ${CHROOTDIR}/usr/doc
|
|
|
|
${SVN_CMD} co ${SVNROOTPORTS}/${BRANCHPORTS} ${CHROOTDIR}/usr/ports
|
2012-09-26 18:04:16 +00:00
|
|
|
|
2013-02-03 10:26:24 +00:00
|
|
|
${SETENV} ${NWMAKE} -C ${CHROOTDIR}/usr/src ${WORLD_FLAGS} buildworld
|
|
|
|
${SETENV} ${NWMAKE} -C ${CHROOTDIR}/usr/src installworld distribution DESTDIR=${CHROOTDIR}
|
|
|
|
mount -t devfs devfs ${CHROOTDIR}/dev
|
|
|
|
trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit
|
2012-09-26 18:04:16 +00:00
|
|
|
|
2013-02-03 10:26:24 +00:00
|
|
|
if [ -d ${CHROOTDIR}/usr/doc ]; then
|
|
|
|
cp /etc/resolv.conf ${CHROOTDIR}/etc/resolv.conf
|
2011-03-13 15:08:06 +00:00
|
|
|
|
2012-09-17 02:23:03 +00:00
|
|
|
# Install docproj to build release documentation
|
2013-02-03 10:26:24 +00:00
|
|
|
${CHROOT_CMD} /bin/sh -c \
|
|
|
|
'make -C /usr/ports/textproc/docproj \
|
|
|
|
BATCH=yes \
|
|
|
|
WITHOUT_SVN=yes \
|
|
|
|
WITHOUT_JADETEX=yes \
|
|
|
|
WITHOUT_X11=yes \
|
|
|
|
WITHOUT_PYTHON=yes \
|
|
|
|
install'
|
2011-03-11 16:58:21 +00:00
|
|
|
fi
|
2011-03-13 15:08:06 +00:00
|
|
|
|
2013-02-03 10:26:24 +00:00
|
|
|
${CHROOT_CMD} ${SETENV} ${CROSSENV} ${WMAKE} buildworld
|
|
|
|
${CHROOT_CMD} ${SETENV} ${CROSSENV} ${KMAKE} buildkernel
|
|
|
|
${CHROOT_CMD} ${SETENV} ${CROSSENV} ${RMAKE} release
|
|
|
|
${CHROOT_CMD} ${SETENV} ${CROSSENV} ${RMAKE} install DESTDIR=/R
|