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

[SCM] Debian package checker branch, master, updated. 2.0.0-13-g0094324



The following commit has been merged in the master branch:
commit 66ef13d69a5f0281c1e6440b73c48ce781cf77e0
Author: Frank Lichtenheld <djpig@debian.org>
Date:   Wed Sep 24 23:07:35 2008 +0200

    Lintian::Output: Add print_start_pkg and print_end_pkg hooks
    
    It might be useful to have the actual package meta information
    available in the output module to allow more flexible formats.

diff --git a/frontend/lintian b/frontend/lintian
index 628ae19..8b81066 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -1336,7 +1336,6 @@ foreach my $pkg_info ($schedule->get_all) {
     my $long_type = ($type eq 'b' ? 'binary' :
 		     ($type eq 's' ? 'source' : 'udeb' ));
 
-    v_msg(delimiter(), "Processing $long_type package $pkg (version $ver) ...");
     Tags::set_pkg( $file, $pkg, $ver, $arch, $long_type );
 
     # determine base directory
@@ -1610,6 +1609,7 @@ foreach my $pkg_info ($schedule->get_all) {
 	close(STATUS);
     }
 }
+Tags::reset_pkg();
 if ($action eq 'check' and not $no_override and not $show_overrides) {
     my $errors = $overrides{errors} || 0;
     my $warnings = $overrides{warnings} || 0;
diff --git a/lib/Lintian/Output.pm b/lib/Lintian/Output.pm
index 8547ff6..08a1e87 100644
--- a/lib/Lintian/Output.pm
+++ b/lib/Lintian/Output.pm
@@ -209,16 +209,47 @@ sub delimiter {
     return $self->_delimiter;
 }
 
+=item C<string($lead, @args)>
+
+TODO: Is this part of the public interface?
+
+=cut
+
+sub string {
+    my ($self, $lead, @args) = _global_or_object(@_);
+
+    my $output = '';
+    if (@args) {
+	foreach (@args) {
+	    $output .= $lead.': '.$_."\n";
+	}
+    } elsif ($lead) {
+	$output .= $lead.".\n";
+    }
+
+    return $output;
+}
+
+=back
+
+=head1 INSTANCE METHODS FOR CONTEXT-AWARE OUTPUT
+
+The following methods are designed to be called at specific points
+during program execution and require very specific arguments.  They
+can only be called as instance methods.
+
+=over 4
+
 =item C<print_tag($pkg_info, $tag_info, $extra)>
 
 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.  Tags::tag() is a wrapper around this.
+(if any) as an array reference.  Called from Tags::tag().
 
 =cut
 
 sub print_tag {
-    my ( $self, $pkg_info, $tag_info, $information ) = _global_or_object(@_);
+    my ($self, $pkg_info, $tag_info, $information) = @_;
 
     my $extra = '';
     $extra = " @$information" if @$information;
@@ -240,33 +271,38 @@ sub print_tag {
     $self->_print('', "$code: $pkg_info->{pkg}$type", "$tag$extra");
 }
 
-=item C<string($lead, @args)>
+=item C<print_start_pkg($pkg_info)>
 
-TODO: Is the part of the public interface?
+Called before lintian starts to handle each package.  The version in
+Lintian::Output uses v_msg() for output.  Called from Tags::select_pkg().
 
 =cut
 
-sub string {
-    my ($self, $lead, @args) = _global_or_object(@_);
+sub print_start_pkg {
+    my ($self, $pkg_info) = @_;
 
-    my $output = '';
-    if (@args) {
-	foreach (@args) {
-	    $output .= $lead.': '.$_."\n";
-	}
-    } elsif ($lead) {
-	$output .= $lead.".\n";
-    }
+    $self->v_msg($self->delimiter,
+		 "Processing $pkg_info->{type} package $pkg_info->{pkg} (version $pkg_info->{version}) ...");
+}
 
-    return $output;
+=item C<print_start_pkg($pkg_info)>
+
+Called after lintian is finished with a package.  The version in
+Lintian::Output does nothing.  Called from Tags::select_pkg() and
+Tags::reset_pkg().
+
+=cut
+
+sub print_end_pkg {
 }
 
 =back
 
-=head1 INSTANCE METHODS (for subclassing)
+=head1 INSTANCE METHODS FOR SUBCLASSING
 
 The following methods are only intended for subclassing and are
-only available as instance methods.  The methods mentioned above
+only available as instance methods.  The methods mentioned in
+L<CLASS/INSTANCE METHODS>
 usually only check whether they should do anything at all (according
 to the values of quiet, verbose, and debug) and then call one of
 the following methods to do the actual printing. Allmost all of them
diff --git a/lib/Lintian/Output/ColonSeparated.pm b/lib/Lintian/Output/ColonSeparated.pm
index ffbb5de..c738da7 100644
--- a/lib/Lintian/Output/ColonSeparated.pm
+++ b/lib/Lintian/Output/ColonSeparated.pm
@@ -27,7 +27,7 @@ use Lintian::Output qw(:util);
 use base qw(Lintian::Output);
 
 sub print_tag {
-    my ( $self, $pkg_info, $tag_info, $information ) = _global_or_object(@_);
+    my ($self, $pkg_info, $tag_info, $information) = @_;
 
     my $extra = "@$information";
 
diff --git a/lib/Lintian/Output/LetterQualifier.pm b/lib/Lintian/Output/LetterQualifier.pm
index 20aa9c8..eaffc42 100644
--- a/lib/Lintian/Output/LetterQualifier.pm
+++ b/lib/Lintian/Output/LetterQualifier.pm
@@ -93,7 +93,7 @@ sub new {
 
 
 sub print_tag {
-    my ( $self, $pkg_info, $tag_info, $information ) = @_;
+    my ($self, $pkg_info, $tag_info, $information) = @_;
 
     my $code = Tags::get_tag_code($tag_info);
     $code = 'X' if exists $tag_info->{experimental};
diff --git a/lib/Tags.pm b/lib/Tags.pm
index e3b5379..68723ba 100644
--- a/lib/Tags.pm
+++ b/lib/Tags.pm
@@ -111,8 +111,8 @@ sub set_pkg {
 	return 0;
     }
 
-    $current = $file;
     $info{$file} = {
+	file => $file,
 	pkg => $pkg,
 	version => $version,
 	arch => $arch,
@@ -125,6 +125,7 @@ sub set_pkg {
 	overrides => {},
     };
 
+    select_pkg($file);
     return 1;
 }
 
@@ -138,12 +139,19 @@ sub select_pkg {
 	return 0;
     }
 
+    if ($current) {
+	$Lintian::Output::GLOBAL->print_end_pkg($info{$current});
+    }
     $current = $file;
+    $Lintian::Output::GLOBAL->print_start_pkg($info{$current});
     return 1;
 }
 
 # only delete the value of 'current' without deleting any stored information
 sub reset_pkg {
+    if ($current) {
+	$Lintian::Output::GLOBAL->print_end_pkg($info{$current});
+    }
     undef $current;
     return 1;
 }

-- 
Debian package checker


Reply to: