[SCM] Debian package checker branch, master, updated. 2.5.3-3-gd11c3b9
The following commit has been merged in the master branch:
commit d11c3b9d4bf32c8e9f07bb9ea5b04b13d7f7ace5
Author: Niels Thykier <niels@thykier.net>
Date: Sun Sep 11 10:37:40 2011 +0200
Modified the Output API to take a L::T::Override in print_tag
Comments are no longer printed by Lintian::Tags. Instead, the
output format is passed the override object and can decide how
to print the override (and its comments).
diff --git a/lib/Lintian/Output.pm b/lib/Lintian/Output.pm
index 44fda1f..e43d2f7 100644
--- a/lib/Lintian/Output.pm
+++ b/lib/Lintian/Output.pm
@@ -273,23 +273,24 @@ can only be called as instance methods.
=over 4
-=item C<print_tag($pkg_info, $tag_info, $extra, $overridden)>
+=item C<print_tag($pkg_info, $tag_info, $extra, $override)>
Print a tag. The first two arguments are hash reference with the
-information about the package and the tag, $extra is the extra information
-for the tag (if any) as an array reference, and $overridden is either
-undef if the tag is not overridden or the override for this tag. Called
-from Lintian::Tags::tag().
+information about the package and the tag, $extra is the extra
+information for the tag (if any) as an array reference, and $override
+is either undef if the tag is not overridden or the
+L<Lintian::Tag::Override|override> for this tag. Called from
+Lintian::Tags::tag().
=cut
sub print_tag {
- my ($self, $pkg_info, $tag_info, $information, $overridden) = @_;
+ my ($self, $pkg_info, $tag_info, $information, $override) = @_;
$information = ' ' . $information if $information ne '';
my $code = $tag_info->code;
my $tag_color = $self->{colors}{$code};
$code = 'X' if $tag_info->experimental;
- $code = 'O' if defined($overridden);
+ $code = 'O' if defined($override);
my $type = '';
$type = " $pkg_info->{type}" if $pkg_info->{type} ne 'binary';
@@ -308,6 +309,10 @@ sub print_tag {
$tag .= $tag_info->tag;
}
+ if ($override && @{ $override->comments }) {
+ $self->msg(@{ $override->comments } );
+ }
+
$self->_print('', "$code: $pkg_info->{package}$type", "$tag$information");
if (not $self->issued_tag($tag_info->tag) and $self->showdescription) {
my $description;
diff --git a/lib/Lintian/Output/ColonSeparated.pm b/lib/Lintian/Output/ColonSeparated.pm
index 1e3e263..af37866 100644
--- a/lib/Lintian/Output/ColonSeparated.pm
+++ b/lib/Lintian/Output/ColonSeparated.pm
@@ -27,7 +27,12 @@ use Lintian::Output qw(:util);
use base qw(Lintian::Output);
sub print_tag {
- my ($self, $pkg_info, $tag_info, $information, $overridden) = @_;
+ my ($self, $pkg_info, $tag_info, $information, $override) = @_;
+ my $odata = '';
+ if ($override) {
+ $odata = $override->tag;
+ $odata .= ' ' . $override->extra if $override->extra;
+ }
$self->issued_tag($tag_info->tag);
$self->_print(
@@ -36,11 +41,11 @@ sub print_tag {
$tag_info->severity,
$tag_info->certainty,
($tag_info->experimental ? 'X' : '').
- (defined($overridden) ? 'O' : ''),
+ (defined($override) ? 'O' : ''),
@{$pkg_info}{'package','version','arch','type'},
$tag_info->tag,
$information,
- $overridden || '',
+ $odata,
);
}
diff --git a/lib/Lintian/Output/LetterQualifier.pm b/lib/Lintian/Output/LetterQualifier.pm
index 1f9828c..159e536 100644
--- a/lib/Lintian/Output/LetterQualifier.pm
+++ b/lib/Lintian/Output/LetterQualifier.pm
@@ -103,11 +103,11 @@ sub new {
sub print_tag {
- my ($self, $pkg_info, $tag_info, $information, $overridden) = @_;
+ my ($self, $pkg_info, $tag_info, $information, $override) = @_;
my $code = $tag_info->code;
$code = 'X' if $tag_info->experimental;
- $code = 'O' if defined($overridden);
+ $code = 'O' if defined($override);
my $sev = $tag_info->severity;
my $cer = $tag_info->certainty;
diff --git a/lib/Lintian/Output/XML.pm b/lib/Lintian/Output/XML.pm
index 77823e8..a55ce02 100644
--- a/lib/Lintian/Output/XML.pm
+++ b/lib/Lintian/Output/XML.pm
@@ -27,18 +27,24 @@ use Lintian::Output qw(:util);
use base qw(Lintian::Output);
sub print_tag {
- my ($self, $pkg_info, $tag_info, $information, $overridden) = @_;
+ my ($self, $pkg_info, $tag_info, $information, $override) = @_;
$self->issued_tag($tag_info->tag);
my $flags = ($tag_info->experimental ? 'experimental' : '');
- if ($overridden) {
+ my $comment;
+ if ($override) {
$flags .= ',' if $flags;
$flags .= 'overridden';
+ if (@{ $override->comments }) {
+ my $c = $self->_make_xml_tag ('comment', [],
+ join ("\n", @{ $override->comments }));
+ $comment = [ $c ];
+ }
}
my @attrs = ([ severity => $tag_info->severity ],
[ certainty => $tag_info->certainty ],
[ flags => $flags ],
[ name => $tag_info->tag ]);
- $self->_print_xml_tag('tag', \@attrs, $information);
+ print { $self->stdout } $self->_make_xml_tag('tag', \@attrs, $information, $comment), "\n";
}
sub print_start_pkg {
@@ -66,6 +72,12 @@ sub _print {
print { $stream } $output;
}
+# Create a start tag (or a self-closed tag)
+# $tag is the name of the tag
+# $attrs is an anonymous array of pairs of attributes and their values
+# $close is a boolean. If a truth-value, the tag will closed
+#
+# returns the string.
sub _open_xml_tag {
my ($self, $tag, $attrs, $close) = @_;
my $output = "<$tag";
@@ -82,14 +94,22 @@ sub _open_xml_tag {
# Print a given XML tag to standard output. Takes the tag, an anonymous array
# of pairs of attributes and values, and then the contents of the tag.
-sub _print_xml_tag {
- my ($self, $tag, $attrs, $content) = @_;
- my $empty = ($content//'') eq '';
+sub _make_xml_tag {
+ my ($self, $tag, $attrs, $content, $children) = @_;
+ # $empty is true if $content is empty and there are no children
+ my $empty = ($content//'') eq '' && (!defined $children || !@$children);
my $output = $self->_open_xml_tag($tag, $attrs, $empty);
- if (defined $content && $content ne '') {
- $output .= encode_entities($content,"<>&\"'") . "</$tag>";
+ if (!$empty) {
+ $output .= encode_entities($content,"<>&\"'") if $content;
+ if (defined $children) {
+ foreach my $child (@$children) {
+ $output .= "\n\t$child";
+ }
+ $output .= "\n";
+ }
+ $output .= "</$tag>";
}
- print { $self->stdout } $output, "\n";
+ return $output;
}
1;
diff --git a/lib/Lintian/Tags.pm b/lib/Lintian/Tags.pm
index 6983574..469dd16 100644
--- a/lib/Lintian/Tags.pm
+++ b/lib/Lintian/Tags.pm
@@ -201,16 +201,16 @@ sub _check_overrides {
return unless $overrides;
if (exists $overrides->{''}) {
$stats->{''}++;
- return [$tag, ''];
+ return $overrides->{''};
} elsif ($extra ne '' and exists $overrides->{$extra}) {
$stats->{$extra}++;
- return [$tag, $extra];
+ return $overrides->{$extra};
} elsif ($extra ne '') {
for (sort keys %$overrides) {
my $override = $overrides->{$_};
if ($override->is_pattern && $override->overrides($extra)){
$stats->{$_}++;
- return [$tag, $override->extra];
+ return $override;
}
}
}
@@ -220,9 +220,9 @@ sub _check_overrides {
# Record tag statistics. Takes the tag, the Lintian::Tag::Info object and a
# flag saying whether the tag was overridden.
sub _record_stats {
- my ($self, $tag, $info, $overridden) = @_;
+ my ($self, $tag, $info, $override) = @_;
my $stats = $self->{statistics}{$self->{current}};
- if ($overridden) {
+ if ($override) {
$stats = $self->{statistics}{$self->{current}}{overrides};
}
$stats->{tags}{$tag}++;
@@ -254,26 +254,12 @@ sub tag {
my $extra = join(' ', @extra);
$extra = '' unless defined $extra;
- my $overridden = $self->_check_overrides($tag, $extra);
- $self->_record_stats($tag, $info, $overridden);
- return if (defined($overridden) and not $self->{show_overrides});
+ my $override = $self->_check_overrides($tag, $extra);
+ $self->_record_stats($tag, $info, $override);
+ return if (defined($override) and not $self->{show_overrides});
return unless $self->displayed($tag);
my $file = $self->{info}{$self->{current}};
- my $ovout;
- if ($overridden) {
- my $overrides = $self->{info}{$self->{current}}{'overrides-data'}{$tag}{$overridden->[1]};
- my $comments = $overrides->comments;
- if ($comments && @$comments) {
- $Lintian::Output::GLOBAL->msg(@$comments);
- }
- # We have to use undef, "$tag" or "$tag $extra" due to the Lintian::Output API
- if ($overridden->[1]) {
- $ovout = join(' ', @$overridden);
- } else {
- $ovout = $overridden->[0];
- }
- }
- $Lintian::Output::GLOBAL->print_tag($file, $info, $extra, $ovout);
+ $Lintian::Output::GLOBAL->print_tag($file, $info, $extra, $override);
}
=back
diff --git a/t/tests/lintian-output-xml/tags b/t/tests/lintian-output-xml/tags
index a6f9fe2..89c58bd 100644
--- a/t/tests/lintian-output-xml/tags
+++ b/t/tests/lintian-output-xml/tags
@@ -4,21 +4,21 @@
<package type="binary" name="lintian-output-xml" architecture="all" version="1.0+dsfg-1.1">
<package type="changes" name="lintian-output-xml_1.0+dsfg-1.1_ARCH" architecture="source all" version="1.0+dsfg-1.1">
<package type="source" name="lintian-output-xml" architecture="source" version="1.0+dsfg-1.1">
-<tag severity="important" certainty="possible" flags="" name="new-essential-package"></tag>
+<tag severity="important" certainty="possible" name="new-essential-package" />
<tag severity="minor" certainty="certain" flags="overridden" name="dfsg-version-misspelled">1.0+dsfg-1.1</tag>
-<tag severity="minor" certainty="possible" flags="" name="description-synopsis-might-not-be-phrased-properly"></tag>
-<tag severity="normal" certainty="certain" flags="" name="maintainer-upload-has-incorrect-version-number">1.0+dsfg-1.1</tag>
-<tag severity="normal" certainty="possible" flags="" name="binary-without-manpage">usr/bin/script</tag>
-<tag severity="normal" certainty="wild-guess" flags="" name="desktop-entry-limited-to-environments">usr/share/applications/script.desktop</tag>
-<tag severity="pedantic" certainty="certain" flags="" name="debian-control-has-unusual-field-spacing">line 11</tag>
-<tag severity="pedantic" certainty="certain" flags="" name="direct-changes-in-diff-but-no-patch-system">Changes</tag>
-<tag severity="pedantic" certainty="possible" flags="" name="example-unusual-interpreter">usr/share/doc/lintian-output-xml/examples/example #!/usr/bin/foo</tag>
-<tag severity="pedantic" certainty="possible" flags="" name="no-homepage-field"></tag>
-<tag severity="pedantic" certainty="wild-guess" flags="overridden" name="no-upstream-changelog"></tag>
-<tag severity="serious" certainty="certain" flags="" name="dir-in-usr-local">usr/local/share/</tag>
-<tag severity="serious" certainty="certain" flags="" name="dir-in-usr-local">usr/local/share/lintian/</tag>
-<tag severity="serious" certainty="possible" flags="" name="dir-or-file-in-var-lock">var/lock/lintian/</tag>
-<tag severity="serious" certainty="wild-guess" flags="" name="possible-gpl-code-linked-with-openssl"></tag>
-<tag severity="wishlist" certainty="certain" flags="" name="binary-control-field-duplicates-source">field "section" in package lintian-output-xml</tag>
-<tag severity="wishlist" certainty="possible" flags="" name="package-contains-empty-directory">usr/local/share/lintian/</tag>
-<tag severity="wishlist" certainty="wild-guess" flags="" name="description-possibly-contains-homepage">http://www.example.com/.</tag>
+<tag severity="minor" certainty="possible" name="description-synopsis-might-not-be-phrased-properly" />
+<tag severity="normal" certainty="certain" name="maintainer-upload-has-incorrect-version-number">1.0+dsfg-1.1</tag>
+<tag severity="normal" certainty="possible" name="binary-without-manpage">usr/bin/script</tag>
+<tag severity="normal" certainty="wild-guess" name="desktop-entry-limited-to-environments">usr/share/applications/script.desktop</tag>
+<tag severity="pedantic" certainty="certain" name="debian-control-has-unusual-field-spacing">line 11</tag>
+<tag severity="pedantic" certainty="certain" name="direct-changes-in-diff-but-no-patch-system">Changes</tag>
+<tag severity="pedantic" certainty="possible" name="example-unusual-interpreter">usr/share/doc/lintian-output-xml/examples/example #!/usr/bin/foo</tag>
+<tag severity="pedantic" certainty="possible" name="no-homepage-field" />
+<tag severity="pedantic" certainty="wild-guess" flags="overridden" name="no-upstream-changelog" />
+<tag severity="serious" certainty="certain" name="dir-in-usr-local">usr/local/share/</tag>
+<tag severity="serious" certainty="certain" name="dir-in-usr-local">usr/local/share/lintian/</tag>
+<tag severity="serious" certainty="possible" name="dir-or-file-in-var-lock">var/lock/lintian/</tag>
+<tag severity="serious" certainty="wild-guess" name="possible-gpl-code-linked-with-openssl" />
+<tag severity="wishlist" certainty="certain" name="binary-control-field-duplicates-source">field "section" in package lintian-output-xml</tag>
+<tag severity="wishlist" certainty="possible" name="package-contains-empty-directory">usr/local/share/lintian/</tag>
+<tag severity="wishlist" certainty="wild-guess" name="description-possibly-contains-homepage">http://www.example.com/.</tag>
--
Debian package checker
Reply to: