aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Drewery <bdrewery@FreeBSD.org>2014-09-30 16:22:05 +0000
committerBryan Drewery <bdrewery@FreeBSD.org>2014-09-30 16:22:05 +0000
commit9576bda6137e0b862682abb07840ea1da57f104b (patch)
tree7d8babfa14cfeff32d5fe0bcb1ca2735cecd0652
parent04b3cf366b9858a3f23aee1b6323bd40d4521871 (diff)
downloadports-9576bda6137e0b862682abb07840ea1da57f104b.tar.gz
ports-9576bda6137e0b862682abb07840ea1da57f104b.zip
If either of OSVERSION or UNAME_r is improperly set when building in a
jail/chroot, a number of unexpected errors can occur. 1. autotools fixup may not run when needed. This could be avoided by always running it [PR 177980, 177403]. 2. Not having UNAME_r set will cause many unknown errors. Many ports use OSREL (derived from UNAME_r) to determine the name of files. This is usually also due to the port build itself using uname -r to derive filenames or 'built for' messages. [PR 192449, 191943] Without having these sanity checks it is very easy for users to get into situations where "everything worked" until they touch a certain port that reads uname(1) output or OSVERSION. It has always been necessary to define all of the UNAME_ vars and OSVERSION (or have a proper sys/param.h present), but many users do not know this. Remove the fallback on the kernel for kern.osreldate as it easily gets the answer wrong. I have added sanity checks to ensure OSVERSION==OSREL==UNAME_r as these are the most critical vars to have set properly. Differential Revision: https://reviews.freebsd.org/D869 PR: 177980, 177403, 192449, 191943 Reviewed by: antoine, bapt, gjb With hat: portmgr
Notes
Notes: svn path=/head/; revision=369644
-rw-r--r--CHANGES30
-rw-r--r--Mk/bsd.port.mk17
2 files changed, 43 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index 720ee8336fb8..46d009758c89 100644
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,36 @@ in the release notes and/or placed into UPDATING.
All ports committers are allowed to commit to this file.
+20140930:
+AUTHOR: bdrewery@FreeBSD.org
+
+ Building ports in a chroot or jail have always required a particular
+ environment be setup. This was not clear though and the ports framework
+ did not enforce it. These requirements are:
+ 1. Either a SRC_BASE/sys/sys/param.h, or /usr/include/sys/param.h be
+ present with the __FreeBSD_version_ number of the target system,
+ or OSVERSION be set in the environment. Lack of these would fallback
+ on kern.osreldate before, which is no longer the case.
+ 2. UNAME_r,UNAME_v,UNAME_s all must be set for the target system.
+
+ Not having these values in sync will now cause the build to error until it is
+ resolved.
+
+ Setting these in the environment can be done via your own wrapper scripts,
+ or /etc/login.conf (along with cap_mkdb /etc/login.conf) or
+ via /etc/make.conf using appropriate values. Note that OSVERSION is redundant
+ if a proper param.h is in the environment:
+
+ OSVERSION+= 1100036
+ UNAME_ENV+= OSVERSION=${OSVERSION}
+ UNAME_ENV+= UNAME_s=FreeBSD
+ UNAME_ENV+= UNAME_r=11.0-CURRENT
+ UNAME_ENV+= UNAME_v="${UNAME_s} ${UNAME_r}"
+ .MAKEFLAGS: ${UNAME_ENV}
+ MAKE_ENV+= ${UNAME_ENV}
+ CONFIGURE_ENV+= ${UNAME_ENV}
+ SCRIPTS_ENV+= ${UNAME_ENV}
+
20140922:
AUTHOR: bapt@FreeBSD.org
diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index 06e8f3521332..1fc5d258ea9c 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -1186,10 +1186,10 @@ ARCH!= ${UNAME} -p
OPSYS!= ${UNAME} -s
.endif
+UNAMER!=${UNAME} -r
+
# Get the operating system revision
-.if !defined(OSREL)
-OSREL!= ${UNAME} -r | ${SED} -e 's/[-(].*//'
-.endif
+OSREL?= ${UNAMER:C/-.*//}
# Get __FreeBSD_version
.if !defined(OSVERSION)
@@ -1198,10 +1198,19 @@ OSVERSION!= ${AWK} '/^\#define[[:blank:]]__FreeBSD_version/ {print $$3}' < /usr/
.elif exists(${SRC_BASE}/sys/sys/param.h)
OSVERSION!= ${AWK} '/^\#define[[:blank:]]__FreeBSD_version/ {print $$3}' < ${SRC_BASE}/sys/sys/param.h
.else
-OSVERSION!= ${SYSCTL} -n kern.osreldate
+.error Unable to determine OS version. Either define OSVERSION, install /usr/include/sys/param.h or define SRC_BASE.
.endif
.endif
+# Convert OSVERSION to major release number
+_OSVERSION_MAJOR= ${OSVERSION:C/([0-9]?[0-9])([0-9][0-9])[0-9]{3}/\1/}
+# Sanity checks for chroot/jail building.
+.if ${_OSVERSION_MAJOR} != ${UNAMER:R}
+.error UNAME_r (${UNAMER}) and OSVERSION (${OSVERSION}) do not agree on major version number.
+.elif ${_OSVERSION_MAJOR} != ${OSREL:R}
+.error OSREL (${OSREL}) and OSVERSION (${OSVERSION}) do not agree on major version number.
+.endif
+
# Enable new xorg for FreeBSD versions after Radeon KMS was imported unless
# WITHOUT_NEW_XORG is set.
.if (${OSVERSION} >= 902510 && ${OSVERSION} < 1000000) || ${OSVERSION} >= 1000704