Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Dec 2010 13:32:57 GMT
From:      Ganael Laplanche <martymac@FreeBSD.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/152804: Add USE_SRC and ONLY_FOR_*VER to bsd.port.mk
Message-ID:  <201012031332.oB3DWvfX060599@red.freebsd.org>
Resent-Message-ID: <201012031340.oB3De91A030075@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         152804
>Category:       ports
>Synopsis:       Add USE_SRC and ONLY_FOR_*VER to bsd.port.mk
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 03 13:40:09 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Ganael Laplanche
>Release:        9.0-CURRENT
>Organization:
http://contribs.martymac.org
>Environment:
FreeBSD laptop.martymac.org 9.0-CURRENT FreeBSD 9.0-CURRENT #12 r213828: Thu Oct 14 14:49:56 UTC 2010     martymac@laptop.martymac.org:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
As proposed on ports@, here is a patch that provides a check for the presence of kernel sources when building a port. This check can be activated by defining :

- USE_SRC : to be set to "yes" or a space-separated list of files to check under ${SRC_BASE}
- SRC_BASE : by default /usr/src if ${USE_SRC} is set

A standard message is then displayed if kernel sources are missing.

Several ports that check for the presence of kernel sources also often check for a specific version of FreeBSD, so the patch also provides :

ONLY_FOR_MINVER / ONLY_FOR_MINVER_REASON : the minimal version of
FreeBSD required to build the port, and a given reason (if any)

ONLY_FOR_MAXVER / ONLY_FOR_MAXVER_REASON : the maximal version of
FreeBSD required to build the port, and a given reason (if any)

Those variables will help us avoid duplicating the same kind of checks
again and again in our ports tree, as well as providing standard error messages.

Finally, find here :

http://people.freebsd.org/~martymac/patches/20101203-patch-uhso-kmod.txt

an example that shows how those variables could be used
(comms/uhso-kmod). Note that in this example, a change of behaviour is
introduced : the port will now refuse to build if OSVERSION > 800500,
while it was only displaying a warning in the previous version. This
patch to hso-kmod is *not* to be committed, but just a showcase.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- bsd.port.mk.orig	2010-12-02 17:55:40.325016866 +0000
+++ bsd.port.mk	2010-12-03 07:24:21.494950196 +0000
@@ -222,6 +222,17 @@
 #				- Set this instead of ONLY_FOR_ARCHS if the given port
 #				  fetches and installs compiled i386 binaries.
 #
+# ONLY_FOR_MINVER
+#				- Only build port if ${OSVERSION} is superior or equal
+#				  to this value.
+# ONLY_FOR_MINVER_REASON
+#				- Reason why it's only for ${ONLY_FOR_MINVER}
+# ONLY_FOR_MAXVER
+#				- Only build port if ${OSVERSION} is inferior or equal
+#				  to this value.
+# ONLY_FOR_MAXVER_REASON
+#				- Reason why it's only for ${ONLY_FOR_MAXVER}
+#
 # Dependency checking.  Use these if your port requires another port
 # not in the list below.  (Default: empty.)
 #
@@ -295,6 +306,14 @@
 #                         passed to the compiler by setting DEBUG_FLAGS. It is
 #                         set to "-g" at default.
 #
+##
+# USE_SRC		- If set, this port needs kernel sources to build.
+#				  If set to "yes", presence of ${SRC_BASE}/sys/Makefile
+#				  is checked. If set to a space-separated list of files,
+#				  presence of those files under ${SRC_BASE}/ is checked.
+# SRC_BASE		- Set to the base directory of your kernel sources
+#				  Default: /usr/src
+##
 # USE_BZIP2		- If set, this port tarballs use bzip2, not gzip, for
 #				  compression.
 # USE_XZ		- If set, this port tarballs use xz (or lzma)
@@ -1388,6 +1407,21 @@
 WWWDIR?=		${PREFIX}/www/${PORTNAME}
 ETCDIR?=		${PREFIX}/etc/${PORTNAME}
 
+.if defined(USE_SRC)
+SRC_BASE?=	/usr/src
+. if ${USE_SRC:L} == "yes"
+_SRC_CHECK_FILES=	sys/Makefile
+. else
+_SRC_CHECK_FILES=	${USE_SRC}
+.endif
+
+.for file in ${_SRC_CHECK_FILES}
+. if !defined(${IGNORE}) && !exists(${SRC_BASE}/${file})
+IGNORE=	requires kernel source files
+. endif
+.endfor
+.endif # defined(USE_SRC)
+
 .if defined(USE_LINUX_RPM)
 .include "${PORTSDIR}/Mk/bsd.linux-rpm.mk"
 .endif
@@ -3252,6 +3286,25 @@
 
 .endif
 
+# Check for minimum and maximum version compatibility
+.if defined(ONLY_FOR_MINVER)
+. if ${OSVERSION} < ${ONLY_FOR_MINVER}
+IGNORE=	requires FreeBSD ${ONLY_FOR_MINVER:C/([0-9]+)([0-9])[0-9]{4}/\1.\2/} or later
+.  if defined(ONLY_FOR_MINVER_REASON)
+IGNORE+= (${ONLY_FOR_MINVER_REASON})
+.  endif
+. endif
+.endif
+
+.if defined(ONLY_FOR_MAXVER)
+. if ${OSVERSION} > ${ONLY_FOR_MAXVER}
+IGNORE=	requires FreeBSD ${ONLY_FOR_MAXVER:C/([0-9]+)([0-9])[0-9]{4}/\1.\2/} or earlier
+.  if defined(ONLY_FOR_MAXVER_REASON)
+IGNORE+= (${ONLY_FOR_MAXVER_REASON})
+.  endif
+. endif
+.endif
+
 # Check the user interaction and legal issues
 .if !defined(NO_IGNORE)
 .if (defined(IS_INTERACTIVE) && defined(BATCH))


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012031332.oB3DWvfX060599>