pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc pkgtools/pkglint: Added checks for proper quoting of s...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/6d0c495f7857
branches:  trunk
changeset: 489060:6d0c495f7857
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Tue Feb 15 21:07:01 2005 +0000

description:
pkgtools/pkglint: Added checks for proper quoting of shell variables
($ vs. $$). Welcome to 4.05. Approved by wiz.

diffstat:

 doc/CHANGES                       |   3 +-
 pkgtools/pkglint/Makefile         |   4 +-
 pkgtools/pkglint/files/pkglint.pl |  41 +++++++++++++++++++++++---------------
 3 files changed, 29 insertions(+), 19 deletions(-)

diffs (114 lines):

diff -r 1087cbfe3605 -r 6d0c495f7857 doc/CHANGES
--- a/doc/CHANGES       Tue Feb 15 20:54:37 2005 +0000
+++ b/doc/CHANGES       Tue Feb 15 21:07:01 2005 +0000
@@ -1,4 +1,4 @@
-$NetBSD: CHANGES,v 1.9150 2005/02/15 20:54:37 rillig Exp $
+$NetBSD: CHANGES,v 1.9151 2005/02/15 21:07:01 rillig Exp $
 
 Changes to the packages collection and infrastructure in 2005:
 
@@ -886,3 +886,4 @@
        Updated awstats to 6.3nb4 [minskim 2005-02-15]
        Updated jabberd2 to 2.0s6nb1 [rillig 2005-02-15]
        Updated rcs to 5.7nb3 [rillig 2005-02-15]
+       Updated pkglint to 4.05 [rillig 2005-02-15]
diff -r 1087cbfe3605 -r 6d0c495f7857 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Tue Feb 15 20:54:37 2005 +0000
+++ b/pkgtools/pkglint/Makefile Tue Feb 15 21:07:01 2005 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.218 2005/02/14 22:14:48 cube Exp $
+# $NetBSD: Makefile,v 1.219 2005/02/15 21:07:01 rillig Exp $
 #
 
-DISTNAME=      pkglint-4.04
+DISTNAME=      pkglint-4.05
 CATEGORIES=    pkgtools devel
 MASTER_SITES=  # empty
 DISTFILES=     # empty
diff -r 1087cbfe3605 -r 6d0c495f7857 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Tue Feb 15 20:54:37 2005 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Tue Feb 15 21:07:01 2005 +0000
@@ -11,7 +11,7 @@
 # Freely redistributable.  Absolutely no warranty.
 #
 # From Id: portlint.pl,v 1.64 1998/02/28 02:34:05 itojun Exp
-# $NetBSD: pkglint.pl,v 1.129 2005/02/12 21:34:47 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.130 2005/02/15 21:07:01 rillig Exp $
 #
 # This version contains lots of changes necessary for NetBSD packages
 # done by Hubert Feyrer <hubertf%netbsd.org@localhost>,
@@ -1139,7 +1139,7 @@
        return $contents;
 }
 
-sub check_make_variable_definition($) {
+sub check_Makefile_vartype($) {
        my ($line) = @_;
        if ($line->text =~ qr"([A-Z_a-z0-9.]+)\s*(=|\?=|\+=)\s*(.*)") {
                my ($varname, $op, $value) = ($1, $2, $3);
@@ -1171,23 +1171,31 @@
        return true;
 }
 
-sub check_Makefile_variable_definitions($) {
-       my ($fname) = @_;
-       my ($lines) = load_file($fname);
-       if (!$lines) {
-               log_error($fname, NO_LINE_NUMBER, "Could not open");
-               return false;
-       } else {
-               foreach my $line (@$lines) {
-                       check_make_variable_definition($line);
+sub check_Makefile_variables($) {
+       my ($lines) = @_;
+
+       # Check variable name quoting
+       foreach my $line (@$lines) {
+               if ($line->text =~ qr"^[^#]*[^\$]\$(\w+)") {
+                       my ($varname) = ($1);
+                       log_warning($line->file, $line->lineno, "please write either \${$varname} or \$\$$varname instead of \$$varname.");
                }
        }
+
+       # Check variable types
+       if ($opt_warn_types) {
+               foreach my $line (@$lines) {
+                       check_Makefile_vartype($line);
+               }
+       }
+
        return true;
 }
 
 sub checkfile_Makefile($) {
        my ($file) = @_;
        my ($fname) = ("$opt_packagedir/$file");
+       my ($lines) = load_file($fname);
        my ($tmp, $rawwhole, $whole, $idx, @sections);
        my (@varnames) = ();
        my ($distfiles, $svrpkgname, $distname, $extractsufx) = ('', '', '', '', '');
@@ -1196,6 +1204,11 @@
        my ($includefile);
        my ($category);
 
+       if (!defined($lines)) {
+               log_error($fname, NO_LINE_NUMBER, "read error");
+               return false;
+       }
+
        if ($opt_packagedir eq ".") {
                $category = basename(dirname(cwd()));
        } else {
@@ -1976,11 +1989,7 @@
                        "discouraged. redefine \"do-$1\" instead.");
        }
 
-       if ($opt_warn_types) {
-               return check_Makefile_variable_definitions($fname);
-       } else {
-               return true;
-       }
+       return check_Makefile_variables($lines);
 }
 
 sub checkextra($$) {



Home | Main Index | Thread Index | Old Index