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

[lintian] 01/01: checks/patch-systems.{desc, pm}: Check for patch files under the debian/patches that are not mentioned in any series file. Thanks to Paul Wise for the idea. (Closes: #887817)



This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository lintian.

commit d911ec700edc9f54564db2cb6a18fdaeff570895
Author: Chris Lamb <lamby@debian.org>
Date:   Sun Jan 21 15:23:50 2018 +1100

    checks/patch-systems.{desc,pm}: Check for patch files under the debian/patches that are not mentioned in any series file. Thanks to Paul Wise for the idea. (Closes: #887817)
---
 checks/patch-systems.desc                          |  8 +++++++
 checks/patch-systems.pm                            | 26 ++++++++++++++++++++++
 debian/changelog                                   |  4 ++++
 t/tests/cruft-general-wig-pen/desc                 |  2 ++
 t/tests/legacy-scripts/desc                        |  1 +
 t/tests/legacy-scripts/tags                        |  1 +
 t/tests/patch-systems-dpatch-description/desc      |  1 +
 t/tests/patch-systems-dpatch-description/tags      |  1 +
 .../debian/patches/file-mentioned-in-vendor-series |  1 +
 .../debian/patches/file-not-referenced-in-series   |  1 +
 .../debian/debian/patches/series.vendorname        |  1 +
 .../patches/subdir/file-not-referenced-in-series-2 |  1 +
 t/tests/patch-systems-quilt-general/desc           |  1 +
 t/tests/patch-systems-quilt-general/tags           |  2 ++
 t/tests/patch-systems-quilt-no-depends/desc        |  4 ++--
 15 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/checks/patch-systems.desc b/checks/patch-systems.desc
index 4753554..a54e609 100644
--- a/checks/patch-systems.desc
+++ b/checks/patch-systems.desc
@@ -194,3 +194,11 @@ Info: This package build-depends on a patch system such as dpatch or
  can refer to <tt>/usr/share/doc/dpatch/README.source.gz</tt> for dpatch.
 Ref: policy 4.14
 
+Tag: patch-file-present-but-not-mentioned-in-series
+Severity: normal
+Certainty: certain
+Info: The specified patch is present under the <tt>debian/patches</tt>
+ directory but is not mentioned in any "series" or "00list" file.
+ .
+ This may mean that a patch was created with the intention of modifying
+ the package but is not being applied.
diff --git a/checks/patch-systems.pm b/checks/patch-systems.pm
index 24cc2b6..64d913c 100644
--- a/checks/patch-systems.pm
+++ b/checks/patch-systems.pm
@@ -48,6 +48,7 @@ sub run {
     return if not $droot;
     my $dpdir = $droot->resolve_path('patches');
     my $patch_series;
+    my %known_files;
 
     # Find debian/patches/series, assuming debian/patches is a (symlink to a)
     # dir.  There are cases, where it is a file (ctwm: #778556)
@@ -72,6 +73,7 @@ sub run {
               $dpdir->children;
             if ($opt_file and $opt_file->is_open_ok) {
                 my $fd = $opt_file->open;
+                $known_files{$opt_file->basename}++;
                 while(<$fd>) {
                     if (/DPATCH_OPTION_CPP=1/) {
                         $list_uses_cpp = 1;
@@ -82,6 +84,7 @@ sub run {
             }
             for my $list_file (@list_files) {
                 my @patches;
+                $known_files{$list_file->basename}++;
                 my $fd = $list_file->open;
                 while(<$fd>) {
                     chomp;
@@ -99,6 +102,7 @@ sub run {
 
                 # Check each patch.
                 foreach my $patch_name (@patches) {
+                    $known_files{$patch_name}++;
                     my $patch_file = $dpdir->child($patch_name);
                     $patch_file = $dpdir->child("${patch_name}.dpatch")
                       if not $patch_file;
@@ -221,6 +225,28 @@ sub run {
           if not $readme;
     }
 
+    #----- look for unreferenced files in debian/patches
+    if ($dpdir and $format ne '2.0') {
+        # Check all series filesf, including $vendor.series
+        foreach my $file ($dpdir->children) {
+            next unless $file =~ /\/series(\..+)?$/;
+            next unless $file->is_open_ok;
+            $known_files{$file->basename}++;
+            my $fd = $file->open;
+            while (<$fd>) {
+                $known_files{$1}++ if m{^\s*(\S+)};
+            }
+            close($fd);
+        }
+
+        foreach my $file ($dpdir->children('breadth-first')) {
+            # Use path relative to debian/patches for "subdir/foo"
+            my $name = substr($file, length $dpdir);
+            tag 'patch-file-present-but-not-mentioned-in-series', $name
+              unless $known_files{$name} or $file->is_dir;
+        }
+    }
+
     #----- general cruft checking:
     if ($uses_patch_system > 1) {
         tag 'more-than-one-patch-system';
diff --git a/debian/changelog b/debian/changelog
index 18d0afe..04e1f43 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,10 @@ lintian (2.5.71) UNRELEASED; urgency=medium
 
   * checks/files.pm:
     + [CL] Ignore Rust .rs files in extra-license-file.  (Closes: #887715)
+  * checks/patch-systems.{desc,pm}:
+    + [CL] Check for patch files under the debian/patches that are not
+      mentioned in any series file. Thanks to Paul Wise for the idea.
+      (Closes: #887817)
   * checks/python.{desc,pm}:
     + [CL] Don't emit "python-package-missing-depends-on-python" for debug
       packages
diff --git a/t/tests/cruft-general-wig-pen/desc b/t/tests/cruft-general-wig-pen/desc
index a8d5058..24aeee9 100644
--- a/t/tests/cruft-general-wig-pen/desc
+++ b/t/tests/cruft-general-wig-pen/desc
@@ -20,3 +20,5 @@ Test-For:
  diff-contains-svn-conflict-file
  diff-contains-svn-control-dir
  unsupported-source-format
+Test-Against:
+ patch-file-present-but-not-mentioned-in-series
diff --git a/t/tests/legacy-scripts/desc b/t/tests/legacy-scripts/desc
index 3a241c9..e91ece1 100644
--- a/t/tests/legacy-scripts/desc
+++ b/t/tests/legacy-scripts/desc
@@ -53,6 +53,7 @@ Test-For:
  package-installs-python-bytecode
  package-uses-debhelper-but-lacks-build-depends
  package-uses-deprecated-debhelper-compat-version
+ patch-file-present-but-not-mentioned-in-series
  patch-system-but-no-source-readme
  php-script-but-no-php-cli-dep
  php-script-with-unusual-interpreter
diff --git a/t/tests/legacy-scripts/tags b/t/tests/legacy-scripts/tags
index aba9fdd..6f63d5e 100644
--- a/t/tests/legacy-scripts/tags
+++ b/t/tests/legacy-scripts/tags
@@ -50,6 +50,7 @@ W: scripts source: debian-watch-file-should-use-sf-redirector line 8
 W: scripts source: debian-watch-file-specifies-old-upstream-version 5 line 8
 W: scripts source: debian-watch-file-uses-deprecated-sf-redirector-method line 5
 W: scripts source: package-uses-deprecated-debhelper-compat-version 1
+W: scripts source: patch-file-present-but-not-mentioned-in-series 03_specified_without_dpatch.dpatch
 W: scripts source: patch-system-but-no-source-readme
 W: scripts source: source-nmu-has-incorrect-version-number 6ds-1ubuntu0.5.10.1
 W: scripts: binary-without-manpage usr/bin/envfoo
diff --git a/t/tests/patch-systems-dpatch-description/desc b/t/tests/patch-systems-dpatch-description/desc
index dab83a6..48e8ed0 100644
--- a/t/tests/patch-systems-dpatch-description/desc
+++ b/t/tests/patch-systems-dpatch-description/desc
@@ -5,3 +5,4 @@ Extra-Build-Depends: dpatch
 Test-For:
  dpatch-index-references-non-existent-patch
  dpatch-missing-description
+ patch-file-present-but-not-mentioned-in-series
diff --git a/t/tests/patch-systems-dpatch-description/tags b/t/tests/patch-systems-dpatch-description/tags
index 518f640..d2e60e8 100644
--- a/t/tests/patch-systems-dpatch-description/tags
+++ b/t/tests/patch-systems-dpatch-description/tags
@@ -3,3 +3,4 @@ E: patch-systems-dpatch-description source: dpatch-index-references-non-existent
 E: patch-systems-dpatch-description source: dpatch-index-references-non-existent-patch 01_some_other_patch_thats_not_in_the_package.dpatch
 I: patch-systems-dpatch-description source: dpatch-missing-description 02_i_dont_have_a_description.patch
 I: patch-systems-dpatch-description source: dpatch-missing-description 04_i_dont_have_a_description_either.patch
+W: patch-systems-dpatch-description source: patch-file-present-but-not-mentioned-in-series 03_specified_without_dpatch.dpatch
diff --git a/t/tests/patch-systems-quilt-general/debian/debian/patches/file-mentioned-in-vendor-series b/t/tests/patch-systems-quilt-general/debian/debian/patches/file-mentioned-in-vendor-series
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/t/tests/patch-systems-quilt-general/debian/debian/patches/file-mentioned-in-vendor-series
@@ -0,0 +1 @@
+foo
diff --git a/t/tests/patch-systems-quilt-general/debian/debian/patches/file-not-referenced-in-series b/t/tests/patch-systems-quilt-general/debian/debian/patches/file-not-referenced-in-series
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/t/tests/patch-systems-quilt-general/debian/debian/patches/file-not-referenced-in-series
@@ -0,0 +1 @@
+foo
diff --git a/t/tests/patch-systems-quilt-general/debian/debian/patches/series.vendorname b/t/tests/patch-systems-quilt-general/debian/debian/patches/series.vendorname
new file mode 100644
index 0000000..4232ed0
--- /dev/null
+++ b/t/tests/patch-systems-quilt-general/debian/debian/patches/series.vendorname
@@ -0,0 +1 @@
+file-mentioned-in-vendor-series
diff --git a/t/tests/patch-systems-quilt-general/debian/debian/patches/subdir/file-not-referenced-in-series-2 b/t/tests/patch-systems-quilt-general/debian/debian/patches/subdir/file-not-referenced-in-series-2
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/t/tests/patch-systems-quilt-general/debian/debian/patches/subdir/file-not-referenced-in-series-2
@@ -0,0 +1 @@
+foo
diff --git a/t/tests/patch-systems-quilt-general/desc b/t/tests/patch-systems-quilt-general/desc
index e509842..b002a8a 100644
--- a/t/tests/patch-systems-quilt-general/desc
+++ b/t/tests/patch-systems-quilt-general/desc
@@ -10,3 +10,4 @@ Test-For:
  patch-system-but-direct-changes-in-diff
  quilt-patch-with-non-standard-options
  quilt-series-references-non-existent-patch
+ patch-file-present-but-not-mentioned-in-series
diff --git a/t/tests/patch-systems-quilt-general/tags b/t/tests/patch-systems-quilt-general/tags
index 257cee6..7eccf4a 100644
--- a/t/tests/patch-systems-quilt-general/tags
+++ b/t/tests/patch-systems-quilt-general/tags
@@ -4,5 +4,7 @@ E: patch-systems-quilt-general source: quilt-series-references-non-existent-patc
 E: patch-systems-quilt-general source: quilt-series-references-non-existent-patch some-nonexistent-patch
 W: patch-systems-quilt-general source: dpatch-build-dep-but-no-patch-list
 W: patch-systems-quilt-general source: more-than-one-patch-system
+W: patch-systems-quilt-general source: patch-file-present-but-not-mentioned-in-series file-not-referenced-in-series
+W: patch-systems-quilt-general source: patch-file-present-but-not-mentioned-in-series subdir/file-not-referenced-in-series-2
 W: patch-systems-quilt-general source: patch-system-but-direct-changes-in-diff README
 W: patch-systems-quilt-general source: quilt-patch-with-non-standard-options some-other-file
diff --git a/t/tests/patch-systems-quilt-no-depends/desc b/t/tests/patch-systems-quilt-no-depends/desc
index 515da6a..12e7d47 100644
--- a/t/tests/patch-systems-quilt-no-depends/desc
+++ b/t/tests/patch-systems-quilt-no-depends/desc
@@ -3,5 +3,5 @@ Version: 1.0
 Description: Test for quilt series but no B-D on quilt
 Test-For:
  quilt-series-but-no-build-dep
-
-
+Test-Against:
+ patch-file-present-but-not-mentioned-in-series

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: