pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files Added support for SUBST_VARS.*.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/c8f87b80045f
branches:  trunk
changeset: 530948:c8f87b80045f
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Jul 15 22:13:46 2007 +0000

description:
Added support for SUBST_VARS.*.

diffstat:

 pkgtools/pkglint/files/pkglint.pl |  24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diffs (86 lines):

diff -r 3698199e4315 -r c8f87b80045f pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Sun Jul 15 22:11:03 2007 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Sun Jul 15 22:13:46 2007 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.pl,v 1.712 2007/07/10 15:27:57 joerg Exp $
+# $NetBSD: pkglint.pl,v 1.713 2007/07/15 22:13:46 rillig Exp $
 #
 
 # pkglint - static analyzer and checker for pkgsrc packages
@@ -1294,7 +1294,7 @@
 
 sub new($) {
        my ($class) = @_;
-       my ($self) = ([undef, undef, undef, undef, [], [], undef, undef]);
+       my ($self) = ([undef, undef, undef, undef, [], [], [], undef]);
        bless($self, $class);
        return $self;
 }
@@ -1304,19 +1304,21 @@
 sub subst_message($)           { return shift(@_)->[SUBST_MESSAGE]; }
 sub subst_files($)             { return shift(@_)->[SUBST_FILES]; }
 sub subst_sed($)               { return shift(@_)->[SUBST_SED]; }
+sub subst_vars($)              { return shift(@_)->[SUBST_VARS]; }
 sub subst_filter_cmd($)                { return shift(@_)->[SUBST_FILTER_CMD]; }
 sub subst_id($)                        { return shift(@_)->[SUBST_ID]; }
 
 sub init($) {
        my ($self) = @_;
 
+       $self->[SUBST_ID] = undef;
        $self->[SUBST_CLASS] = undef;
        $self->[SUBST_STAGE] = undef;
        $self->[SUBST_MESSAGE] = undef;
        $self->[SUBST_FILES] = [];
        $self->[SUBST_SED] = [];
+       $self->[SUBST_VARS] = [];
        $self->[SUBST_FILTER_CMD] = undef;
-       $self->[SUBST_ID] = undef;
 }
 
 sub check_end($$) {
@@ -1333,8 +1335,8 @@
        if (@{$self->subst_files} == 0) {
                $line->log_warning("Incomplete SUBST block: SUBST_FILES missing.");
        }
-       if (@{$self->subst_sed} == 0 && !defined($self->subst_filter_cmd)) {
-               $line->log_warning("Incomplete SUBST block: SUBST_SED missing.");
+       if (@{$self->subst_sed} == 0 && @{$self->subst_vars} == 0 && !defined($self->subst_filter_cmd)) {
+               $line->log_warning("Incomplete SUBST block: SUBST_SED or SUBST_VARS missing.");
        }
        $self->init();
 }
@@ -1345,7 +1347,7 @@
        return false unless defined($self->subst_id);
        return false unless defined($self->subst_class);
        return false unless defined($self->subst_files);
-       return false unless defined($self->subst_sed);
+       return false if @{$self->subst_sed} == 0 && @{$self->subst_vars} == 0;
        return true;
 }
 
@@ -1372,7 +1374,7 @@
 
        $id = $self->subst_id;
 
-       if ($varname =~ qr"^(SUBST_(?:STAGE|MESSAGE|FILES|SED|FILTER_CMD))\.([\-\w_]+)$") {
+       if ($varname =~ qr"^(SUBST_(?:STAGE|MESSAGE|FILES|SED|VARS|FILTER_CMD))\.([\-\w_]+)$") {
                ($varbase, $varparam) = ($1, $2);
 
                if (!defined($id)) {
@@ -1441,6 +1443,14 @@
                        $self->[SUBST_FILTER_CMD] = $value;
                }
 
+       } elsif ($varbase eq "SUBST_VARS") {
+               if (@{$self->subst_vars} > 0) {
+                       if ($op ne "+=") {
+                               $line->log_warning("All but the first SUBST_VARS line should use the \"+=\" operator.");
+                       }
+               }
+               push(@{$self->subst_vars}, $value);
+
        } else {
                $line->log_warning("Foreign variable in SUBST block.");
        }



Home | Main Index | Thread Index | Old Index