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

[SCM] Debian package checker branch, master, updated. 2.5.11-209-gdc7f4dd



The following commit has been merged in the master branch:
commit dc7f4dd7b8cb561ad3ce7c86aee364a6b39fd596
Author: Niels Thykier <niels@thykier.net>
Date:   Mon Apr 1 19:49:29 2013 +0200

    lintian: Use XDG_CONFIG_{HOME,DIRS} for the lintianrc file
    
    Accept (and prefer) XDG based paths for the lintianrc file.  At the
    same time, stop supporting "LINTIAN_ROOT/lintianrc".  This patch fixes
    the "config" part of #701477.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/debian/changelog b/debian/changelog
index f88f481..8e83272 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -168,7 +168,8 @@ lintian (2.5.12) UNRELEASED; urgency=low
       to work around #677530.
     + [NT] Add XS-Testsuite for autopkgtest tests.
     + [NT] Add Build-Depends on libtest-perl-critic-perl.
-    + [NT] Add (Build-)Depends on liblist-moreutils-perl.
+    + [NT] Add (Build-)Depends on liblist-moreutils-perl and
+      libfile-basedir-perl.
   * debian/lintian.install:
     + [NT] Install Test::Lintian in /usr/share/lintian/lib.
   * debian/rules:
@@ -197,6 +198,11 @@ lintian (2.5.12) UNRELEASED; urgency=low
     + [NT] Add new command line option "--ignore-lintian-env" to make
       lintian ignore all environment variables starting with LINTIAN_.
     + [NT] Add a new command line option --no-display-experimental.
+    + [NT] Also search for the lintianrc file in XDG_CONFIG_{HOME,DIRS}.
+      The default paths are now ~/.config/lintian/lintianrc and
+      /etc/xdg/lintian/lintianrc.  The previous lintianrc paths are
+      still accepted.
+    + [NT] Stop looking for lintianrc files in the LINTIAN_ROOT.
 
   * lib/*:
     + [NT] Use "parent" instead of the "base" pragma.
diff --git a/debian/control b/debian/control
index 58bdf47..15fb0b4 100644
--- a/debian/control
+++ b/debian/control
@@ -31,6 +31,7 @@ Build-Depends: binutils,
                libdpkg-perl,
                libdigest-sha-perl,
                libemail-valid-perl,
+               libfile-basedir-perl,
                libhtml-parser-perl,
                libipc-run-perl,
                liblist-moreutils-perl,
@@ -81,6 +82,7 @@ Depends: binutils,
          libdigest-sha-perl,
          libdpkg-perl,
          libemail-valid-perl,
+         libfile-basedir-perl,
          libipc-run-perl,
          liblist-moreutils-perl,
          libparse-debianchangelog-perl,
diff --git a/frontend/lintian b/frontend/lintian
index 6e3522b..0b7d5f2 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -691,15 +691,8 @@ if (defined $experimental_output_opts) {
 # search for configuration file if it was not set with --cfg
 # do not search the default locations if it was set.
 unless ($no_conf) {
-    if ($opt{'LINTIAN_CFG'}) {
-    } elsif (exists $ENV{'LINTIAN_CFG'} &&
-             -f ($opt{'LINTIAN_CFG'} = $ENV{'LINTIAN_CFG'})) {
-    } elsif (-f ($opt{'LINTIAN_CFG'} = $opt{'LINTIAN_ROOT'} . '/lintianrc')) {
-    } elsif ($opt{'user-dirs'} && exists $ENV{'HOME'} &&
-             -f ($opt{'LINTIAN_CFG'} = $ENV{'HOME'} . '/.lintianrc')) {
-    } elsif ($opt{'user-dirs'} && -f ($opt{'LINTIAN_CFG'} = '/etc/lintianrc')) {
-    } else {
-        $opt{'LINTIAN_CFG'} = '';
+    if (not $opt{'LINTIAN_CFG'}) {
+        $opt{'LINTIAN_CFG'} = _find_cfg_file() // '';
     }
 } else {
     $opt{'LINTIAN_CFG'} = '';
@@ -1502,6 +1495,42 @@ sub handle_lab_query {
     }
 }
 
+sub _find_cfg_file {
+    return $ENV{'LINTIAN_CFG'} if exists $ENV{'LINTIAN_CFG'} and -f $ENV{'LINTIAN_CFG'};
+
+    if ($opt{'user-dirs'}) {
+        my $rcfile;
+        {
+            # File::BaseDir sprews warnings if $ENV{'HOME'} is undef, so
+            # make sure it is defined when we load the module.  Though,
+            # we need to scope this, so $ENV{HOME} becomes undef again
+            # when we check for it later.
+            local $ENV{'HOME'} = $ENV{'HOME'} // '/nonexistent';
+            require File::BaseDir;
+            import File::BaseDir qw(config_home config_files);
+        };
+        # only accept config_home if either HOME or
+        # XDG_CONFIG_HOME was set.  If both are unset, then this
+        # will return the "bogus" path
+        # "/nonexistent/lintian/lintianrc" and we don't want that
+        # (in the however unlikely case that file actually
+        # exists).
+        $rcfile = config_home ('lintian/lintianrc')
+            if exists $ENV{'HOME'} or exists $ENV{'XDG_CONFIG_HOME'};
+        return $rcfile if defined $rcfile and -f $rcfile;
+        if (exists $ENV{'HOME'}) {
+            $rcfile = $ENV{'HOME'} . '/.lintianrc';
+            return $rcfile if -f $rcfile;
+        }
+        return '/etc/lintianrc' if -f '/etc/lintianrc';
+        # config_files checks that the file exists for us
+        $rcfile = config_files ('lintian/lintianrc');
+        return $rcfile if defined $rcfile and $rcfile ne '';
+
+    }
+
+    return; # None found
+}
 
 sub _find_changes {
     require Parse::DebianChangelog;
diff --git a/man/lintian.pod.in b/man/lintian.pod.in
index 96227aa..ee07ad5 100644
--- a/man/lintian.pod.in
+++ b/man/lintian.pod.in
@@ -423,9 +423,6 @@ B<lintian> will check this directory for (additional) profiles, data
 files, support libraries and checks.  The latter two implies that
 Lintian may attempt to I<load and execute code> from this directory.
 
-Unlike with the B<--root> option, B<lintian> will I<not> load
-collections nor the I<lintianrc> from this directory.
-
 This option may appear more than once; each time adding an additional
 directory.  Directories are searched in the order they appear on the
 command line.
@@ -476,9 +473,9 @@ These option can appear multiple times, in which case the of them
 to appear determines the result.
 
 Note that if the intention is only to disable the user's I<$HOME>,
-then unsetting $HOME may suffice.  Alternatively, I</etc> can be
-"re-added" by using I<--include-dir> (caveat: I</etc/lintianrc> will
-be ignored by this).
+then unsetting $HOME and $XDG_CONFIG_HOME may suffice.  Alternatively,
+I</etc> can be "re-added" by using I<--include-dir> (caveat:
+I</etc/lintianrc> will be ignored by this).
 
 If the intention is to avoid (unintentional) side-effects from the
 calling user, then this option could be combined with
@@ -544,17 +541,28 @@ With B<--all> this means check all udeb packages in the lab.
 
 Lintian looks for its configuration file in the following locations:
 
-The file name given with the --cfg option
-
 =over 4
 
-=item I<$LINTIAN_CFG>
+=item * The argument given to B<--cfg>
+
+=item * I<$LINTIAN_CFG>
+
+=item * I<$XDG_CONFIG_HOME/lintian/lintianrc>
+
+=item * I<$HOME/.lintianrc>
+
+Deprecated in Lintian/2.5.12 and newer (use the XDG based variant
+above)
+
+=item * I<XGD_DIR/lintian/lintianrc>
 
-=item I<$LINTIAN_ROOT/lintianrc>
+Where XGD_DIR is a directories listed in I<$XDG_CONFIG_DIRS> (or
+I</etc/xdg> if I<$XDG_CONFIG_DIRS> is unset).
 
-=item I<$HOME/.lintianrc>
+=item * I</etc/lintianrc>
 
-=item I</etc/lintianrc>
+Deprecated in Lintian/2.5.12 and newer (use the XDG based variant
+above)
 
 =back
 

-- 
Debian package checker


Reply to: