[SCM] Debian package checker branch, master, updated. 2.5.0-38-g12aabc0
The following commit has been merged in the master branch:
commit 12aabc078800af095d38a3f0f3f9462365fb9f6d
Author: Niels Thykier <niels@thykier.net>
Date: Wed Jun 8 22:19:00 2011 +0200
Allow some options to appear in lintianrc
Some options can now get a default value set in the
lintianrc file.
diff --git a/debian/changelog b/debian/changelog
index b83f314..14137a9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -78,6 +78,10 @@ lintian (2.5.1) UNRELEASED; urgency=low
- Explicitly depends on bzip2 to always support bz2 source packages.
- Added xz-utils as suggests - needed for .xz source packages.
+ * frontend/lintian:
+ + [NT] Allow some options to be put into the lintianrc file.
+ (Closes: #460350)
+
* lib/Lintian/Tags.pm:
+ [NT] Fixed a flaw in logic that gave incorrect results for
architecture dependent overrides. Thanks to Andreas Beckmann for
diff --git a/frontend/lintian b/frontend/lintian
index 1fff26e..9e085da 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -47,15 +47,9 @@ my $quiet = 0; #flag for -q|--quiet switch
my $debug = 0;
my $check_everything = 0; #flag for -a|--all switch
my $lintian_info = 0; #flag for -i|--info switch
-our $display_experimentaltags = 0; #flag for -E|--display-experimental switch
-our $display_pedantictags = 0; #flag for --pedantic switch
our $ftpmaster_tags = 0; #flag for -F|--ftp-master-rejects switch
-our $no_override = 0; #flag for -o|--no-override switch
-our $show_overrides = 0; #flag for --show-overrides switch
-my $color = 'never'; #flag for --color switch
my $check_checksums = 0; #flag for -m|--md5sums|--checksums switch
my $allow_root = 0; #flag for --allow-root switch
-my $fail_on_warnings = 0; #flag for --fail-on-warnings switch
my $keep_lab = 0; #flag for --keep-lab switch
my $packages_file = 0; #string for the -p option
our $OPT_LINTIAN_LAB = ''; #string for the --lab option
@@ -66,6 +60,8 @@ our $OPT_LINTIAN_AREA = ''; #string for the --area option
# These options can also be used via default or environment variables
our $LINTIAN_CFG = ''; #config file to use
our $LINTIAN_ROOT; #location of the lintian modules
+my %opt; #hash of some flags from cmd or cfg
+my %conf_opt; #names of options set in the cfg file
my $experimental_output_opts = undef;
@@ -354,6 +350,34 @@ sub record_display_source {
$display_source{$_[1]} = 1;
}
+# Process display-info and display-level options in cfg files
+# - dies if display-info and display-level are used together
+# - adds the relevant display level unless the command-line
+# added something to it.
+# - uses @display_level to track cmd-line appearences of
+# --display-level/--display-info
+sub cfg_display_level {
+ my ($var, $val) = @_;
+ if ($var eq 'display-info'){
+ die "display-info and display-level may not both appear in the config file.\n"
+ if $conf_opt{'display-level'};
+
+ return unless $val; # case "display-info=no"
+ push @display_level, [ '+', '>=', 'wishlist' ] unless @display_level;
+ } elsif ($var eq 'display-level'){
+ die "display-info and display-level may not both appear in the config file.\n"
+ if $conf_opt{'display-info'};
+
+ return if @display_level;
+ $val =~ s/^\s++//;
+ $val =~ s/\s++$//;
+ foreach my $dl (split m/\s++/, $val) {
+ record_display_level('display-level', $dl);
+ }
+ }
+
+}
+
# Hash used to process commandline options
my %opthash = ( # ------------------ actions
'setup-lab|S' => \&record_action,
@@ -377,21 +401,21 @@ my %opthash = ( # ------------------ actions
'quiet|q' => \$quiet,
# ------------------ behaviour options
- 'info|i' => \$lintian_info,
+ 'info|i' => \$opt{'info'},
'display-info|I' => \&display_infotags,
- 'display-experimental|E' => \$display_experimentaltags,
- 'pedantic' => \$display_pedantictags,
+ 'display-experimental|E' => \$opt{'display-experimental'},
+ 'pedantic' => \$opt{'pedantic'},
'display-level|L=s' => \&record_display_level,
'display-source=s' => \&record_display_source,
'suppress-tags=s' => \&record_suppress_tags,
'suppress-tags-from-file=s' => \&record_suppress_tags_from_file,
- 'no-override|o' => \$no_override,
- 'show-overrides' => \$show_overrides,
- 'color=s' => \$color,
+ 'no-override|o' => \$opt{'no-override'},
+ 'show-overrides' => \$opt{'show-overrides'},
+ 'color=s' => \$opt{'color'},
'unpack-info|U=s' => \&record_unpack_info,
'checksums|md5sums|m' => \$check_checksums,
'allow-root' => \$allow_root,
- 'fail-on-warnings' => \$fail_on_warnings,
+ 'fail-on-warnings' => \$opt{'fail-on-warnings'},
'keep-lab' => \$keep_lab,
# Note: Ubuntu has (and other derivatives might gain) a
@@ -419,6 +443,19 @@ my %opthash = ( # ------------------ actions
'exp-output:s' => \$experimental_output_opts,
);
+# Options that can appear in the config file
+my %cfghash = (
+ 'color' => \$opt{'color'},
+ 'display-experimental' => \$opt{'display-experimental'},
+ 'display-info' => \&cfg_display_level,
+ 'display-level' => \&cfg_display_level,
+ 'fail-on-warnings' => \$opt{'fail-on-warnings'},
+ 'info' => \$opt{'info'},
+ 'pedantic' => \$opt{'pedantic'},
+ 'no-override' => \$opt{'no-override'},
+ 'show-overrides' => \$opt{'show-overrides'},
+ );
+
# init commandline parser
Getopt::Long::config('bundling', 'no_getopt_compat', 'no_auto_abbrev');
@@ -447,11 +484,6 @@ if (($check_everything or $packages_file) and $#ARGV+1 > 0) {
undef $packages_file;
}
-# check permitted values for --color
-if ($color and $color !~ /^(?:never|always|auto|html)$/) {
- die "invalid argument to --color: $color\n";
-}
-
# check specified action
$action = 'check' unless $action;
@@ -509,12 +541,49 @@ if ($LINTIAN_CFG) {
}
}
unless ($found) {
+ # check if it is a config option
+ if (m/^\s*([-a-z]+)\s*=\s*(.*\S)\s*$/o){
+ my ($var, $val) = ($1, $2);
+ my $ref = $cfghash{$var};
+ die "Unknown configuration variable $var at line: ${.}.\n"
+ unless $ref;
+ if (exists $conf_opt{$var}){
+ print STDERR "Configuration variable $var appears more than once\n";
+ print STDERR " in $LINTIAN_CFG (line: $.) - Using the first value!\n";
+ next;
+ }
+ $conf_opt{$var} = 1;
+ $found = 1;
+ if ($val =~ m/^y(?:es)|true$/o){
+ $val = 1;
+ } elsif ($val =~ m/^no?|false$/o){
+ $val = 0;
+ }
+ if (ref $ref eq 'SCALAR'){
+ # Check it was already set
+ next if defined $$ref;
+ $$ref = $val;
+ } elsif (ref $ref eq 'CODE'){
+ $ref->($var, $val);
+ }
+
+ }
+ }
+ unless ($found) {
die "syntax error in configuration file: $_\n";
}
}
close(CFG);
}
+# check permitted values for --color / color
+# - We set the default to 'never' here; because we cannot do
+# it before the config check.
+$opt{'color'} = 'never' unless defined $opt{'color'};
+if ($opt{'color'} and $opt{'color'} !~ /^(?:never|always|auto|html)$/) {
+ die "The color value must be one of \"never\", \"always\", \"auto\" or \"html\"\n";
+}
+
# environment variables overwrite settings in conf file:
foreach (VARS) {
no strict 'refs';
@@ -605,8 +674,8 @@ if (defined $experimental_output_opts) {
$Lintian::Output::GLOBAL->verbose($verbose);
$Lintian::Output::GLOBAL->debug($debug);
$Lintian::Output::GLOBAL->quiet($quiet);
-$Lintian::Output::GLOBAL->color($color);
-$Lintian::Output::GLOBAL->showdescription($lintian_info);
+$Lintian::Output::GLOBAL->color($opt{'color'});
+$Lintian::Output::GLOBAL->showdescription($opt{'info'});
# Now that we can load the data, process the -F or --ftp-master-rejects
# option.
@@ -630,9 +699,9 @@ debug_msg(1,
);
our $TAGS = Lintian::Tags->new;
-$TAGS->show_experimental($display_experimentaltags);
-$TAGS->show_pedantic($display_pedantictags);
-$TAGS->show_overrides($show_overrides);
+$TAGS->show_experimental($opt{'display-experimental'});
+$TAGS->show_pedantic($opt{'pedantic'});
+$TAGS->show_overrides($opt{'show-overrides'});
$TAGS->sources(keys %display_source) if %display_source;
$TAGS->only(split(/,/, $check_tags)) if defined $check_tags;
$TAGS->suppress(keys %suppress_tags) if %suppress_tags;
@@ -985,7 +1054,7 @@ if ($action eq 'unpack') {
my $map = Lintian::DepMap::Properties->new();
my $collmap = Lintian::DepMap::Properties->new();
-unless ($no_override) {
+unless ($opt{'no-override'}) {
# add the override-file collection
$map->add('coll-override-file', {'type' => 'collection', 'name' => 'override-file'});
$collmap->add('coll-override-file', {'type' => 'collection', 'name' => 'override-file'});
@@ -1045,7 +1114,7 @@ foreach my $gname (sort $pool->get_group_names()) {
$TAGS->file_end();
-if ($action eq 'check' and not $no_override and not $show_overrides) {
+if ($action eq 'check' and not $opt{'no-override'} and not $opt{'show-overrides'}) {
my $errors = $overrides{errors} || 0;
my $warnings = $overrides{warnings} || 0;
my $info = $overrides{info} || 0;
@@ -1267,7 +1336,7 @@ sub auto_clean_package {
sub post_pkg_process_overrides{
my ($pkg_path) = @_;
# report unused overrides
- if (not $no_override) {
+ if (not $opt{'no-override'}) {
my $overrides = $TAGS->overrides($pkg_path);
for my $tag (sort keys %$overrides) {
@@ -1287,7 +1356,7 @@ sub post_pkg_process_overrides{
}
# Report override statistics.
- if (not $no_override and not $show_overrides) {
+ if (not $opt{'no-override'} and not $opt{'show-overrides'}) {
my $stats = $TAGS->statistics($pkg_path);
my $errors = $stats->{overrides}{types}{E} || 0;
my $warnings = $stats->{overrides}{types}{W} || 0;
@@ -1467,7 +1536,7 @@ sub process_group {
next;
}
- unless ($no_override) {
+ unless ($opt{'no-override'}) {
if ($collmap->done('coll-override-file')) {
debug_msg(1, 'Override file collected, loading it ...');
$TAGS->file_overrides("$base/override")
@@ -1511,7 +1580,7 @@ sub process_group {
my $stats = $TAGS->statistics($pkg_path);
if ($stats->{types}{E}) {
$exit_code = 1;
- } elsif ($fail_on_warnings && $stats->{types}{W}) {
+ } elsif ($opt{'fail-on-warnings'} && $stats->{types}{W}) {
$exit_code = 1;
}
}
diff --git a/man/lintian.pod.in b/man/lintian.pod.in
index c5cd16a..9d71650 100644
--- a/man/lintian.pod.in
+++ b/man/lintian.pod.in
@@ -165,6 +165,8 @@ use color, "auto" will use color only if the output is going to a
terminal, and "html" will use HTML E<lt>spanE<gt> tags with a color style
attribute (instead of ANSI color escape sequences).
+This option overrides the B<color> variable in the configuration file.
+
=item B<--display-source> X
Only display tags from the source X (e.g. the Policy Manual or the
@@ -186,23 +188,37 @@ and might still give surprising results. Feel free to ignore
Experimental messages that do not seem to make sense, though of course
bug reports are always welcomed (particularly if they include fixes).
+This option overrides the B<display-experimental> variable in the
+configuration file.
+
=item B<--fail-on-warnings>
By default, B<lintian> exits with 0 status if only warnings were
found. If this flag is given, exit with a status of 1 if either
warnings or errors are found.
+This option overrides the B<fail-on-warnings> variable in the
+configuration file.
+
=item B<-i>, B<--info>
Print explanatory information about each problem discovered in
addition to the lintian error tags. To print a long tag description
without running lintian, see L<lintian-info(1)>.
+This option overrides B<info> variable in the configuration file.
+
=item B<-I>, B<--display-info>
Display informational ("I:") tags as well. They are normally
suppressed. (This is equivalent to B<-L> ">=wishlist").
+This option overrides the B<display-info> variable in the
+configuration file.
+
+Note: B<display-level> and B<display-info> may not both appear in the
+configuration file.
+
=item B<--keep-lab>
By default, temporary labs will be removed after lintian is finished.
@@ -213,13 +229,6 @@ lab is located by running lintian with the B<--verbose> option.
For static (non-temporary) labs this option causes Lintian to skip
the automatical clean up of some collections.
-=item B<-l> n, B<--unpack-level> n
-
-Set unpack level to I<n>. See the L</UNPACK LEVELS> section, below.
-
-Note that the UNPACK LEVEL system is deprecated in favour of the
-L</COLLECTION> system.
-
=item B<-L> [+|-|=][>=|>|<|<=][S|C|S/C], B<--display-level> [+|-|=][>=|>|<|<=][S|C|S/C]
Fine-grained selection of tags to be displayed. It is possible to add,
@@ -229,6 +238,14 @@ possible, wild-guess), or both (S/C). The default settings are
equivalent to B<-L> ">=important" B<-L> "+>=normal/possible" B<-L>
+minor/certain).
+This option overrides the B<display-level> variable in the
+configuration file. The value of the B<display-level> in
+configuration file should be space separated entries in the same
+format as passed via command-line.
+
+Note: B<display-level> and B<display-info> may not both appear in the
+configuration file.
+
=item B<-m>, B<--md5sums>, B<--checksums>
Check checksums when processing a .changes file. Normally, Lintian
@@ -239,6 +256,9 @@ file.
Don't use the overrides file.
+This option overrides the B<overrides> variable in the configuration
+file.
+
=item B<--pedantic>
Display pedantic ("P:") tags as well. They are normally suppressed.
@@ -249,10 +269,16 @@ disagree with. Expect false positives and Lintian tags that you don't
consider useful if you use this option. Adding overrides for pedantic
tags is probably not worth the effort.
+This option overrides the B<pedantic> variable in the configuration
+file.
+
=item B<--show-overrides>
Output tags that have been overridden.
+This option overrides the B<show-overrides> variable in the
+configuration file.
+
=item B<--suppress-tags> tag1,tag2,...
Suppress the listed tags. They will not be reported if they occur and
@@ -393,11 +419,6 @@ B<.deb> file and to the lintian directory for the source package.
For source packages, the binary and fields directories are unpacked,
and symbolic links are made to the source package files.
-=item B<2 (contents)>
-
-This unpack level is deprecated and no longer functional. The
-I<unpacked> collection script replaced it.
-
=back
Lintian will unpack packages as far as is necessary to do its checks,
@@ -419,7 +440,7 @@ B<LINTIAN_UNPACK_LEVEL> variable in the configuration file.
Lintian looks for its configuration file in the following locations:
-The directory given with the --cfg option
+The file name given with the --cfg option
=over 4
--
Debian package checker
Reply to: