[SCM] Debian package checker branch, master, updated. 2.5.4-115-g3e2aa2a
The following commit has been merged in the master branch:
commit 623b9b5b478d8493a695bc4fe496622671c97dfa
Author: Niels Thykier <niels@thykier.net>
Date: Wed Jan 18 11:16:46 2012 +0100
Removed Checker module and reduced the "magic" of LINTIAN_ROOT
The code from the Checker module has been inlined into its own sub in
frontend/lintian. The extra module did not reduce the size of
f/lintian notabily and it allowed a reduction in the ways we propagate
LINTIAN_ROOT to modules.
Previously LINTIAN_ROOT needed to be exported as an ENV variable AND
as an "our $LINTIAN_ROOT". Now, only the ENV variable is needed.
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/frontend/lintian b/frontend/lintian
index 7333e34..03edddd 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -31,22 +31,14 @@ use Getopt::Long;
# {{{ Application Variables
-
-### LIST OF MAGIC VARIABLES
-#
-# List of variables that has a scope greater than this file in one
-# way or another.
+#### NOTE ABOUT LINTIAN_ROOT
#
-# $LINTIAN_ROOT
-# - must be "our" as it is used by Checker and Lab
-# - it is set after opt parsing and left at that; this allows it
-# to be trivially removed once Checker and Lab have been fixed.
+# Some of the Lintian modules need LINTIAN_ROOT (e.g. Lintian::Data)
+# and we supply it via $ENV{'LINTIAN_ROOT'}. This means that
+# $ENV{'LINTIAN_ROOT'} must generally always be update *before* we
+# load Lintian modules.
#
-# Please do not introduce any new magical variables, Thank You!
-#
-### END LIST OF MAGIC VARIABLES
-
-our $LINTIAN_ROOT;
+#### END NOTE ABOUT LINTIAN_ROOT
my @MUST_EXPORT = (qw(
LINTIAN_LAB
@@ -549,9 +541,6 @@ if (defined $opt{'LINTIAN_ROOT'}) {
$opt{'LINTIAN_ROOT'} = '/usr/share/lintian';
}
-## Update our MAGIC $LINTIAN_ROOT for the first and last time!
-$LINTIAN_ROOT = $opt{'LINTIAN_ROOT'};
-
# option --all and packages specified at the same time?
if (($check_everything or $packages_file or $opt{'packages-from-file'}) and $#ARGV+1 > 0) {
print STDERR "warning: options -a, -p and --packages-from-file cannot be mixed with package parameters!\n";
@@ -601,7 +590,7 @@ unless ($no_conf) {
if ($opt{'LINTIAN_CFG'}) {
} elsif (exists $ENV{'LINTIAN_CFG'} &&
-f ($opt{'LINTIAN_CFG'} = $ENV{'LINTIAN_CFG'})) {
- } elsif (-f ($opt{'LINTIAN_CFG'} = $LINTIAN_ROOT . '/lintianrc')) {
+ } elsif (-f ($opt{'LINTIAN_CFG'} = $opt{'LINTIAN_ROOT'} . '/lintianrc')) {
} elsif (exists $ENV{'HOME'} &&
-f ($opt{'LINTIAN_CFG'} = $ENV{'HOME'} . '/.lintianrc')) {
} elsif (-f ($opt{'LINTIAN_CFG'} = '/etc/lintianrc')) {
@@ -716,8 +705,8 @@ if ($debug) {
# Use our custom-generated locale for programs we call, if it's available. We
# first look in the Lintian root and then in /var/lib/lintian, which is the
# standard location for the install-time-generated locale.
-if (-d "$LINTIAN_ROOT/locale/en_US.UTF-8") {
- $ENV{LOCPATH} = "$LINTIAN_ROOT/locale";
+if (-d "$opt{'LINTIAN_ROOT'}/locale/en_US.UTF-8") {
+ $ENV{LOCPATH} = "$opt{'LINTIAN_ROOT'}/locale";
} elsif (-d '/var/lib/lintian/locale/en_US.UTF-8') {
$ENV{LOCPATH} = '/var/lib/lintian/locale';
}
@@ -732,7 +721,6 @@ require Lintian::Lab;
require Util;
import Util;
-require Checker;
require Lintian::Collect;
require Lintian::DepMap::Properties;
require Lintian::Data;
@@ -1125,7 +1113,7 @@ for my $c (keys %unpack_infos) {
for my $c (keys %enabled_checks) {
# Add the checks with their dependency information
- $map->add('check-' . $c, {'type' => 'check', 'name' => $c});
+ $map->add('check-' . $c, $PROFILE->get_script($c));
if (exists $check_info{$c}{'needs-info'}) {
$map->addp('check-' . $c, 'coll-', @{$check_info{$c}{'needs-info'}});
}
@@ -1597,8 +1585,8 @@ sub process_group {
}
while ($map->pending) {
foreach my $req (sort $map->selectable) {
- my $ri = $map->getProp($req);
- my $check = $ri->{'name'};
+ my $cs = $map->getProp($req);
+ my $check = $cs->name;
my $ci = $check_info{$check};
# current type?
@@ -1608,7 +1596,7 @@ sub process_group {
}
debug_msg(1, "Running check: $check ...");
- my $returnvalue = Checker::runcheck($pkg_name, $pkg_type, $info, $check, $proc, $group);
+ my $returnvalue = _run_check ($cs, $pkg_name, $pkg_type, $info, $proc, $group);
# Set exit_code correctly if there was not yet an exit code
$exit_code = $returnvalue unless $exit_code;
@@ -1820,6 +1808,30 @@ sub _update_profile {
}
}
+sub _run_check {
+ my ($cs, $pkg_name, @args) = @_;
+ my $check = $cs->name;
+ my $ret = 0;
+ my $cs_pkg = $cs->script_pkg;
+
+ debug_msg(1, "Running check: $check ...");
+
+ require "$opt{'LINTIAN_ROOT'}/checks/$check";
+
+ {
+ # minimal "no strict refs" scope.
+ no strict 'refs';
+ eval { &{'Lintian::' . $cs_pkg . '::run'}($pkg_name, @args); };
+ }
+
+ if ( $@ ) {
+ print STDERR $@;
+ print STDERR "internal error: cannot run $check check on package $pkg_name";
+ $ret = 2;
+ }
+ return $ret;
+}
+
# }}}
# {{{ Exit handler.
diff --git a/lib/Checker.pm b/lib/Checker.pm
deleted file mode 100644
index cbc9abb..0000000
--- a/lib/Checker.pm
+++ /dev/null
@@ -1,60 +0,0 @@
-# Checker -- Perl checker functions for lintian
-
-# Copyright (C) 2004 Jeroen van Wolffelaar
-#
-# 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 Checker;
-use strict;
-no strict 'refs';
-use warnings;
-
-# Quiet "Name "main::LINTIAN_ROOT" used only once"
-# The variable comes from 'lintian'
-() = $main::LINTIAN_ROOT;
-my $LINTIAN_ROOT = $main::LINTIAN_ROOT;
-my $debug = $::debug;
-
-sub runcheck {
- my ($pkg, $type, $info, $name, @args) = @_;
-
- # Will be set to 2 if error is encountered
- my $return = 0;
-
- print "N: Running check: $name ...\n" if $debug;
-
- # require has an anti-require-twice cache
- require "$LINTIAN_ROOT/checks/$name";
-
- $name =~ s/[-.]/_/g;
- eval { &{'Lintian::'.$name.'::run'}($pkg, $type, $info, @args) };
- if ( $@ ) {
- print STDERR $@;
- print STDERR "internal error: cannot run $name check on package $pkg\n";
- $return = 2;
- }
-
- return $return;
-}
-
-1;
-
-# Local Variables:
-# indent-tabs-mode: nil
-# cperl-indent-level: 4
-# End:
-# vim: syntax=perl sw=4 sts=4 sr et
diff --git a/t/scripts/pod-coverage.t b/t/scripts/pod-coverage.t
index c74ce93..8e662b7 100755
--- a/t/scripts/pod-coverage.t
+++ b/t/scripts/pod-coverage.t
@@ -13,7 +13,6 @@ plan skip_all => 'Test::Pod::Coverage is required for testing POD coverage'
# add underscores; personally, I (rra) think they make the code hard to read.
our %MODULES =
(
- 'Lintian::Check' => [],
'Lintian::CheckScript' => [],
'Lintian::Collect' => [],
'Lintian::Collect::Group' => [],
--
Debian package checker
Reply to: