[SCM] Debian package checker branch, master, updated. 2.5.10-56-g3a62926
The following commit has been merged in the master branch:
commit 6e47790f53e2849dc15c420ce5d1217e4e456b45
Author: Niels Thykier <niels@thykier.net>
Date: Mon Jul 16 23:18:11 2012 +0200
lintian: Move load_collections to L::I::FrontendUtils
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/frontend/lintian b/frontend/lintian
index 4948da2..7e5d390 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -1019,7 +1019,16 @@ if($action eq 'remove'){
# }}}
# {{{ Load information about collector scripts
-load_collections(\%collection_info, "$opt{'LINTIAN_ROOT'}/collection");
+{
+ my $load_coll = sub {
+ my ($cs) = @_;
+ my $coll = $cs->name;
+ debug_msg(2, "Read collector description for $coll ...");
+ $collection_info{$coll} = $cs;
+ };
+
+ load_collections ($load_coll, "$opt{'LINTIAN_ROOT'}/collection");
+}
# }}}
# {{{ determine which checks have been requested
@@ -1194,26 +1203,6 @@ exit $exit_code;
# {{{ Some subroutines
-# Given a ref to %collection_info and the path to the collection
-# directory, this will load all the collection information into
-# %collection_info.
-sub load_collections{
- my ($cinfo, $dirname) = @_;
- opendir(my $dir, $dirname)
- or fail("cannot read directory $dirname");
-
- for my $f (readdir($dir)) {
- next if $f =~ /^\./;
- next unless $f =~ /\.desc$/;
-
- debug_msg(2, "Reading collector description file $f ...");
- my $cs = Lintian::CollScript->new ("$dirname/$f");
- $cinfo->{$cs->name} = $cs;
- }
-
- closedir($dir);
-}
-
# Removes all collections with "Auto-Remove: yes"; takes a Lab::Package
# - depends on global variables %collection_info and %keep_coll
#
diff --git a/lib/Lintian/Internal/FrontendUtil.pm b/lib/Lintian/Internal/FrontendUtil.pm
index 664c518..4ef08a3 100644
--- a/lib/Lintian/Internal/FrontendUtil.pm
+++ b/lib/Lintian/Internal/FrontendUtil.pm
@@ -24,9 +24,10 @@ use base qw(Exporter);
use Dpkg::Vendor;
+use Lintian::CollScript;
use Lintian::Util qw(check_path fail);
-our @EXPORT = qw(&check_test_feature &find_default_profile);
+our @EXPORT = qw(check_test_feature find_default_profile load_collections);
# Check if we are testing a specific feature
# - e.g. vendor-libdpkg-perl
@@ -63,6 +64,28 @@ sub find_default_profile {
return lc($vendor);
}
+# load_collections ($visitor, $dirname)
+#
+# Load collections from $dirname and pass them to $visitor. $visitor
+# will be called once per collection as it has been loaded. The first
+# (and only) argument to $visitor is the collection as an instance of
+# Lintian::CollScript instance.
+sub load_collections {
+ my ($visitor, $dirname) = @_;
+
+ opendir my $dir, $dirname
+ or fail "cannot read directory $dirname: $!";
+
+ foreach my $file (readdir $dir) {
+ next if $file =~ m/^\./;
+ next unless $file =~ m/\.desc$/;
+ my $cs = Lintian::CollScript->new ("$dirname/$file");
+ $visitor->($cs);
+ }
+
+ closedir $dir;
+}
+
1;
# Local Variables:
--
Debian package checker
Reply to: