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

[SCM] Debian package checker branch, lab-refactor, updated. 2.5.3-144-geea2537



The following commit has been merged in the lab-refactor branch:
commit eea2537d1060ef1332819df6939c149f300ae834
Author: Niels Thykier <niels@thykier.net>
Date:   Wed Oct 26 12:44:47 2011 +0200

    Added experimental output that always uses full package info
    
    The new output format is basically the old output format, except it
    always uses the full metadata (even if it is redundant).  As an
    example
    
     T: my-pkg udeb: tag
    
    becomes
    
     T: my-pkg udeb (1.0-2) [i386]: tag
    
    This allows harness script (and other machine-parsers) to always get
    the full package information with the tag without using state-based
    parsing (i.e. checking for "N: Processing xyz ..." lines).
      It also disambiguates which package is being process without needing
    --verbose.  Optimally the normal output would add the extra fields as
    needed, but currently it does not.
    
    On the downside this format is a bit terse for human-readers and is
    probably not a good candidate as a default (interactive) output.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/frontend/lintian b/frontend/lintian
index 6dc0e17..c0c5a78 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -775,6 +775,9 @@ if (defined $experimental_output_opts) {
             } elsif ($opts{$_} eq 'xml') {
                 require Lintian::Output::XML;
                 $Lintian::Output::GLOBAL = Lintian::Output::XML->new;
+            } elsif ($opts{$_} eq 'fullewi') {
+                require Lintian::Output::FullEWI;
+                $Lintian::Output::GLOBAL = Lintian::Output::FullEWI->new;
             }
         }
         no strict 'refs';
diff --git a/lib/Lintian/Output.pm b/lib/Lintian/Output.pm
index c5b71fe..4077e3d 100644
--- a/lib/Lintian/Output.pm
+++ b/lib/Lintian/Output.pm
@@ -289,10 +289,7 @@ sub print_tag {
     $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($override);
-    my $type = '';
-    $type = " $pkg_info->{type}" if $pkg_info->{type} ne 'binary';
+    my $fpkg_info = $self->_format_pkg_info ($pkg_info, $tag_info, $override);
 
     my $tag;
     if ($self->_do_color) {
@@ -313,7 +310,7 @@ sub print_tag {
         $self->msg(@{ $override->comments } );
     }
 
-    $self->_print('', "$code: $pkg_info->{package}$type", "$tag$information");
+    $self->_print('', $fpkg_info, "$tag$information");
     if (not $self->issued_tag($tag_info->tag) and $self->showdescription) {
         my $description;
         if ($self->_do_color && $self->color eq 'html') {
@@ -327,6 +324,20 @@ sub print_tag {
     }
 }
 
+# Helper function to "print_tag" to decide the output format of the tag line.  Used by
+# the "FullEWI" subclass.
+#
+sub _format_pkg_info {
+    my ($self, $pkg_info, $tag_info, $override) = @_;
+    my $code = $tag_info->code;
+    $code = 'X' if $tag_info->experimental;
+    $code = 'O' if defined $override;
+    my $type = '';
+    $type = " $pkg_info->{type}" if $pkg_info->{type} ne 'binary';
+    return "$code: $pkg_info->{package}$type";
+}
+
+
 =item C<print_start_pkg($pkg_info)>
 
 Called before lintian starts to handle each package.  The version in
diff --git a/lib/Lintian/Output/FullEWI.pm b/lib/Lintian/Output/FullEWI.pm
new file mode 100644
index 0000000..8e2f9d7
--- /dev/null
+++ b/lib/Lintian/Output/FullEWI.pm
@@ -0,0 +1,66 @@
+# Copyright © 2011 Niels Thykier <niels@thykier.net>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, you can find it on the World Wide
+# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+package Lintian::Output::FullEWI;
+
+# The FullEWI always emit *full* package metadata even if it is
+# redundant (that is, optional values are always included) when
+# emitting tags.
+#   Other than that, it is identical to the normal output.
+#
+# When parsing a lintian.log written in format, it is no longer
+# ambigious which package is referred to (even if --verbose is
+# not used).
+#   This makes machine-parsing of the log easier, especially
+# when using the parsed data with the Lintian::Lab API.
+#
+# The full format of the emitted tag is:
+#
+#  C: name type (version) [arch]: tag [...]
+#
+# Note the "[...]" is the extra which may or may not be present
+# depending on the tag.
+#
+# Notable cases:
+# * binary packages include type classification
+# * source packages include an architecture, which is always
+#   "source".
+# * [arch] may contain spaces (and generally do for .changes)
+#   files.
+
+use strict;
+use warnings;
+
+use base qw(Lintian::Output);
+
+# Overridden from Lintian::Output
+sub _format_pkg_info {
+    my ($self, $pkg_info, $tag_info, $override) = @_;
+    my $code = $tag_info->code;
+    $code = 'X' if $tag_info->experimental;
+    $code = 'O' if defined $override;
+    my $version = $pkg_info->{version};
+    my $arch = '';
+    my $type = $pkg_info->{type};
+    $arch = "$pkg_info->{arch}" if $pkg_info->{type} ne 'source';
+    $arch = 'source' unless $arch;
+    return "$code: $pkg_info->{package} $type ($version) [$arch]";
+}
+
+1;
+

-- 
Debian package checker


Reply to: