From edwin@mavetju.org  Sun Mar 19 08:59:51 2006
Return-Path: <edwin@mavetju.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0942016A401
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 19 Mar 2006 08:59:51 +0000 (UTC)
	(envelope-from edwin@mavetju.org)
Received: from mail2out.barnet.com.au (mail2out.barnet.com.au [202.83.176.14])
	by mx1.FreeBSD.org (Postfix) with ESMTP id E788343D6E
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 19 Mar 2006 08:59:41 +0000 (GMT)
	(envelope-from edwin@mavetju.org)
Received: by mail2out.barnet.com.au (Postfix, from userid 27)
	id 3E1237073BC; Sun, 19 Mar 2006 19:59:39 +1100 (EST)
Received: from mail2-auth.barnet.com.au (mail2.barnet.com.au [202.83.176.13])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "*.barnet.com.au", Issuer "BarNet Root Certificate Authority" (verified OK))
	by mail2.barnet.com.au (Postfix) with ESMTP id C91B57073BA
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 19 Mar 2006 19:59:38 +1100 (EST)
Received: from k7.mavetju (edwin-3.int.barnet.com.au [10.10.12.2])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client did not present a certificate)
	by mail2-auth.barnet.com.au (Postfix) with ESMTP id DCC177073B3
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 19 Mar 2006 19:59:37 +1100 (EST)
Received: by k7.mavetju (Postfix, from userid 1001)
	id D265F272; Sun, 19 Mar 2006 19:59:36 +1100 (EST)
Message-Id: <20060319085936.D265F272@k7.mavetju>
Date: Sun, 19 Mar 2006 19:59:36 +1100 (EST)
From: Edwin Groothuis <edwin@mavetju.org>
Reply-To: Edwin Groothuis <edwin@mavetju.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] bsd.port.mk - introduce ONLY_FOR_OSVERSION as _REASON
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         94680
>Category:       ports
>Synopsis:       [patch] bsd.port.mk - introduce ONLY_FOR_OSVERSION as _REASON
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    portmgr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 19 09:00:29 GMT 2006
>Closed-Date:    Wed May 16 22:26:37 GMT 2007
>Last-Modified:  Wed May 16 22:26:37 GMT 2007
>Originator:     Edwin Groothuis
>Release:        FreeBSD 6.0-RELEASE i386
>Organization:
-
>Environment:
System: FreeBSD k7.mavetju 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Thu Nov 3 09:36:13 UTC 2005 root@x64.samsco.home:/usr/obj/usr/src/sys/GENERIC i386


>Description:

A lot of ports have this in them:

    .include <bsd.port.pre.mk>
    .if ${OSVERSION} < 400000
    BROKEN=         Not supported for pre-4.0 FreeBSD
    .endif

    .include <bsd.port.pre.mk>
    .if ${OSVERSION} >= 502126
    BROKEN=         Does not compile on FreeBSD >= 5.x
    .endif

    .include <bsd.port.pre.mk>
    .if ${OSVERSION} < 500000
    BROKEN=         Does not compile on 4.x (port and dependencies need recent C++ compiler)
    .endif

It would be much more in the trend of ONLY_FOR_ARCHS and NOT_FOR_ARCHS
to use normal messages for this:

    ONLY_FOR_OSVERSION=	400000+
    ONLY_FOR_OSVERSION_REASON=	Not supported for pre-4.0 FreeBSD

    ONLY_FOR_OSVERSION=	-502126
    ONLY_FOR_OSVERSION_REASON=	Does not compile on FreeBSD >= 5.x

    ONLY_FOR_OSVERSION=	500000+
    ONLY_FOR_OSVERSION_REASON=	Does not compile on 4.x (port and dependencies need recent C++ compiler)


Which would give as output:

===>  rdist-6.1.5_2 is marked as broken: Not supported for pre-4.0 FreeBSD.
===>  rdist-6.1.5_2 is marked as broken: Requires OSVERSION 400000 or later: Not supported for pre-4.0 FreeBSD.

===>  nil-000928_2 is marked as broken: Does not compile on FreeBSD >= 5.x
===>  nil-000928_2 is marked as broken: Requires OSVERSION 502126 or earlier: Does not compile on FreeBSD >= 5.x.

===>  vamos-0.5.5_2 is marked as broken: "Does not compile on 4.x (port and dependencies need recent C++ compiler)".
===>  vamos-0.5.5_2 is marked as broken: Requires OSVERSION 500000 or later: Does not compile on 4.x (port and dependencies need recent C++ compiler).

It will also give other scripts (freshports, linimons portlist) the
possibilities to give better data back to the users, and people who
want to do sweeps of the port collection a chance to find ports
which can be cleaned up ("port requires FreeBSD < 4") or checks
which can be removed ("Port requires FreeBSD > 4")

