aboutsummaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorlinimon <linimon@FreeBSD.org>2010-06-26 07:01:05 +0800
committerlinimon <linimon@FreeBSD.org>2010-06-26 07:01:05 +0800
commitffdb228ba0218c3d6a0442260d65c9eba3f639f4 (patch)
treef52a2c875fe0dc485f6a866463b2b36631212cb0 /Tools
parent8158c95a07255b101ac376b162bf2e927b4a31c1 (diff)
downloadfreebsd-ports-gnome-ffdb228ba0218c3d6a0442260d65c9eba3f639f4.tar.gz
freebsd-ports-gnome-ffdb228ba0218c3d6a0442260d65c9eba3f639f4.tar.zst
freebsd-ports-gnome-ffdb228ba0218c3d6a0442260d65c9eba3f639f4.zip
Generalize the packge building scripts to be able to be run on more than
one 'head' node, rather than just pointyhat itself. Constants are factored out into installation-specific files known as portbuild/conf/server.conf and portbuild/conf/client.conf. There is only one server.conf file. Individual <arch> directories may have their own client.conf files, or may symlink to ../conf/client.conf. Several bugs are fixed and improvements are made: - the definitions for valid 'arch' and 'branch' are moved to server.conf. - the script is broken up into two pieces; the old 'buildenv' name becomes the server side, and 'buildenv.client' is add for the client side. 'buildenv.common' is what you would expect. This makes the separation of what controls what more clear. - the concept of 'branch base' is generalized to match any pattern postpended with '-', thus removing the specialness of '-exp'. More work remains on the other scripts to best take advantage of this. - as a corollary, 'branch' can also have '.' in it, e.g., 6.4. - the obsolete variables FTP_PASSIVE_MODE, PKGZIPCMD, and X_WINDOW_SYSTEM are removed. Feature safe: yes
Diffstat (limited to 'Tools')
-rw-r--r--Tools/portbuild/scripts/buildenv156
1 files changed, 80 insertions, 76 deletions
diff --git a/Tools/portbuild/scripts/buildenv b/Tools/portbuild/scripts/buildenv
index 07af4dc54f68..5cba30d99068 100644
--- a/Tools/portbuild/scripts/buildenv
+++ b/Tools/portbuild/scripts/buildenv
@@ -1,36 +1,44 @@
#!/bin/sh
+# $FreeBSD$
#
-# Set up the build variables which are used by a given build
-#
-# Code fragment used by other scripts for commonality
+# Set up the build variables which are used by a given build. Some
+# of the code here is common to both clients and server; some is
+# particular to each.
+
+# get the major branch number. only used on server side.
+get_branch_base() {
+ strippedbranch=${1%%[-\.]*}
+ branchbase=`echo $strippedbranch | grep ${SRC_BRANCHES_PATTERN}`
+ echo ${branchbase}
+}
+# only used on server side
validate_env() {
arch=$1
branch=$2
- case ${arch} in
- amd64|i386|ia64|powerpc|sparc64)
- continue
- ;;
- *)
- echo "Invalid arch: ${arch}"
- return 1
- ;;
- esac
-
- case ${branch} in
- 6|6-exp|7|7-exp|8|8-exp|9|9-exp)
- continue
- ;;
- *)
- echo "Invalid branch: ${branch}"
- return 1
- ;;
- esac
+ valid_arch=0
+ for i in ${SUPPORTED_ARCHS}; do
+ if [ ${i} = ${arch} ]; then
+ valid_arch=1
+ break
+ fi
+ done
+ if [ $valid_arch = 0 ]; then
+ echo "Invalid arch: ${arch}"
+ return 1
+ fi
+
+ branchbase=$(get_branch_base ${branch})
+ if [ -z "${branchbase}" ]; then
+ echo "Invalid branch: ${branch}"
+ return 1
+ fi
return 0
}
+# only used on server side
resolve() {
pb=$1
arch=$2
@@ -38,7 +46,7 @@ resolve() {
buildid=$4
# Resolve a possibly symlinked buildid (e.g. "latest") to the
- # underlying directory
+ # underlying physical directory
pbab=${pb}/${arch}/${branch}
builddir=${pbab}/builds/${buildid}/
@@ -54,12 +62,17 @@ resolve() {
echo ${buildid}
}
+#
+# establish commonly-used environment variables (server-side)
+#
buildenv () {
pb=$1
arch=$2
branch=$3
builddir=$4
+ buildenv.common ${pb} ${arch}
+
# Have to use realpath because 'make index' doesn't deal with
# symlinks in PORTSDIR - kk 020311
if [ -d ${builddir}/ports/ ]; then
@@ -73,74 +86,65 @@ buildenv () {
export SRCBASE=/nonexistent
fi
- if [ -f ${SRCBASE}/sys/sys/param.h ]; then
- export OSVERSION=$(awk '/^#define __FreeBSD_version/ {print $3}' < ${SRCBASE}/sys/sys/param.h)
- fi
- if [ -f ${SRCBASE}/sys/conf/newvers.sh ]; then
- export OSREL=$(awk 'BEGIN {FS="\""}; /^REVISION/ {print $2}' < ${SRCBASE}/sys/conf/newvers.sh)
- export BRANCH=$(awk 'BEGIN {FS="\""}; /^BRANCH/ {print $2}' < ${SRCBASE}/sys/conf/newvers.sh)
- fi
-
- case "x$branch" in
- x6)
- export INDEXFILE=INDEX-6
- ;;
- x6-exp)
- export INDEXFILE=INDEX-6
- ;;
- x7)
- export INDEXFILE=INDEX-7
- ;;
- x7-exp)
- export INDEXFILE=INDEX-7
- ;;
- x8)
- export INDEXFILE=INDEX-8
- ;;
- x8-exp)
- export INDEXFILE=INDEX-8
- ;;
- x9)
- export INDEXFILE=INDEX-9
- ;;
- x9-exp)
- export INDEXFILE=INDEX-9
- ;;
- *)
- echo "buildenv: invalid branch"
- exit 1
- ;;
- esac
-
- export ARCH=${arch}
- export MACHINE_ARCH=${arch}
-
+ # override things destined for bsd.port.mk
export LOCALBASE=/usr/local
+ export DISTDIR=${builddir}/distfiles
+ export PACKAGES=${builddir}/packages
export PKGSUFFIX=.tbz
- export PKGZIPCMD=bzip2
- export X_WINDOW_SYSTEM=xorg
- #export USA_RESIDENT=yes
- export SRCPREFIX=${SRCBASE} #XXX Which one is canonical?
+ # now unused:
+ # export PKGZIPCMD=bzip2
+
+ branchbase=$(get_branch_base ${branch})
+ if [ -z "${branchbase}" ]; then
+ echo "buildenv: invalid branch ${branch}"
+ exit 1
+ else
+ export INDEXFILE=INDEX-${branchbase}
+ fi
+ # probably only used in mkbindist
export __MAKE_CONF=${pb}/${arch}/make.conf
+}
- export DISTDIR=${builddir}/distfiles
- export PACKAGES=${builddir}/packages
+#
+# establish commonly-used environment variables (client-side)
+#
+buildenv.client() {
+ pb=$1
+ arch=$2
+
+ buildenv.common ${pb} ${arch}
# Don't pick up host OPTIONS
export PORT_DBDIR=/nonexistent
+ # manually override results of uname(1)
export UNAME_m=${ARCH}
export UNAME_n=freebsd.org
export UNAME_p=${ARCH}
export UNAME_r=${OSREL}-${BRANCH}
export UNAME_s=FreeBSD
- export UNAME_v="FreeBSD ${OSREL}-${BRANCH} #0: $(date) kris@freebsd.org:/usr/src/sys/magic/kernel/path"
+ export UNAME_v="FreeBSD ${OSREL}-${BRANCH} #0: $(date) portmgr@freebsd.org:/usr/src/sys/magic/kernel/path"
+}
- export BATCH=1
- export PACKAGE_BUILDING=1
+#
+# establish commonly-used environment variables (common to clients and server)
+#
+buildenv.common() {
+ pb=$1
+ arch=$2
- export FTP_PASSIVE_MODE=yes
- #export FETCH_BEFORE_ARGS=-vvv
+ if [ -f ${SRCBASE}/sys/sys/param.h ]; then
+ export OSVERSION=$(awk '/^#define __FreeBSD_version/ {print $3}' < ${SRCBASE}/sys/sys/param.h)
+ fi
+ if [ -f ${SRCBASE}/sys/conf/newvers.sh ]; then
+ export OSREL=$(awk 'BEGIN {FS="\""}; /^REVISION/ {print $2}' < ${SRCBASE}/sys/conf/newvers.sh)
+ export BRANCH=$(awk 'BEGIN {FS="\""}; /^BRANCH/ {print $2}' < ${SRCBASE}/sys/conf/newvers.sh)
+ fi
+
+ export ARCH=${arch}
+ export MACHINE_ARCH=${arch}
+
+ export BATCH=1
}