1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 500-backport-1.23.22-frontend.dpatch by Eero Häkkinen <eero.hakkinen@nokia.com>
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: Backported frontends from lintian 1.23.22
8 diff -urNad lintian-1.23.8/frontend/lintian lintian-1.23.22/frontend/lintian
9 --- lintian-1.23.8/frontend/lintian 2005-01-02 00:29:42.000000000 +0000
10 +++ lintian-1.23.22/frontend/lintian 2006-07-19 11:57:17.000000000 +0000
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, you can find it on the World Wide
14 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
15 -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 -# MA 02111-1307, USA.
17 +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
18 +# MA 02110-1301, USA.
21 # {{{ libraries and such
23 my $LINTIAN_CFG = ""; #config file to use
24 our $LINTIAN_ROOT; #location of the lintian modules
26 +my $experimental_output_opts = undef;
41 "unpack-info|U=s" => \&record_unpack_info,
42 "md5sums|m" => \$check_md5sums,
43 "allow-root" => \$allow_root,
44 + # Note: Ubuntu has (and other derivatives might gain) a
45 + # -D/--debian option to make lintian behave like in Debian, that
46 + # is, to revert distribution-specific changes
48 # ------------------ configuration options
49 "cfg=s" => \$LINTIAN_CFG,
51 "source|s" => \&record_pkgmode,
52 "udeb" => \&record_pkgmode,
53 "packages-file|p=s" => \$packages_file,
55 + # ------------------ experimental
56 + "exp-output:s" => \$experimental_output_opts,
59 # init commandline parser
61 # LINTIAN_ARCH must have a value.
62 unless (defined $LINTIAN_ARCH) {
64 - chop($LINTIAN_ARCH=`dpkg --print-installation-architecture`);
65 + chop($LINTIAN_ARCH=`dpkg --print-architecture`);
67 $LINTIAN_ARCH = 'any';
77 +my @l_secs = read_dpkg_control("$LINTIAN_ROOT/checks/lintian.desc");
79 +map Tags::add_tag($_), @l_secs;
83 # {{{ No clue why this code is here...
89 + Tags::set_pkg( $arg, $arg_name, "", "", 'binary' );
90 # check distribution field
91 if (! (($data->{'distribution'} eq 'stable')
92 or ($data->{'distribution'} eq 'testing')
94 or ($data->{'distribution'} =~ /\w+-security/))
96 # bad distribution entry
97 - print "E: $arg_name: bad-distribution-in-changes-file $data->{'distribution'}\n";
98 + tag("bad-distribution-in-changes-file",
99 + $data->{'distribution'});
102 # process all listed `files:'
104 if (-s $filename ne $size) {
105 print "N: size is $size, argname is $arg_name, filename is $filename\n";
107 - print "E: $arg_name: file-size-mismatch-in-changes-file $file\n";
108 + tag( "file-size-mismatch-in-changes-file", $file );
112 @@ -644,13 +661,13 @@
113 my $real_md5sum = get_file_md5($filename);
115 if ($real_md5sum ne $md5sum) {
116 - print "E: $arg_name: md5sum-mismatch-in-changes-file $file\n";
117 + tag( "md5sum-mismatch-in-changes-file", $file );
122 if (($section eq 'non-free') or ($section eq 'contrib')) {
123 - print "E: $arg_name: bad-section-in-changes-file $file $section\n";
124 + tag( "bad-section-in-changes-file", $file, $section );
129 $info->{'version'}, $filename);
133 + unless ($exit_code) {
134 + my $stats = Tags::get_stats( $arg );
135 + if ($stats->{severity}{4}) {
141 fail("bad package file name $arg (neither .deb, .udeb or .dsc file)");
143 @@ -850,10 +875,22 @@
145 # {{{ Now we're ready to load info about checks & tags
150 +if (defined $experimental_output_opts) {
151 + $Tags::output_formatter = \&Tags::print_tag_new;
152 + my %opts = map { split(/=/) } split( /,/, $experimental_output_opts );
153 + foreach (keys %opts) {
154 + if ($_ eq 'format') {
155 + if ($opts{$_} eq 'colons') {
156 + require Tags::ColonSeparated;
157 + $Tags::output_formatter = \&Tags::ColonSeparated::print_tag;
161 + ${"Tags::$_"} = $opts{$_};
166 $Tags::show_info = $display_infotags;
167 $Tags::show_overrides = $show_overrides;
169 @@ -920,10 +957,10 @@
174 + map Tags::add_tag($_), @secs;
175 } # end: if ne lintian
178 - map Tags::add_tag($_), @secs;
182 @@ -1056,8 +1093,6 @@
183 printf "N: Selected checks: %s\n",join(',',keys %checks);
190 # for each package (the `reverse sort' is to make sure that source packages are
191 @@ -1203,7 +1238,7 @@
194 if ($action eq 'check') { # read override file
195 - Tags::pkg_reset($long_type eq 'binary' ? $pkg : "$pkg $long_type");
196 + Tags::set_pkg( $file, $pkg, "", "", $long_type );
199 unless ($no_override)
200 @@ -1259,21 +1294,25 @@
201 print "N: Skipping $action of $long_type package $pkg\n";
206 + unless ($exit_code) {
207 + my $stats = Tags::get_stats( $file );
208 + if ($stats->{severity}{4}) {
213 # report unused overrides
214 -# if (not $no_override and $verbose) {
215 -# my $ppkg = $type eq 'b' ? quotemeta($pkg) : quotemeta("$pkg $long_type");
216 -# for my $o (sort keys %overridden) {
217 -# next unless $o =~ /^$ppkg:/;
218 -# next if $overridden{$o};
220 -# print "I: $pkg: unused-override $o\n";
222 -# # mark override entry as used
223 -# $overridden{$o} = 99999;
226 + if (not $no_override and $verbose) {
227 + my $overrides = Tags::get_overrides( $file );
229 + for my $o (sort keys %$overrides) {
230 + next if $overrides->{$o};
232 + tag( "unused-override", $o );
237 # chdir to lintian root directory (to unlock $base so it can be removed below)
238 diff -urNad lintian-1.23.8/frontend/lintian-info lintian-1.23.22/frontend/lintian-info
239 --- lintian-1.23.8/frontend/lintian-info 2004-11-24 22:44:09.000000000 +0000
240 +++ lintian-1.23.22/frontend/lintian-info 2006-07-19 11:57:17.000000000 +0000
242 # You should have received a copy of the GNU General Public License
243 # along with this program. If not, you can find it on the World Wide
244 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
245 -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
246 -# MA 02111-1307, USA.
247 +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
248 +# MA 02110-1301, USA.
253 my ($type, $pkg, @pieces) = split(/:\s+/);
254 if ($type =~ m/^[OEWIX]$/) {
255 $tag = shift @pieces;
256 + next if not defined $tag;
257 ($tag) = split(/\s+/, $tag, 2);
259 next if not exists $tag_info{$tag} or $already_displayed{$tag}++;
260 diff -urNad lintian-1.23.8/lib/Tags/ColonSeparated.pm lintian-1.23.22/lib/Tags/ColonSeparated.pm
261 --- lintian-1.23.8/lib/Tags/ColonSeparated.pm 1970-01-01 00:00:00.000000000 +0000
262 +++ lintian-1.23.22/lib/Tags/ColonSeparated.pm 2006-07-19 11:58:28.000000000 +0000
264 +# Tags::ColonSeparated -- Perl tags functions for lintian
265 +# $Id: Tags.pm 489 2005-09-17 00:06:30Z djpig $
267 +# Copyright (C) 2005 Frank Lichtenheld <frank@lichtenheld.de>
269 +# This program is free software; you can redistribute it and/or modify
270 +# it under the terms of the GNU General Public License as published by
271 +# the Free Software Foundation; either version 2 of the License, or
272 +# (at your option) any later version.
274 +# This program is distributed in the hope that it will be useful,
275 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
276 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
277 +# GNU General Public License for more details.
279 +# You should have received a copy of the GNU General Public License
280 +# along with this program. If not, you can find it on the World Wide
281 +# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
282 +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
283 +# MA 02110-1301, USA.
285 +package Tags::ColonSeparated;
290 + my ( $char, @items ) = @_;
294 + s/\Q$char\E/\\$char/go;
301 + my ( $pkg_info, $tag_info, $information ) = @_;
303 + my $extra = "@$information";
305 + print join(':', quote_char( ':',
306 + $tag_info->{severity},
307 + $tag_info->{significance},
308 + @{$tag_info->{overridden}}{'override',
311 + @{$pkg_info}{'pkg','version','arch','type'},
319 diff -urNad lintian-1.23.8/lib/Tags.pm lintian-1.23.22/lib/Tags.pm
320 --- lintian-1.23.8/lib/Tags.pm 2006-07-18 13:39:52.000000000 +0000
321 +++ lintian-1.23.22/lib/Tags.pm 2006-07-19 11:57:40.000000000 +0000
323 # Tags -- Perl tags functions for lintian
324 -# $Id: Tags.pm 364 2004-11-13 21:07:48Z djpig $
325 +# $Id: Tags.pm 510 2005-10-14 00:19:49Z djpig $
327 # Copyright (C) 1998-2004 Various authors
328 +# Copyright (C) 2005 Frank Lichtenheld <frank@lichtenheld.de>
330 # This program is free software; you can redistribute it and/or modify
331 # it under the terms of the GNU General Public License as published by
333 # You should have received a copy of the GNU General Public License
334 # along with this program. If not, you can find it on the World Wide
335 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
336 -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
337 -# MA 02111-1307, USA.
338 +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
339 +# MA 02110-1301, USA.
348 our @ISA = qw(Exporter);
349 our @EXPORT = qw(tag);
351 -my $LINTIAN_ROOT = $::LINTIAN_ROOT;
353 -# Can also be more precise later on (only verbose with lab actions) but for
354 -# now this will do --Jeroen
355 -my $verbose = $::verbose;
356 -my $debug = $::debug;
358 -# What to print between the "E:" and the tag, f.e. "package source"
359 -our $prefix = undef;
360 +# configuration variables and defaults
361 +our $verbose = $::verbose;
362 +our $debug = $::debug;
364 +our $show_overrides = 0;
365 +our $output_formatter = \&print_tag;
366 +our $min_severity = 1;
367 +our $max_severity = 99;
368 +our $min_significance = 1;
369 +our $max_significance = 99;
371 -# The master hash with all tag info. Key is a hash too, with these stuff:
372 +# The master hash with all tag info. Key is the tag name, value another hash
373 +# with the following keys:
375 # - type: error/warning/info/experimental
376 # - info: Description in HTML
378 # - experimental: experimental status (possibly undef)
381 -our $show_overrides;
382 -# in the form overrides->tag or full thing
384 +# Statistics per file. Key is the filename, value another hash with the
392 -my $codes = { 'error' => 'E' , 'warning' => 'W' , 'info' => 'I' };
393 +# Info about a specific file. Key is the the filename, value another hash
394 +# with the following keys:
395 +# - pkg: package name
396 +# - version: package version
397 +# - arch: package architecture
398 +# - type: one of 'binary', 'udeb' or 'source'
399 +# - overrides: hash with all overrides for this file as keys
402 +# Currently selected file (not package!)
406 -# - override support back in --> just the unused reporting
407 -# - be able to return whether any errors were there, better, full stats
408 +# Compatibility stuff
409 +my %codes = ( 'error' => 'E' , 'warning' => 'W' , 'info' => 'I' );
410 +our %type_to_sev = ( error => 4, warning => 2, info => 0 );
411 +our @sev_to_type = qw( info warning warning error error );
413 -# Call this function to add a certain tag, by supplying the info as a hash
414 +my @sig_to_qualifier = ( '??', '?', '', '!' );
415 +my @sev_to_code = qw( I W W E E );
417 +# Add a new tag, supplied as a hash reference
420 - fail("Duplicate tag: $newtag->{'tag'}")
421 - if exists $tags{$newtag->{'tag'}};
423 + if (exists $tags{$newtag->{tag}}) {
424 + warn "Duplicate tag: $newtag->{tag}\n";
428 + # smooth transition
429 + $newtag->{type} = $sev_to_type[$newtag->{severity}]
430 + unless $newtag->{type};
431 + $newtag->{significance} = 2 unless exists $newtag->{significance};
432 + $newtag->{severity} = $type_to_sev{$newtag->{type}}
433 + unless exists $newtag->{severity};
434 $tags{$newtag->{'tag'}} = $newtag;
438 -# Used to reset the matched tags data
442 +# Add another file, will fail if there is already stored info about
445 + my ( $file, $pkg, $version, $arch, $type ) = @_;
447 + if (exists $info{$file}) {
448 + warn "File $file was already processed earlier\n";
455 + version => $version,
462 + significance => {},
470 -# Add an override, string tag, string rest
471 +# select another file as 'current' without deleting or adding any information
472 +# the file must have been added with add_pkg
476 + unless (exists $info{$file}) {
477 + warn "Can't select package $file";
485 +# only delete the value of 'current' without deleting any stored information
491 +# delete all the stored information (including tags)
500 +# Add an override. If you specifiy two arguments, the first will be taken
501 +# as file to add the override to, otherwise 'current' will be assumed
504 - $overrides{$tag} = 0;
505 + my ($tag, $file) = ( "", "" );
507 + ($file, $tag) = @_;
509 + ($file, $tag) = ($current, @_);
513 + warn "Don't know which package to add override $tag to";
517 + $info{$file}{overrides}{$tag} = 0;
526 + warn "Don't know which package to get overrides from";
530 + return $info{$file}{overrides};
533 +# Get the info hash for a tag back as a reference. The hash will be
534 +# copied first so that you can edit it safely
537 + return { %{$tags{$tag}} } if exists $tags{$tag};
542 + my ( $x, $min, $max ) = @_;
544 + return -1 if $x < $min;
545 + return 1 if $x > $max;
549 +# check if a certain tag has a override for the 'current' package
550 +sub check_overrides {
551 + my ( $tag_info, $information ) = @_;
554 + $extra = " @$information" if @$information;
555 + $extra = '' if $extra eq ' ';
556 + if( exists $info{$current}{overrides}{$tag_info->{tag}}) {
557 + $info{$current}{overrides}{$tag_info->{tag}}++;
558 + return $tag_info->{tag};
559 + } elsif( exists $info{$current}{overrides}{"$tag_info->{tag}$extra"} ) {
560 + $info{$current}{overrides}{"$tag_info->{tag}$extra"}++;
561 + return "$tag_info->{tag}$extra";
567 +# sets all the overridden fields of a tag_info hash correctly
568 +sub check_need_to_show {
569 + my ( $tag_info, $information ) = @_;
570 + $tag_info->{overridden}{override} = check_overrides( $tag_info,
572 + my $min_sev = $show_info ? 0 : $min_severity; # compat hack
573 + $tag_info->{overridden}{severity} = check_range( $tag_info->{severity},
576 + $tag_info->{overridden}{significance} = check_range( $tag_info->{significance},
578 + $max_significance );
581 +# records the stats for a given tag_info hash
583 + my ( $tag_info ) = @_;
585 + for my $k (qw( severity significance tag )) {
586 + $stats{$current}{$k}{$tag_info->{$k}}++
587 + unless $tag_info->{overridden}{$k};
589 + for my $k (qw( severity significance override )) {
590 + $stats{$current}{overrides}{$k}{$tag_info->{overridden}{$k}}++
591 + if $tag_info->{overridden}{$k};
595 +# get the statistics for a file (one argument) or for all files (no argument)
599 + return $stats{$file} if $file;
604 + my ( $pkg_info, $tag_info, $information ) = @_;
607 + $extra = " @$information" if @$information;
608 + $extra = '' if $extra eq ' ';
609 + my $code = $codes{$tag_info->{type}};
610 + $code = 'O' if $tag_info->{overridden}{override};
612 + $type = " $pkg_info->{type}" if $pkg_info->{type} ne 'binary';
614 + print "$code: $pkg_info->{pkg}$type: $tag_info->{tag}$extra\n";
618 + my ( $pkg_info, $tag_info, $information ) = @_;
621 + $extra = " @$information" if @$information;
622 + $extra = '' if $extra eq ' ';
623 + my $code = $sev_to_code[$tag_info->{severity}];
624 + $code = 'O' if $tag_info->{overridden}{override};
625 + my $qualifier = $sig_to_qualifier[$tag_info->{significance}];
626 + $qualifier = '' if $code eq 'O';
628 + $type = " $pkg_info->{type}" if $pkg_info->{type} ne 'binary';
630 + print "$code$qualifier: $pkg_info->{pkg}$type: $tag_info->{tag}$extra\n";
636 - my $info = $tags{$tag};
637 - return if not $show_info and $info->{'type'} eq 'info';
639 - $extra = ' '.join(' ', @_) if $#_ >=0;
640 - $extra = '' if $extra eq ' ';
641 - my $code = $codes->{$info->{'type'}};
642 - if (exists $overrides{$tag} or exists $overrides{"$tag$extra"}) {
643 - return unless $show_overrides or $verbose;
646 + my ( $tag, @information ) = @_;
647 + unless ($current) {
648 + warn "Tried to issue tag $tag without setting package\n";
652 - print "$code: $prefix: $tag$extra\n";
653 + my $tag_info = get_tag_info( $tag );
654 + unless ($tag_info) {
655 + warn "Tried to issue unknown tag $tag\n";
658 + check_need_to_show( $tag_info, \@information );
660 + record_stats( $tag_info );
663 + $tag_info->{overridden}{severity} != 0
664 + || $tag_info->{overridden}{significance} != 0
665 + || ( $tag_info->{overridden}{override} &&
668 + &$output_formatter( $info{$current}, $tag_info, \@information );