[SCM] Debian package checker branch, master, updated. 1.24.4-57-gcfdcbc8
The following commit has been merged in the master branch:
commit c41ccf360480de8257cea08dcea0f167923165e8
Author: Jordà Polo <jorda@ettin.org>
Date: Fri Aug 15 19:33:16 2008 +0200
Initial support to restrict displayed tags by source
A new --display-source option is implemented to restrict displayed tags
depending on its source. It currently supports tags with manual references
only.
diff --git a/frontend/lintian b/frontend/lintian
index 2c6409d..7ac7779 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -73,6 +73,7 @@ my $experimental_output_opts = undef;
my @severities = qw(wishlist minor normal important serious);
my @certainties = qw(wild-guess possible certain);
my %display_level = ();
+my %display_source = ();
my @packages;
@@ -148,6 +149,7 @@ Behaviour options:
-I, --display-info display "I:" tags (normally suppressed)
-E, --display-experimental display "X:" tags (normally suppressed)
-L, --display-level display tags with the specified level
+ --display-source X restrict displayed tags by source
-l X, --unpack-level X set default unpack level to X
-o, --no-override ignore overrides
--show-overrides output tags that have been overriden
@@ -329,6 +331,7 @@ my %opthash = ( # ------------------ actions
"display-info|I" => \&display_infotags,
"display-experimental|E" => \$display_experimentaltags,
"display-level|L=s" => \&record_display_level,
+ "display-source=s" => \&record_display_source,
"unpack-level|l=i" => \$unpack_level,
"no-override|o" => \$no_override,
"show-overrides" => \$show_overrides,
@@ -432,6 +435,10 @@ sub display_infotags {
}
}
+sub record_display_source {
+ $display_source{$_[1]} = 1;
+}
+
# check permitted values for --color
if ($color and $color !~ /^(never|always|auto|html)$/) {
die "invalid argument to --color: $color\n";
@@ -637,6 +644,7 @@ if (defined $experimental_output_opts) {
$Tags::show_experimental = $display_experimentaltags;
$Tags::show_overrides = $show_overrides;
%Tags::display_level = %display_level;
+%Tags::display_source = %display_source;
$Tags::color = $color;
%Tags::only_issue_tags = map { $_ => 1 } (split(/,/, $check_tags))
if defined $check_tags;
@@ -1157,7 +1165,7 @@ for my $f (readdir CHECKDIR) {
foreach my $tag (@secs) {
$tag->{'script'} = $script;
Tags::add_tag($tag);
- $p->{'requested-tags'}++ if Tags::check_level($tag);
+ $p->{'requested-tags'}++ if Tags::display_tag($tag);
}
} # end: if ne lintian
diff --git a/lib/Tags.pm b/lib/Tags.pm
index 7d58752..d1f890f 100644
--- a/lib/Tags.pm
+++ b/lib/Tags.pm
@@ -43,6 +43,7 @@ our $show_overrides = 0;
our $output_formatter = \&print_tag;
our $color = 'never';
our %display_level;
+our %display_source;
our %only_issue_tags;
# The master hash with all tag info. Key is the tag name, value another hash
@@ -302,20 +303,48 @@ sub print_tag {
print $output;
}
+# Extract manual sources from a given tag. Returns a hash that has manual
+# names as keys and sections/ids has values.
+sub get_tag_source {
+ my ( $tag_info ) = @_;
+ my $ref = $tag_info->{'ref'};
+ return undef if not $ref;
+
+ my @refs = split(',', $ref);
+ my %source = ();
+ foreach my $r (@refs) {
+ $source{$1} = $2 if $r =~ /^([\w-]+)\s(.+)$/;
+ }
+ return \%source;
+}
+
# Checks if the Severity/Certainty level of a given tag passes the threshold
-# of requested tags (returns 1) or not (returns 0).
-sub check_level {
+# of requested tags (returns 1) or not (returns 0). If there are restrictions
+# by source, references will be also checked. The result is also saved in the
+# tag structure to avoid unnecessarily checking later.
+sub display_tag {
my ( $tag_info ) = @_;
- my $severity = $tag_info->{severity};
- my $certainty = $tag_info->{certainty};
- return $display_level{$severity}{$certainty};
+ return $tag_info->{'display'} if defined $tag_info->{'display'};
+
+ my $severity = $tag_info->{'severity'};
+ my $certainty = $tag_info->{'certainty'};
+ my $level = $display_level{$severity}{$certainty};
+
+ $tag_info->{'display'} = $level;
+ return $level if not keys %display_source;
+
+ my $tag_source = get_tag_source($tag_info);
+ my %in = map { $_ => 1 } grep { $tag_source->{$_} } keys %display_source;
+
+ $tag_info->{'display'} = ($level and keys %in) ? 1 : 0;
+ return $tag_info->{'display'};
}
sub skip_print {
my ( $tag_info ) = @_;
return 1 if exists $tag_info->{experimental} && !$show_experimental;
return 1 if $tag_info->{overridden}{override} && !$show_overrides;
- return 1 if not check_level( $tag_info );
+ return 1 if not display_tag( $tag_info );
return 0;
}
--
Debian package checker
Reply to: