[SCM] Debian package checker branch, master, updated. 2.5.6-45-g3502d02
The following commit has been merged in the master branch:
commit 3ad1640f5bd0e91fb83fba811ac4ed780203cef0
Author: Niels Thykier <niels@thykier.net>
Date: Fri Mar 16 15:09:15 2012 +0100
L::Data: Require a L::Profile before data files can be loaded
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/frontend/lintian b/frontend/lintian
index 92dd9e9..56fb402 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -828,7 +828,7 @@ if ($dont_check || %suppress_tags || $checks || $check_tags) {
}
$TAGS->profile ($PROFILE);
-
+Lintian::Data->set_vendor ($PROFILE);
# Initialize display level settings.
for my $level (@display_level) {
diff --git a/frontend/lintian-info b/frontend/lintian-info
index fcce0a7..d65689a 100755
--- a/frontend/lintian-info
+++ b/frontend/lintian-info
@@ -37,6 +37,7 @@ BEGIN {
# import perl libraries
use lib "$ENV{'LINTIAN_ROOT'}/lib";
+use Lintian::Data;
use Lintian::Internal::FrontendUtil;
use Lintian::Profile;
use Text_utils;
@@ -79,6 +80,8 @@ unless ($prof) {
}
$profile = Lintian::Profile->new($prof, $ENV{'LINTIAN_ROOT'}, \@proc_inc);
+Lintian::Data->set_vendor ($profile);
+
# If tag mode was specified, read the arguments as tags and display the
# descriptions for each one. (We don't currently display the severity,
# although that would be nice.)
diff --git a/lib/Lintian/Data.pm b/lib/Lintian/Data.pm
index 56baf5c..2d101d9 100644
--- a/lib/Lintian/Data.pm
+++ b/lib/Lintian/Data.pm
@@ -59,9 +59,7 @@ sub new {
sub _load_data {
my ($self, $type, $separator, $code) = @_;
unless (exists $data{$type}) {
- my $dir = $ENV{LINTIAN_ROOT} . '/data';
- open(my $fd, '<', "$dir/$type")
- or croak("unknown data type $type");
+ my $fd = $self->_open_data_file ($type);
local ($_, $.);
while (<$fd>) {
chomp;
@@ -88,9 +86,27 @@ sub new {
close $fd;
}
$self->{'data'} = $data{$type};
- }
+ }
}
+{
+ my $profile;
+ sub set_vendor {
+ my (undef, $vendor) = @_;
+ $profile = $vendor;
+ }
+
+ sub _open_data_file {
+ my ($self, $type) = @_;
+ my $dir = $ENV{LINTIAN_ROOT} . '/data';
+ croak "No vendor given" unless $profile;
+ open my $fd, '<', "$dir/$type"
+ or croak "unknown data type $type";
+ return $fd;
+ }
+}
+
+
sub _force_promise {
my ($self) = @_;
my $promise = $self->{promise};
@@ -200,6 +216,11 @@ A given file will only be loaded once. If new() is called again with the
same TYPE argument, the data previously loaded will be reused, avoiding
multiple file reads.
+=item set_vendor(PROFILE)
+
+Specifies vendor profile. It must be set before the first data file
+is loaded.
+
=back
=head1 INSTANCE METHODS
diff --git a/reporting/html_reports b/reporting/html_reports
index 6661387..e323980 100755
--- a/reporting/html_reports
+++ b/reporting/html_reports
@@ -50,6 +50,7 @@ $ENV{'LINTIAN_ROOT'} = $LINTIAN_ROOT;
# Import Lintian Perl libraries.
use lib "$ENV{LINTIAN_ROOT}/lib";
+use Lintian::Data;
use Lintian::Lab;
use Lintian::Profile;
use Lintian::Internal::FrontendUtil;
@@ -60,6 +61,8 @@ my $profile = Lintian::Profile->new (find_default_profile ("$LINTIAN_ROOT/profil
$LINTIAN_ROOT,
["$LINTIAN_ROOT/profiles"]);
+Lintian::Data->set_vendor ($profile);
+
# Set the Lintian version, current timestamp, and archive timestamp.
our $LINTIAN_VERSION = `$LINTIAN_ROOT/frontend/lintian --print-version`;
diff --git a/t/scripts/tags.t b/t/scripts/tags.t
index 35ca2bd..ae44f07 100755
--- a/t/scripts/tags.t
+++ b/t/scripts/tags.t
@@ -24,14 +24,20 @@ use warnings;
use Test::More qw(no_plan);
use Lintian::Check qw(check_spelling);
+use Lintian::Data;
+use Lintian::Profile;
use Lintian::Tags ();
use Util qw(read_dpkg_control);
+my $vendor = Lintian::Profile->new ('debian/main', $ENV{'LINTIAN_ROOT'},
+ ["$ENV{'LINTIAN_ROOT'}/profiles"]);
my @DESCS = <$ENV{'LINTIAN_ROOT'}/checks/*.desc>;
my %severities = map { $_ => 1 } 'pedantic', @Lintian::Tags::SEVERITIES;
my %certainties = map { $_ => 1 } @Lintian::Tags::CERTAINTIES;
+Lintian::Data->set_vendor ($vendor);
+
for my $desc_file (@DESCS) {
for my $i (read_dpkg_control($desc_file)) {
$desc_file =~ s#.*/##;
--
Debian package checker
Reply to: