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

[SCM] Debian package checker branch, lab-refactor, updated. 2.5.3-151-g2eec10a



The following commit has been merged in the lab-refactor branch:
commit 2eec10a9a90e7d222f730d0da337c6fec68017cd
Author: Niels Thykier <niels@thykier.net>
Date:   Thu Oct 27 17:11:18 2011 +0200

    Added method to visit all packages in the lab
    
    Use the new method to power "lintian --all" instead of parsing the
    manifest files directly.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/frontend/lintian b/frontend/lintian
index c0c5a78..7debb30 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -755,7 +755,6 @@ require Lintian::Command;
 import Lintian::Command qw(spawn reap);
 require Lintian::Internal::FrontendUtil;
 import Lintian::Internal::FrontendUtil;
-require Lintian::Internal::PackageList;
 require Lintian::ProcessablePool;
 require Lintian::Profile;
 require Lintian::Tag::Info;
@@ -925,10 +924,6 @@ $ENV{'LINTIAN_LAB'} = $opt{'LINTIAN_LAB'} = $LAB->dir;
 $pool = Lintian::ProcessablePool->new($LAB);
 # process package/file arguments
 
-# Store contents of the packages files in these if needed
-my ($src_info, $bin_info, $udeb_info);
-
-
 while (my $arg = shift) {
     # file?
     if (-f $arg) {
@@ -988,31 +983,13 @@ while (my $arg = shift) {
 }
 
 if ($check_everything) {
-    # make sure package info is available
-    $src_info  = load_pkg_list('source', "$opt{'LINTIAN_LAB'}/info/source-packages") unless $src_info;
-    $bin_info  = load_pkg_list('binary', "$opt{'LINTIAN_LAB'}/info/binary-packages") unless $bin_info;
-    $udeb_info = load_pkg_list('udeb', "$opt{'LINTIAN_LAB'}/info/udeb-packages") unless $udeb_info;
-
-    debug_msg(2, "pkg_mode = $pkg_mode");
-
-    if (($pkg_mode eq 'auto') or ($pkg_mode eq 'source')) {
-        for my $arg (sort $src_info->get_all) {
-            debug_msg(1, "doing stuff with $opt{'LINTIAN_ARCHIVEDIR'}/" . $src_info->get($arg)->{'file'});
-            $pool->add_file("$opt{'LINTIAN_ARCHIVEDIR'}/" . $src_info->get($arg)->{'file'});
-        }
-    }
-    if (($pkg_mode eq 'auto') or ($pkg_mode eq 'binary')) {
-        for my $arg (sort $bin_info->get_all) {
-            debug_msg(1, "doing stuff with $opt{'LINTIAN_ARCHIVEDIR'}/" . $bin_info->get($arg)->{'file'});
-            $pool->add_file("$opt{'LINTIAN_ARCHIVEDIR'}/" . $bin_info->get($arg)->{'file'});
-        }
-    }
-    if (($pkg_mode eq 'auto') or ($pkg_mode eq 'udeb')) {
-        for my $arg (sort $udeb_info->get_all) {
-            debug_msg(1, "doing stuff with $opt{'LINTIAN_ARCHIVEDIR'}/" . $udeb_info->get($arg)->{'file'});
-            $pool->add_file("$opt{'LINTIAN_ARCHIVEDIR'}/" . $udeb_info->get($arg)->{'file'});
-        }
-    }
+    my $t = $pkg_mode;
+    my $visitor = sub {
+        my ($lpkg) = @_;
+        $pool->add_proc ($lpkg);
+    };
+    $t = undef if $pkg_mode eq 'auto';
+    $LAB->visit_packages($visitor, $t);
 } elsif ($packages_file) {
     # process all packages listed in packages file?
     print STDERR "warning: --packages-file is deprecated and may be removed in a later release.\n";
@@ -1045,12 +1022,6 @@ if ($check_everything) {
     close $fd unless $opt{'packages-from-file'} eq '-';
 }
 
-# undef these as they are not needed any more and they give a cheap
-# extra 5+ MB of RAM back on lintian.d.o.
-undef $src_info;
-undef $bin_info;
-undef $udeb_info;
-
 # }}}
 
 # {{{ Some silent exit
@@ -1751,15 +1722,6 @@ sub clear_group_cache {
     return 1;
 }
 
-# Loads a package list using Lintian::Internal::PackageList and returns
-# the newly created object.
-sub load_pkg_list {
-    my ($pkg_type, $file) = @_;
-    my $plist = Lintian::Internal::PackageList->new($pkg_type);
-    $plist->read_list($file);
-    return $plist;
-}
-
 # }}}
 
 # {{{ Exit handler.
diff --git a/lib/Lintian/Lab.pm b/lib/Lintian/Lab.pm
index 810a99d..cb58778 100644
--- a/lib/Lintian/Lab.pm
+++ b/lib/Lintian/Lab.pm
@@ -294,6 +294,35 @@ sub get_package {
     return wantarray ? @entries : $entries[0];
 }
 
+=item $lab->visit_packages ($visitor[, $pkg_type])
+
+Passes each lab entry to visitor.  If $pkg_type is passed, then only
+entries of that time is passed.
+
+=cut
+
+sub visit_packages {
+    my ($self, $visitor, $type) = @_;
+    my @types;
+    push @types, $type if $type;
+    @types = keys %SUPPORTED_TYPES unless $type;
+    foreach my $pkg_type (@types) {
+        my $index = $self->_get_lab_index ($pkg_type);
+        my $intv = sub {
+            my ($me, $pkg_name, $pkg_version, $pkg_arch) = @_;
+            my $dir = $self->_pool_path ($pkg_name, $pkg_type, $pkg_version, $pkg_arch);
+            my $pp = $me->{'file'};
+            my $pkg_src = $me->{'source'}//$pkg_name;
+            my $pkg_src_version = $me->{'source-version'}//$pkg_version;
+            my $lentry = Lintian::Lab::Entry->new ($self, $pkg_name, $pkg_version, $pkg_arch,
+                                                   $pkg_type, $pp, $pkg_src, $pkg_src_version, $dir);
+            $visitor->($lentry, $pkg_name, $pkg_version, $pkg_arch);
+        };
+        $index->visit_all ($intv);
+    }
+}
+
+
 # Non-API method used by reporting to look up the manifest data via the Lab
 # rather than bypassing it.
 sub _get_lab_manifest_data {

-- 
Debian package checker


Reply to: