Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Jun 2005 15:44:40 +0400
From:      Sergey Matveychuk <sem@FreeBSD.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        marcus@FreeBSD.org
Subject:   ports/82316: [PATCH] devel/portlint: prevent use options before bsd.port.pre.mk included
Message-ID:  <E1DisnY-0002ru-WB@fog.mbrd.ru>
Resent-Message-ID: <200506161150.j5GBoJFA058212@freefall.freebsd.org>

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

>Number:         82316
>Category:       ports
>Synopsis:       [PATCH] devel/portlint: prevent use options before bsd.port.pre.mk included
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 16 11:50:18 GMT 2005
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1DisnY-0002ru-WB>