From owner-freebsd-ports-bugs@FreeBSD.ORG Fri Dec 3 13:40:10 2010 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 133D91065672 for ; Fri, 3 Dec 2010 13:40:10 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id C0AE28FC13 for ; Fri, 3 Dec 2010 13:40:09 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id oB3De9lq030076 for ; Fri, 3 Dec 2010 13:40:09 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id oB3De91A030075; Fri, 3 Dec 2010 13:40:09 GMT (envelope-from gnats) Resent-Date: Fri, 3 Dec 2010 13:40:09 GMT Resent-Message-Id: <201012031340.oB3De91A030075@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Ganael Laplanche Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA1001065673 for ; Fri, 3 Dec 2010 13:32:57 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (unknown [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id AC94C8FC16 for ; Fri, 3 Dec 2010 13:32:57 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id oB3DWvb2060600 for ; Fri, 3 Dec 2010 13:32:57 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id oB3DWvfX060599; Fri, 3 Dec 2010 13:32:57 GMT (envelope-from nobody) Message-Id: <201012031332.oB3DWvfX060599@red.freebsd.org> Date: Fri, 3 Dec 2010 13:32:57 GMT From: Ganael Laplanche To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/152804: Add USE_SRC and ONLY_FOR_*VER to bsd.port.mk X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Dec 2010 13:40:10 -0000 >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: