From sem@fog.mbrd.ru  Thu Jun 16 11:44:44 2005
Return-Path: <sem@fog.mbrd.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1CD6216A41C;
	Thu, 16 Jun 2005 11:44:44 +0000 (GMT)
	(envelope-from sem@fog.mbrd.ru)
Received: from fog.mbrd.ru (fog-mtu.mbrd.ru [195.34.35.73])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 9D67C43D1F;
	Thu, 16 Jun 2005 11:44:42 +0000 (GMT)
	(envelope-from sem@fog.mbrd.ru)
Received: from sem by fog.mbrd.ru with local (Exim 4.51 (FreeBSD))
	id 1DisnY-0002ru-WB; Thu, 16 Jun 2005 15:44:41 +0400
Message-Id: <E1DisnY-0002ru-WB@fog.mbrd.ru>
Date: Thu, 16 Jun 2005 15:44:40 +0400
From: Sergey Matveychuk <sem@FreeBSD.org>
Sender: Sergey Matveychuk <sem@fog.mbrd.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc: marcus@FreeBSD.org
Subject: [PATCH] devel/portlint: prevent use options before bsd.port.pre.mk included
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         82316
>Category:       ports
>Synopsis:       [PATCH] devel/portlint: prevent using options before bsd.port.pre.mk included
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    marcus
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 16 11:50:18 GMT 2005
>Closed-Date:    Sat Jul 02 20:35:41 GMT 2005
>Last-Modified:  Sat Jul 02 20:35:41 GMT 2005
>Originator:     Sergey Matveychuk
>Release:        FreeBSD 5.4-RELEASE i386
>Organization:
>Environment:
System: FreeBSD fog.mbrd.ru 5.4-RELEASE FreeBSD 5.4-RELEASE #5: Wed May 11 14:22:55 MSD 2005
>Description:
I often see a mistake when contributors try to check OPTIONS values
before bsd.port.pre.mk included.
The patch checks this situation and show a fatal error.
It works only when OPTIONS defined.

Port maintainer (marcus@FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 0.63
>How-To-Repeat:
>Fix:

--- portlint-2.7.2.patch begins here ---
Index: Makefile
===================================================================
RCS file: /home/pcvs/ports/devel/portlint/Makefile,v
retrieving revision 1.91
diff -u -u -r1.91 Makefile
--- Makefile	16 Apr 2005 19:01:15 -0000	1.91
+++ Makefile	16 Jun 2005 11:42:25 -0000
@@ -8,8 +8,7 @@
 #
 
 PORTNAME=	portlint
-PORTVERSION=	2.7.1
-PORTREVISION=	1
+PORTVERSION=	2.7.2
 CATEGORIES=	devel
 MASTER_SITES=	# none
 DISTFILES=	# none
Index: src/portlint.pl
===================================================================
RCS file: /home/pcvs/ports/devel/portlint/src/portlint.pl,v
retrieving revision 1.72
diff -u -u -r1.72 portlint.pl
--- src/portlint.pl	16 Apr 2005 19:01:15 -0000	1.72
+++ src/portlint.pl	16 Jun 2005 11:42:25 -0000
@@ -937,6 +937,7 @@
 	my $useindex = 0;
 	my %deprecated = ();
 	my %autocmdnames = ();
+	my $pre_mk_line=0;
 
 	open(IN, "< $file") || return 0;
 	$rawwhole = '';
@@ -1067,6 +1068,8 @@
 	#
 	pos($whole) = 0;
 	if ($whole =~ /^\.include\s+<bsd\.port\.pre\.mk>$/gm) {
+		# remember position
+		$pre_mk_line = &linenumber($`)+1;
 		print "OK: checking for USE_* used too late.\n" if ($verbose);
 		my @use_early = qw(
 			APACHE
@@ -1102,6 +1105,35 @@
 	}
 
 	#
+	# whole file: check OPTIONS
+	#
+	pos($whole) = 0;
+	print "OK: checking OPTIONS.\n" if ($verbose);
+	@oopt = ($makevar{OPTIONS} =~ /(\w+)\s+\".*?\"\s+\w+/sg);
+	while ($whole =~ /\n[^#\n]*?\(?\s*WITH(?:OUT)?_(\w+)\s*\)?/mg) {
+		push @mopt, $1;
+		my $lineno = &linenumber($`)+1;
+		&perror("FATAL: $file [$lineno]: option WITH(OUT)_$1 is used before ".
+			"including bsd.port.pre.mk.")
+		if(scalar(@oopt) && $lineno < $pre_mk_line);
+	}
+	foreach my $i (@oopt) {
+		if (!grep(/^$i$/, @mopt)) {
+			&perror("WARN: $file: $i is listed in OPTIONS, ".
+				"but neither WITH_$i nor WITHOUT_$i appears.");
+		}
+	}
+	foreach my $i (@mopt) {
+		next if ($i eq 'NLS'); # skip WITHOUT_NLS
+		if (!grep(/^$i$/, @oopt)) {
+			# XXX: disabled temporarily.
+			# OPTIONS is still "in flux"
+			#&perror("WARN: $file: WITH_$i or WITHOUT_$i appears, ".
+			#	"consider using OPTIONS macro.");
+		}
+	}
+
+	#
 	# whole file: USE_* as a user-settable option
 	#
 	print "OK: checking for USE_* as a user-settable option.\n" if ($verbose);
@@ -2396,26 +2428,6 @@
 			"defining USE_ANT");
 	}
 
-	# check OPTIONS
-	print "OK: checking OPTIONS.\n" if ($verbose);
-	@oopt = ($makevar{OPTIONS} =~ /(\w+)\s+\".*?\"\s+\w+/sg);
-	@mopt = ($tmp =~ /\(?\s*WITH(?:OUT)?_(\w+)\s*\)?/mg);
-	foreach my $i (@oopt) {
-		if (!grep(/^$i$/, @mopt)) {
-			&perror("WARN: $file: $i is listed in OPTIONS, ".
-				"but neither WITH_$i nor WITHOUT_$i appears.");
-		}
-	}
-	foreach my $i (@mopt) {
-		next if ($i eq 'NLS'); # skip WITHOUT_NLS
-		if (!grep(/^$i$/, @oopt)) {
-			# XXX: disabled temporarily.
-			# OPTIONS is still "in flux"
-			#&perror("WARN: $file: WITH_$i or WITHOUT_$i appears, ".
-			#	"consider using OPTIONS macro.");
-		}
-	}
-
 	1;
 }
 
--- portlint-2.7.2.patch ends here ---

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->marcus 
Responsible-Changed-By: sem 
Responsible-Changed-When: Thu Jun 16 11:51:32 GMT 2005 
Responsible-Changed-Why:  
Over to maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=82316 
State-Changed-From-To: open->closed 
State-Changed-By: marcus 
State-Changed-When: Sat Jul 2 20:35:30 GMT 2005 
State-Changed-Why:  
Committed, thanks! 

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