>How-To-Repeat:



>Fix:


--- bsd.port.mk.orig	Sun Mar 19 17:18:28 2006
+++ bsd.port.mk	Sun Mar 19 19:40:06 2006
@@ -208,6 +208,17 @@
 #				- Only build ports if ${ARCH} matches one of these.
 # NOT_FOR_ARCHS	- Only build ports if ${ARCH} doesn't match one of these.
 #
+# Set these if your port only builds on certain OS versions.
+#
+# ONLY_FOR_OSVERSION
+#				- An OS version, optionally prefixed or suffixed a "+" to
+#				  indicate "up to" or "from". OS Versions are the six digits
+#				  versions like ${OSVERSION}). For example: 500000+ requires
+#				  OSVERSION 500000 or higher, +499999 requires OSVERSION to
+#				  be lower than 500000.
+# ONLY_FOR_OSVERSION_REASON
+#				- An optional reason why it doesn't work on this OSVERSION.
+#
 # Dependency checking.  Use these if your port requires another port
 # not in the list below.  (Default: empty.)
 #
@@ -2824,6 +2835,37 @@
 IGNORE=		does not run on ${NOT_FOR_ARCHS},
 .endif
 IGNORE+=	and you are running ${ARCH}
+.endif
+
+#
+# Compare OSVERSION with the values in ${ONLY_FOR_OSVERSION}
+#
+.if defined(ONLY_FOR_OSVERSION)
+
+# Strip any leading or following characters
+_ONLY_FOR_OSVERSION:=${ONLY_FOR_OSVERSION}
+_ONLY_FOR_OSVERSION:=${_ONLY_FOR_OSVERSION:S/+//}
+_ONLY_FOR_OSVERSION:=${_ONLY_FOR_OSVERSION:S/-//}
+.if ${ONLY_FOR_OSVERSION} == "-${_ONLY_FOR_OSVERSION}"
+_OKAYEARLIER=	true
+.endif
+.if ${ONLY_FOR_OSVERSION} == "${_ONLY_FOR_OSVERSION}+"
+_OKAYLATER=	true
+.endif
+
+# Check versions
+.if !defined(_OKAYEARLIER) && !defined(_OKAYLATER) && ( ${OSVERSION} != ${_ONLY_FOR_OSVERSION} )
+BROKEN=	Requires OSVERSION ${_ONLY_FOR_OSVERSION}: ${ONLY_FOR_OSVERSION_REASON}
+.endif
+.if defined(_OKAYEARLIER) && ${OSVERSION} > ${_ONLY_FOR_OSVERSION}
+BROKEN=	Requires OSVERSION ${_ONLY_FOR_OSVERSION} or earlier: ${ONLY_FOR_OSVERSION_REASON}
+.endif
+.if defined(_OKAYLATER) && ${OSVERSION} < ${_ONLY_FOR_OSVERSION}
+BROKEN=	Requires OSVERSION ${_ONLY_FOR_OSVERSION} or later: ${ONLY_FOR_OSVERSION_REASON}
+.endif
+
+.undef _OKAYEARLIER
+.undef _OKAYLATER
 .endif
 
 .if !defined(NO_IGNORE)
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->portmgr 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Sun Mar 19 09:01:35 UTC 2006 
Responsible-Changed-Why:  
OVer to maintainerins 

http://www.freebsd.org/cgi/query-pr.cgi?pr=94680 
State-Changed-From-To: open->feedback 
State-Changed-By: kris 
State-Changed-When: Sat May 6 01:55:00 UTC 2006 
State-Changed-Why:  
I have a couple of issues with this patch: 

* It is necessarily quite complex, but it still doesn't handle all the 
possibilities.  It is quite common for ports to have multiple 
different BROKEN strings in different ARCH/OSVERSION combinations, 
but that can't be handled by this change. 

* Neither does it handle OSVERSION ranges, also quite common 

* Also, I don't think it should be called ONLY_FOR_* since 
ONLY_FOR_ARCHS sets IGNORE but this sets BROKEN, and they have 
different semantics. 

On balance I don't think this is a problem that needs to be solved, 
given the complications; .if ... BROKEN .endif constructs are simple 
and (by definition) flexible enough to handle all possibilities, 
despite requiring a few extra keystrokes. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=94680 
State-Changed-From-To: feedback->closed 
State-Changed-By: linimon 
State-Changed-When: Wed May 16 22:23:43 UTC 2007 
State-Changed-Why:  
I think I'm going to go ahead and agree with kris' analysis that the code 
doesn't cover all the wierd cases that the ports Makefile seem to need, 
and thus we're adding complexity but not completely solving the problem. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=94680 
>Unformatted:
