Bug#637590: [checks/conffiles] merge with checks/etcfiles
Package: lintian
Version: 2.5.2
Severity: wishlist
Tags: patch
checks/conffiles and checks/etcfiles are both very short and there's
certain amount of code duplication between them. I propose to merge them
in to a single check.
--
Jakub Wilk
diff --git a/checks/conffiles b/checks/conffiles
--- a/checks/conffiles
+++ b/checks/conffiles
@@ -1,6 +1,7 @@
# conffiles -- lintian check script -*- perl -*-
# Copyright (C) 1998 Christian Schwarz
+# Copyright (C) 2000 Sean 'Shaleh' Perry
#
# 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
@@ -33,40 +34,55 @@
my $cf = $info->control('conffiles');
-# conffiles?
-unless (-f $cf) {
- return 0;
-}
my %conffiles = ();
-open(IN, '<', $cf) or fail("cannot open $cf for reading: $!");
-while (<IN>) {
- chop;
- next if m/^\s*$/;
+if (-f $cf) {
- unless (m,^/,) {
- tag 'relative-conffile', $_;
- $_ = '/' . $_;
+ open(IN, '<', $cf) or fail("cannot open $cf for reading: $!");
+ while (<IN>) {
+ chop;
+ next if m/^\s*$/;
+
+ unless (m,^/,) {
+ tag 'relative-conffile', $_;
+ $_ = '/' . $_;
+ }
+ my $file = $_;
+ $file =~ s@^/++@@o;
+ $conffiles{$file}++;
+
+ if ($conffiles{$file} > 1) {
+ tag 'duplicate-conffile', $file;
+ }
+
+ if (m,^/usr/,) {
+ tag 'file-in-usr-marked-as-conffile', $file;
+ } else {
+ unless (m,^/etc/,) {
+ tag 'non-etc-file-marked-as-conffile', $file;
+ }
+ }
+
}
- my $file = $_;
- $file =~ s@^/++@@o;
- $conffiles{$file}++;
-
- if ($conffiles{$file} > 1) {
- tag 'duplicate-conffile', $file;
- }
-
- if (m,^/usr/,) {
- tag 'file-in-usr-marked-as-conffile', $file;
- } else {
- unless (m,^/etc/,) {
- tag 'non-etc-file-marked-as-conffile', $file;
- }
- }
+ close(IN);
}
-close(IN);
+
+# Read package contents...
+foreach my $file (@{$info->sorted_index}) {
+ my $index_info = $info->index->{$file};
+ next unless $file =~ m,^etc, and $index_info->{type}=~ m/^[-h]/;
+
+ # If there is a /etc/foo, it must be a conffile (with a few exceptions).
+ if (not exists($conffiles{$file})
+ and $file !~ m,/README$,
+ and $file ne 'etc/init.d/skeleton'
+ and $file ne 'etc/init.d/rc'
+ and $file ne 'etc/init.d/rcS') {
+ tag 'file-in-etc-not-marked-as-conffile', $file;
+ }
+}
}
diff --git a/checks/conffiles.desc b/checks/conffiles.desc
--- a/checks/conffiles.desc
+++ b/checks/conffiles.desc
@@ -37,3 +37,10 @@
Usually, this is because debhelper (dh_installdeb, compat level 3 or higher)
will add any files in your package located in /etc automatically to the list
of conffiles, so if you do that manually too, you'll get duplicates.
+
+Tag: file-in-etc-not-marked-as-conffile
+Severity: serious
+Certainty: certain
+Ref: policy 10.7
+Info: Files in <tt>/etc</tt> must be marked conffiles if they are included
+ in a package. Otherwise they should be created by maintainer scripts.
diff --git a/checks/etcfiles b/checks/etcfiles
deleted file mode 100644
--- a/checks/etcfiles
+++ /dev/null
@@ -1,66 +0,0 @@
-# etcfiles -- lintian check script -*- perl -*-
-
-# Copyright (C) 2000 by Sean 'Shaleh' Perry
-#
-# 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 Lintian::etcfiles;
-use strict;
-use warnings;
-
-use Util;
-use Lintian::Tags qw(tag);
-
-sub run {
-
-my $pkg = shift;
-my $type = shift;
-my $info = shift;
-
-my %conffiles;
-
-my $conffiles = $info->control('conffiles');
-
-# load conffiles
-if (open(IN, '<', $conffiles)) {
- while (<IN>) {
- chop;
- next if m/^\s*$/o;
- s,^/,,;
- $conffiles{$_} = 1;
- }
- close(IN);
-}
-
-# Read package contents...
-foreach my $file (@{$info->sorted_index}) {
- my $index_info = $info->index->{$file};
- next unless $file =~ m,^etc, and $index_info->{type}=~ m/^[-h]/;
-
- # If there is a /etc/foo, it must be a conffile (with a few exceptions).
- if (not exists($conffiles{$file})
- and $file !~ m,/README$,
- and $file ne 'etc/init.d/skeleton'
- and $file ne 'etc/init.d/rc'
- and $file ne 'etc/init.d/rcS') {
- tag 'file-in-etc-not-marked-as-conffile', $file;
- }
-}
-
-}
-
-1;
diff --git a/checks/etcfiles.desc b/checks/etcfiles.desc
deleted file mode 100644
--- a/checks/etcfiles.desc
+++ /dev/null
@@ -1,14 +0,0 @@
-Check-Script: etcfiles
-Author: Sean 'Shaleh' Perry <shaleh@debian.org>
-Abbrev: etc
-Type: binary
-Info: Checks if all files in /etc that are shipped with the package are
- marked as conffiles as required by policy.
-Needs-info: bin-pkg-control, index
-
-Tag: file-in-etc-not-marked-as-conffile
-Severity: serious
-Certainty: certain
-Ref: policy 10.7
-Info: Files in <tt>/etc</tt> must be marked conffiles if they are included
- in a package. Otherwise they should be created by maintainer scripts.
diff --git a/profiles/debian/main.profile b/profiles/debian/main.profile
--- a/profiles/debian/main.profile
+++ b/profiles/debian/main.profile
@@ -4,8 +4,8 @@
Enable-Tags-From-Check: binaries, changelog-file, changes-file, circular-deps, conffiles,
control-file, control-files, copyright-file, cruft, deb-format, debconf,
debhelper, debian-readme, debian-source-dir, description, duplicate-files,
- etcfiles, fields, filename-length, files, huge-usr-share, infofiles, init.d,
- java, lintian, manpages, md5sums, menu-format, menus, nmu, ocaml, patch-systems,
+ fields, filename-length, files, huge-usr-share, infofiles, init.d, java,
+ lintian, manpages, md5sums, menu-format, menus, nmu, ocaml, patch-systems,
po-debconf, rules, scripts, shared-libs, standards-version, symlinks,
version-substvars, watch-file
diff --git a/t/tests/etcfiles-etc-not-marked/debian/debian/install b/t/tests/conffiles-etc-not-marked/debian/debian/install
rename from t/tests/etcfiles-etc-not-marked/debian/debian/install
rename to t/tests/conffiles-etc-not-marked/debian/debian/install
diff --git a/t/tests/etcfiles-etc-not-marked/debian/debian/rules b/t/tests/conffiles-etc-not-marked/debian/debian/rules
rename from t/tests/etcfiles-etc-not-marked/debian/debian/rules
rename to t/tests/conffiles-etc-not-marked/debian/debian/rules
diff --git a/t/tests/etcfiles-etc-not-marked/debian/something.conf b/t/tests/conffiles-etc-not-marked/debian/something.conf
rename from t/tests/etcfiles-etc-not-marked/debian/something.conf
rename to t/tests/conffiles-etc-not-marked/debian/something.conf
diff --git a/t/tests/etcfiles-etc-not-marked/desc b/t/tests/conffiles-etc-not-marked/desc
rename from t/tests/etcfiles-etc-not-marked/desc
rename to t/tests/conffiles-etc-not-marked/desc
--- a/t/tests/etcfiles-etc-not-marked/desc
+++ b/t/tests/conffiles-etc-not-marked/desc
@@ -1,4 +1,4 @@
-Testname: etcfiles-etc-not-marked
+Testname: conffiles-etc-not-marked
Sequence: 6000
Version: 1.0
Description: Test checking etc files not being marked as conffiles
diff --git a/t/tests/etcfiles-etc-not-marked/tags b/t/tests/conffiles-etc-not-marked/tags
rename from t/tests/etcfiles-etc-not-marked/tags
rename to t/tests/conffiles-etc-not-marked/tags
--- a/t/tests/etcfiles-etc-not-marked/tags
+++ b/t/tests/conffiles-etc-not-marked/tags
@@ -1,1 +1,1 @@
-E: etcfiles-etc-not-marked: file-in-etc-not-marked-as-conffile etc/something.conf
+E: conffiles-etc-not-marked: file-in-etc-not-marked-as-conffile etc/something.conf
Reply to: