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

[SCM] Debian package checker branch, master, updated. 1.24.4-123-g85e96ff



The following commit has been merged in the master branch:
commit 7ad56a90b0bc2dcccdbe7bdc4c4556aee1abd18a
Author: Frank Lichtenheld <djpig@debian.org>
Date:   Tue Sep 2 00:27:13 2008 +0200

    Implement support for wildcards in overrides
    
    Allows to add an asterisk at the start and/or end of the
    additional info to match arbitrary strings. This ensures
    nearly full backwards compatibility and should cover many
    cases where you might want to use this new feature.

diff --git a/debian/changelog b/debian/changelog
index b1f9ca8..50fedab 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -105,6 +105,9 @@ lintian (2.0.0~rc1) experimental; urgency=low
       separate packages.
   * private/refresh-perl-provides:
     + [FL] Script to update data/fields/perl-provides.  By Niko Tyni.
+  
+  * doc/lintian.sgml:
+    + [FL] Document wildcard support in overrides.
 
   * frontend/lintian:
     + [RA] Ensure we close the pipe to lintian-info before exiting, since
@@ -117,6 +120,9 @@ lintian (2.0.0~rc1) experimental; urgency=low
       available to output formatters if possible.
       Currently used only by experimental colon-separated output.
   
+  * lib/Tags.pm:
+    + [FL] Add support for specifying wildcards in overrides.
+      (Closes: #253884)
   * lib/Tags/ColonSeparated.pm:
     + [FL] Update for new features and make a little bit easier to read
       for humans:
diff --git a/doc/lintian.sgml b/doc/lintian.sgml
index 6b8953b..1442aff 100644
--- a/doc/lintian.sgml
+++ b/doc/lintian.sgml
@@ -8,7 +8,7 @@
 <author>Sean 'Shaleh' Perry <email>shaleh@debian.org</email>
 <author>Frank Lichtenheld <email>djpig@debian.org</email>
 <author>Contact address: <email>lintian-maint@debian.org</email>
-<version>version 1.23.8, 31 January 2005
+<version>version 2.0.0, 02 September 2008
 
 <abstract>
 This manual describes Lintian, the Debian package checker.
@@ -16,7 +16,7 @@ This manual describes Lintian, the Debian package checker.
 
 <copyright>Copyright &copy; 1998 Christian Schwarz and Richard Braakman
            Copyright &copy; 2000 Sean 'Shaleh' Perry
-           Copyright &copy; 2004 Frank Lichtenheld
+           Copyright &copy; 2004,2008 Frank Lichtenheld
 <p>
 
 This manual is free software; you may redistribute it and/or
@@ -456,7 +456,7 @@ not used in current Lintian versions.
 The format of the overrides file is simple, it consists of one override per
 line (and may contain empty lines and comments, starting with a #, on others):
 <tt>[&lt;package&gt;[ &lt;type&gt;]: ]&lt;lintian-tag&gt;[
-&lt;lintian-info&gt;]</tt>.  <tt>&lt;package&gt;</tt> is the package name;
+[*]&lt;lintian-info&gt;[*]]</tt>.  <tt>&lt;package&gt;</tt> is the package name;
 <tt>&lt;type&gt;</tt> is one of <tt>binary</tt>, <tt>udeb</tt> and
 <tt>source</tt>, and <tt>&lt;lintian-info&gt;</tt> is all additional
 information provided by Lintian except for the tag. What's inside brackets is
@@ -489,7 +489,10 @@ Many tags can occour more than once (e.g. if the same error is found
 in more than one file). You can override a tag either completly by
 specifying its name (first line in the examples) or only one
 occurrence of it by specifying the additional info, too (second line
-in the examples).
+in the examples).  If you add an asterisk (<tt>*</tt>) at the start and/or
+end of the additional info, this will match arbitrary strings similar to
+the shell wildcard.  Asterisks located at any other place in the info have
+no special meaning.  This wildcard support was added in Lintian version 2.0.0.
 
 <chapt>Advanced usage
 
diff --git a/frontend/lintian b/frontend/lintian
index 3e3d9e3..73afec2 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -1431,10 +1431,11 @@ foreach my $pkg_info ($schedule->get_all) {
                     s/\s+/ /go;
                     my $override = $_;
                     $override =~ s/^\Q$pkg\E( \Q$long_type\E)?: //;
-                    if ($override eq '' or $override !~ /^[\w0-9.+-]+(\s+.*)?$/) {
+		    if ($override eq '' or $override !~ /^[\w.+-]+(\s.*)?$/) {
                         tag ('malformed-override', $_);
                     } else {
-                        Tags::add_override($override);
+			my ($tag, $extra) = split(/ /, $override, 2);
+			Tags::add_override($tag, $extra);
                     }
                 }
                 close(O);
@@ -1489,10 +1490,12 @@ foreach my $pkg_info ($schedule->get_all) {
 	if (not $no_override) {
 	    my $overrides = Tags::get_overrides( $file );
 
-	    for my $o (sort keys %$overrides) {
-		next if $overrides->{$o};
+	    for my $tag (sort keys %$overrides) {
+		for my $extra (sort keys %{$overrides->{$tag}}) {
+		    next if $overrides->{$tag}{$extra};
 
-		tag( "unused-override", $o );
+		    tag( "unused-override", $tag, $extra );
+		}
 	    }
 	}
 
diff --git a/lib/Tags.pm b/lib/Tags.pm
index 43f7e92..452e3ee 100644
--- a/lib/Tags.pm
+++ b/lib/Tags.pm
@@ -171,19 +171,20 @@ sub reset {
 # Add an override. If you specifiy two arguments, the first will be taken
 # as file to add the override to, otherwise 'current' will be assumed
 sub add_override {
-    my ($tag, $file) = ( "", "" );
-    if (@_ > 1) {
-	($file, $tag) = @_;
+    my ($tag, $extra, $file) = ( "", "", "" );
+    if (@_ > 2) {
+	($file, $tag, $extra) = @_;
     } else {
-	($file, $tag) = ($current, @_);
+	($file, $tag, $extra) = ($current, @_);
     }
+    $extra ||= "";
 
     unless ($file) {
 	warn "Don't know which package to add override $tag to";
 	return 0;
     }
 
-    $info{$file}{overrides}{$tag} = 0;
+    $info{$file}{overrides}{$tag}{$extra} = 0;
 
     return 1;
 }
@@ -218,14 +219,30 @@ sub check_overrides {
     my ( $tag_info, $information ) = @_;
 
     my $extra = '';
-    $extra = " @$information" if @$information;
-    $extra = '' if $extra eq ' ';
-    if( exists $info{$current}{overrides}{$tag_info->{tag}}) {
-	$info{$current}{overrides}{$tag_info->{tag}}++;
-	return $tag_info->{tag};
-    } elsif( exists $info{$current}{overrides}{"$tag_info->{tag}$extra"} ) {
-	$info{$current}{overrides}{"$tag_info->{tag}$extra"}++;
-	return "$tag_info->{tag}$extra";
+    $extra = "@$information" if @$information;
+    my $tag = $tag_info->{tag};
+    my $overrides = $info{$current}{overrides}{$tag};
+    return unless $overrides;
+
+    if( exists $overrides->{''} ) {
+	$overrides->{''}++;
+	return $tag;
+    } elsif( $extra and exists $overrides->{$extra} ) {
+	$overrides->{$extra}++;
+	return "$tag $extra";
+    } elsif ( $extra ) {
+	foreach (keys %$overrides) {
+	    my $regex = $_;
+	    if (m/^\*/ or m/\*$/) {
+		my ($start, $end) = ("","");
+		$start = '.*' if $regex =~ s/^\*//;
+		$end   = '.*' if $regex =~ s/\*$//;
+		if ($extra =~ /^$start\Q$regex\E$end$/) {
+		    $overrides->{$_}++;
+		    return "$tag $_";
+		}
+	    }
+	}
     }
 
     return '';

-- 
Debian package checker


Reply to: