lintian: r510 - in trunk: frontend lib
Author: djpig
Date: 2005-10-14 02:19:49 +0200 (Fri, 14 Oct 2005)
New Revision: 510
Modified:
trunk/frontend/lintian
trunk/lib/Tags.pm
Log:
* Begin 1.23.14 and already propose a name :)
* frontend/lintian:
+ Fix exit status computing so that we exit with 1 again
if we found any error. (Closes: #329458)
+ Re-enable reporting unused overrides.
* lib/Tags.pm:
+ Some fixes to the statistics code to make the fixes
in frontend/lintian possible
Modified: trunk/frontend/lintian
===================================================================
--- trunk/frontend/lintian 2005-10-14 00:02:11 UTC (rev 509)
+++ trunk/frontend/lintian 2005-10-14 00:19:49 UTC (rev 510)
@@ -74,7 +74,7 @@
my $unpack_info;
my $cwd;
my $cleanup_filename;
-my $exit_code;
+my $exit_code = 0;
my $LAB;
my %collection_info;
@@ -480,8 +480,15 @@
import Util;
import Pipeline;
-# }}}
+require Tags;
+import Tags;
+my @l_secs = read_dpkg_control("$LINTIAN_ROOT/checks/lintian.desc");
+shift(@l_secs);
+map Tags::add_tag($_), @l_secs;
+
+# }}}
+
# {{{ No clue why this code is here...
use vars qw(%source_info %binary_info %udeb_info); # from the above
@@ -612,6 +619,7 @@
next;
}
+ Tags::set_pkg( $arg, $arg_name, "", "", 'binary' );
# check distribution field
if (! (($data->{'distribution'} eq 'stable')
or ($data->{'distribution'} eq 'testing')
@@ -621,7 +629,8 @@
or ($data->{'distribution'} =~ /\w+-security/))
) {
# bad distribution entry
- print "E: $arg_name: bad-distribution-in-changes-file $data->{'distribution'}\n";
+ tag("bad-distribution-in-changes-file",
+ $data->{'distribution'});
}
# process all listed `files:'
@@ -641,7 +650,7 @@
if (-s $filename ne $size) {
print "N: size is $size, argname is $arg_name, filename is $filename\n";
- print "E: $arg_name: file-size-mismatch-in-changes-file $file\n";
+ tag( "file-size-mismatch-in-changes-file", $file );
}
# check md5sums
@@ -649,13 +658,13 @@
my $real_md5sum = get_file_md5($filename);
if ($real_md5sum ne $md5sum) {
- print "E: $arg_name: md5sum-mismatch-in-changes-file $file\n";
+ tag( "md5sum-mismatch-in-changes-file", $file );
}
}
# check section
if (($section eq 'non-free') or ($section eq 'contrib')) {
- print "E: $arg_name: bad-section-in-changes-file $file $section\n";
+ tag( "bad-section-in-changes-file", $file, $section );
}
# process file?
@@ -673,6 +682,14 @@
$info->{'version'}, $filename);
}
}
+
+ unless ($exit_code) {
+ my $stats = Tags::get_stats( $arg );
+ if ($stats->{severity}{4}) {
+ $exit_code = 1;
+ }
+ }
+
} else {
fail("bad package file name $arg (neither .deb, .udeb or .dsc file)");
}
@@ -855,9 +872,6 @@
# {{{ Now we're ready to load info about checks & tags
-require Tags;
-import Tags;
-
no warnings 'once';
if (defined $experimental_output_opts) {
$Tags::output_formatter = \&Tags::print_tag_new;
@@ -940,10 +954,10 @@
}
}
+ shift(@secs);
+ map Tags::add_tag($_), @secs;
} # end: if ne lintian
- shift(@secs);
- map Tags::add_tag($_), @secs;
}
closedir(CHECKDIR);
@@ -1076,8 +1090,6 @@
printf "N: Selected checks: %s\n",join(',',keys %checks);
}
-$exit_code = 0;
-
require Checker;
# for each package (the `reverse sort' is to make sure that source packages are
@@ -1279,21 +1291,25 @@
print "N: Skipping $action of $long_type package $pkg\n";
next PACKAGE;
}
+
}
+ unless ($exit_code) {
+ my $stats = Tags::get_stats( $file );
+ if ($stats->{severity}{4}) {
+ $exit_code = 1;
+ }
+ }
# report unused overrides
-# if (not $no_override and $verbose) {
-# my $ppkg = $type eq 'b' ? quotemeta($pkg) : quotemeta("$pkg $long_type");
-# for my $o (sort keys %overridden) {
-# next unless $o =~ /^$ppkg:/;
-# next if $overridden{$o};
-#
-# print "I: $pkg: unused-override $o\n";
-#
-# # mark override entry as used
-# $overridden{$o} = 99999;
-# }
-# }
+ if (not $no_override and $verbose) {
+ my $overrides = Tags::get_overrides( $file );
+
+ for my $o (sort keys %$overrides) {
+ next if $overrides->{$o};
+
+ tag( "unused-override", $o );
+ }
+ }
}
# chdir to lintian root directory (to unlock $base so it can be removed below)
Modified: trunk/lib/Tags.pm
===================================================================
--- trunk/lib/Tags.pm 2005-10-14 00:02:11 UTC (rev 509)
+++ trunk/lib/Tags.pm 2005-10-14 00:19:49 UTC (rev 510)
@@ -166,11 +166,22 @@
return 0;
}
- $info{$file}{overrides}{$tag}++;
+ $info{$file}{overrides}{$tag} = 0;
return 1;
}
+sub get_overrides {
+ my ($file) = @_;
+
+ unless ($file) {
+ warn "Don't know which package to get overrides from";
+ return undef;
+ }
+
+ return $info{$file}{overrides};
+}
+
# Get the info hash for a tag back as a reference. The hash will be
# copied first so that you can edit it safely
sub get_tag_info {
@@ -194,10 +205,13 @@
my $extra = '';
$extra = " @$information" if @$information;
$extra = '' if $extra eq ' ';
- return $tag_info->{tag}
- if exists $info{$current}{overrides}{$tag_info->{tag}};
- return "$tag_info->{tag}$extra"
- if exists $info{$current}{overrides}{"$tag_info->{tag}$extra"};
+ 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";
+ }
return '';
}
@@ -221,10 +235,12 @@
my ( $tag_info ) = @_;
for my $k (qw( severity significance tag )) {
- $stats{$current}{$k}{$tag_info->{$k}}++;
+ $stats{$current}{$k}{$tag_info->{$k}}++
+ unless $tag_info->{overridden}{$k};
}
for my $k (qw( severity significance override )) {
- $stats{$current}{overrides}{$k}{$tag_info->{overridden}{$k}}++;
+ $stats{$current}{overrides}{$k}{$tag_info->{overridden}{$k}}++
+ if $tag_info->{overridden}{$k};
}
}
Reply to: