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

[SCM] Debian package checker branch, master, updated. 2.5.11-52-g4e8a61a



The following commit has been merged in the master branch:
commit 4e8a61a677f77187de0fd694b0e85f1433185bbb
Author: Niels Thykier <niels@thykier.net>
Date:   Sun Jan 6 19:30:48 2013 +0100

    lintian{,-info}: Add --[no-]user-dirs cmd option
    
    Add new command line option to disable loading data, profiles and
    config files from "user directories" ($HOME and /etc).  This option
    can be used to replace the (private) LINTIAN_INTERNAL_TESTSUITE
    environment variable.
    
    It is mostly useful cases where the user's setting should not affect
    the Lintian results (e.g. testsuites).
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/debian/changelog b/debian/changelog
index 6009492..44b2c60 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -36,6 +36,8 @@ lintian (2.5.12) UNRELEASED; urgency=low
   * frontend/lintian:
     + [NT] Remove "make-shift" lab-query support now that
       Lintian::Lab supports it.
+    + [NT] Add new command line option "--[no-]user-dirs" to disable
+      loading from $HOME/.lintian{rc,/} and /etc/lintian{rc,/}.
 
   * lib/Lintian/Collect.pm:
     + [NT] Add "is_non_free" method to easily check of a given
diff --git a/frontend/lintian b/frontend/lintian
index b7694a7..8a29ce0 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -87,19 +87,23 @@ my $allow_root = 0;             #flag for --allow-root switch
 my $keep_lab = 0;               #flag for --keep-lab switch
 
 my $no_conf = 0;                #flag for --no-cfg
-my %opt;                        #hash of some flags from cmd or cfg
 my %conf_opt;                   #names of options set in the cfg file
 
 my %group_cache = ();           # Cache to store groups in case of group
                                 # queries
+my %opt = (                     #hash of some flags from cmd or cfg
+                                # Init some cmd-line value defaults
+    # Allow user-dirs ($HOME/.lintian + /etc/lintian) by default
+    'user-dirs' => 1,
+);
 
 # The search path except $ENV{'LINTIAN_ROOT'}/--root LINTIAN_ROOT
 # which will be added later.
-my @prof_inc;
+my @search_dirs;
 # In some (rare) cases, $ENV{HOME} will not be available.
 # - Handle that gracefully by not emitting "Uninitialized ...".
-push @prof_inc, "$ENV{HOME}/.lintian" if defined $ENV{HOME};
-push @prof_inc, '/etc/lintian';
+push @search_dirs, "$ENV{HOME}/.lintian" if defined $ENV{HOME};
+push @search_dirs, '/etc/lintian';
 
 
 my $experimental_output_opts = undef;
@@ -501,6 +505,7 @@ my %opthash = (                 # ------------------ actions
                'root=s' => \$opt{'LINTIAN_ROOT'},
 
                'jobs|j:i' => \$opt{'jobs'},
+               'user-dirs!' => \$opt{'user-dirs'},
 
                # ------------------ package selection options
                'all|a' => \$check_everything,
@@ -558,6 +563,13 @@ if (defined $opt{'LINTIAN_ROOT'}) {
     $opt{'LINTIAN_ROOT'} = '/usr/share/lintian';
 }
 
+if (!$opt{'user-dirs'} or $ENV{'LINTIAN_INTERNAL_TESTSUITE'}){
+    # Remove the user part of the search dirs.
+    @search_dirs = ();
+}
+
+push @search_dirs, $opt{'LINTIAN_ROOT'};
+
 # environment variables overwrite settings in conf file, so load them now
 # assuming they were not set by cmd-line options
 foreach my $var (@ENV_VARS) {
@@ -653,9 +665,9 @@ unless ($no_conf) {
     } elsif (exists $ENV{'LINTIAN_CFG'} &&
              -f ($opt{'LINTIAN_CFG'} = $ENV{'LINTIAN_CFG'})) {
     } elsif (-f ($opt{'LINTIAN_CFG'} = $opt{'LINTIAN_ROOT'} . '/lintianrc')) {
-    } elsif (exists $ENV{'HOME'} &&
+    } elsif ($opt{'user-dirs'} && exists $ENV{'HOME'} &&
              -f ($opt{'LINTIAN_CFG'} = $ENV{'HOME'} . '/.lintianrc')) {
-    } elsif (-f ($opt{'LINTIAN_CFG'} = '/etc/lintianrc')) {
+    } elsif ($opt{'user-dirs'} && -f ($opt{'LINTIAN_CFG'} = '/etc/lintianrc')) {
     } else {
         $opt{'LINTIAN_CFG'} = '';
     }
@@ -749,12 +761,6 @@ foreach my $var (@MUST_EXPORT) {
 # (read: broken) paths.
 $ENV{'TMPDIR'} = $opt{'TMPDIR'} if defined $opt{'TMPDIR'};
 
-# If we are running the test suite we should ignore
-# user/system profiles.
-if ($ENV{'LINTIAN_INTERNAL_TESTSUITE'}){
-    @prof_inc = ();
-}
-
 if ($debug) {
     $opt{'verbose'} = 1;
     $ENV{'LINTIAN_DEBUG'} = $debug;
@@ -820,7 +826,7 @@ $TAGS->show_overrides($opt{'show-overrides'});
 $TAGS->sources(keys %display_source) if %display_source;
 
 $PROFILE = Lintian::Profile->new ($opt{'LINTIAN_PROFILE'},
-                                  [@prof_inc, $opt{'LINTIAN_ROOT'}]);
+                                  \@search_dirs);
 # Ensure $opt{'LINTIAN_PROFILE'} is defined
 $opt{'LINTIAN_PROFILE'} = $PROFILE->name unless defined $opt{'LINTIAN_PROFILE'};
 v_msg('Using profile ' . $PROFILE->name . '.');
diff --git a/frontend/lintian-info b/frontend/lintian-info
index 3816fa0..31ea465 100755
--- a/frontend/lintian-info
+++ b/frontend/lintian-info
@@ -43,13 +43,17 @@ use Lintian::Profile;
 
 my %already_displayed = ();
 my ($annotate, $tags, $help, $prof);
+my $user_dirs = 1; # Allow user dirs ($HOME/.lintian and /etc/lintian) by default
 my $profile;
+my @dirs = ();
+
 Getopt::Long::config('bundling', 'no_getopt_compat', 'no_auto_abbrev');
 GetOptions(
     'annotate|a' => \$annotate,
     'tags|t' => \$tags,
     'help|h' => \$help,
     'profile=s' => \$prof,
+    'user-dirs!' => \$user_dirs,
 ) or die("error parsing options\n");
 
 # help
@@ -68,7 +72,16 @@ EOT
     exit 0;
 }
 
-$profile = Lintian::Profile->new ($prof);
+if ($user_dirs) {
+    # If requested, include user dirs
+    push @dirs, "$ENV{'HOME'}/.lintian" if exists $ENV{'HOME'};
+    push @dirs, '/etc/lintian';
+}
+# Add the Lintian root in the end...
+push @dirs, $ENV{'LINTIAN_ROOT'} if exists $ENV{'LINTIAN_ROOT'};
+push @dirs, $ENV{'LINTIAN_ROOT'} unless exists $ENV{'LINTIAN_ROOT'};
+
+$profile = Lintian::Profile->new ($prof, \@dirs);
 
 Lintian::Data->set_vendor ($profile);
 
diff --git a/man/lintian-info.pod b/man/lintian-info.pod
index 30fd972..92df654 100644
--- a/man/lintian-info.pod
+++ b/man/lintian-info.pod
@@ -77,6 +77,16 @@ profiles.
 Rather than treating them as log file names, treat any command-line
 options as tag names and display the descriptions of each tag.
 
+=item B<--user-dirs>, B<--no-user-dirs>
+
+By default, B<lintian> will check I<$HOME> and I</etc> for files
+supplied by the user or the local sysadmin (e.g. profiles).  This
+default can be disabled (and re-enabled) by using B<--no-user-dirs>
+(and B<--user-dirs>, respectively).
+
+These option can appear multiple times, in which case the of them
+to appear determines the result.
+
 =back
 
 =head1 EXIT STATUS
diff --git a/man/lintian.pod.in b/man/lintian.pod.in
index 9b47b94..348a69b 100644
--- a/man/lintian.pod.in
+++ b/man/lintian.pod.in
@@ -396,6 +396,19 @@ Look for B<lintian>'s support files (such as check scripts and
 collection scripts) in rootdir.  This overrides the B<LINTIAN_ROOT>
 environment variable.  The default location is I</usr/share/lintian>.
 
+=item B<--user-dirs>, B<--no-user-dirs>
+
+By default, B<lintian> will check I<$HOME> and I</etc> for files
+supplied by the user or the local sysadmin (e.g. config files and
+profiles).  This default can be disabled (and re-enabled) by using
+B<--no-user-dirs> (and B<--user-dirs>, respectively).
+
+These options will I<not> affect the inclusion of LINTIAN_ROOT, which
+is always included.
+
+These option can appear multiple times, in which case the of them
+to appear determines the result.
+
 =back
 
 Package selection options:
diff --git a/private/runtests b/private/runtests
index d306bfd..f801c73 100755
--- a/private/runtests
+++ b/private/runtests
@@ -28,7 +28,6 @@ fi
 LC_ALL="C"
 LINTIAN_ROOT=""
 LINTIAN_PROFILE=debian
-LINTIAN_INTERNAL_TESTSUITE=1
 NO_PKG_MANGLE=true
 unset MAKEFLAGS
 # Ensure Lintian works without $ENV{HOME}
@@ -39,7 +38,6 @@ unset HOME
 export LC_ALL
 export LINTIAN_ROOT
 export LINTIAN_PROFILE
-export LINTIAN_INTERNAL_TESTSUITE
 export NO_PKG_MANGLE
 
 fail(){
diff --git a/t/runtests b/t/runtests
index e418fb3..3b9b5f6 100755
--- a/t/runtests
+++ b/t/runtests
@@ -479,7 +479,7 @@ sub run_lintian {
     my @options = split(' ', $testdata->{options}//'');
     my $cmd;
     my $ret;
-    unshift(@options, '--allow-root', '--no-cfg');
+    unshift @options, '--allow-root', '--no-cfg', '--no-user-dirs';
     unshift(@options, '--profile', $testdata->{profile}) if $testdata->{profile};
     my $pid = open my $in, '-|';
     fail "pipe/fork error: $!" unless defined $pid;
diff --git a/testset/runtests b/testset/runtests
index f297744..e6f96dd 100755
--- a/testset/runtests
+++ b/testset/runtests
@@ -182,8 +182,8 @@ for (@tests) {
     runsystem("cd $rundir/$pkgdir && dpkg-buildpackage $dpkg_buildpackage_options >../build.$pkg 2>&1");
 
     print "testing... ";
-    print "Running lintian --allow-root --no-cfg $lintian_options on $rundir/$pkg\_$ver*.changes...\n" if $debug;
-    runsystem_ok("$lintian_path --allow-root --no-cfg $lintian_options $rundir/$pkg\_$ver*.changes".
+    print "Running lintian --allow-root --no-cfg --no-user-dirs $lintian_options on $rundir/$pkg\_$ver*.changes...\n" if $debug;
+    runsystem_ok("$lintian_path --allow-root --no-cfg --no-user-dirs $lintian_options $rundir/$pkg\_$ver*.changes".
         " 2>&1 | sort > $rundir/tags.$pkg");
 
     # Run a sed-script if it exists, for tests that have slightly variable

-- 
Debian package checker


Reply to: