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

[lintian] 01/01: Warn when files specified in Files-Excluded exist in the source. (Closes: #871454)



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

lamby pushed a commit to branch master
in repository lintian.

commit 0f8dde254cb281ed4aedd758a8602c6cfe80c4a1
Author: Chris Lamb <lamby@debian.org>
Date:   Tue Dec 5 11:30:20 2017 +0000

    Warn when files specified in Files-Excluded exist in the source. (Closes: #871454)
---
 checks/source-copyright.desc                       |  9 +++++++
 checks/source-copyright.pm                         | 30 ++++++++++++++++++++++
 debian/changelog                                   |  3 +++
 .../debian/.matches                                |  0
 .../debian/debian/copyright                        | 25 ++++++++++++++++++
 .../debian/exclude-dir-2/filename                  |  0
 .../debian/exclude-dir/filename                    |  0
 .../debian/exclude-dir/filename-2                  |  0
 .../debian/exclude-this                            |  0
 .../source-copyright-source-files-excluded/desc    |  5 ++++
 .../source-copyright-source-files-excluded/tags    |  4 +++
 11 files changed, 76 insertions(+)

diff --git a/checks/source-copyright.desc b/checks/source-copyright.desc
index ee5ef3e..2a4b851 100644
--- a/checks/source-copyright.desc
+++ b/checks/source-copyright.desc
@@ -311,3 +311,12 @@ Certainty: possible
 Ref: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
 Info: The <tt>Files</tt> paragraph in debian/copyright is superfluous as it is
  never used to match any files. You should be able to safely remove it.
+
+Tag: source-includes-file-in-files-excluded
+Severity: normal
+Certainty: possible
+Info: A file specified in the <tt>Files-Excluded</tt> header in
+ debian/copyright exists in the source tree.
+ .
+ This usually indicates that the upstream tarball was not repacked as
+ intended.
diff --git a/checks/source-copyright.pm b/checks/source-copyright.pm
index b8bf311..11ab949 100644
--- a/checks/source-copyright.pm
+++ b/checks/source-copyright.pm
@@ -240,6 +240,7 @@ sub _parse_dep5 {
               $renamed_to, "(line $lines[0]{$field})";
         }
     }
+    check_files_excluded($info, $first_para->{'files-excluded'} // '');
     if (    not defined $first_para->{'format'}
         and not defined $first_para->{'format-specification'}){
         tag 'missing-field-in-dep5-copyright', 'format',
@@ -612,6 +613,35 @@ sub get_all_files {
     return grep { $_->is_file } $info->sorted_index;
 }
 
+sub check_files_excluded {
+    my ($info, $excluded) = @_;
+    my @files = get_all_files($info);
+    my @wildcards = split /[\n\t ]+/, $excluded;
+    for my $wildcard (@wildcards) {
+        $wildcard =~ s/^\s+|\s+$//g;
+        if ($wildcard eq '') {
+            next;
+        }
+        my ($wc_value, $wc_type, $wildcard_error)= parse_wildcard($wildcard);
+        if (defined $wildcard_error) {
+            tag 'invalid-escape-sequence-in-dep5-copyright', $wildcard_error;
+            next;
+        }
+        if ($wc_type eq WC_TYPE_FILE) {
+            # Also match "dir/filename" for "Files-Excluded: dir"
+            $wc_value = qr/^${wc_value}(?:\/|$)/;
+        }
+        for my $srcfile (@files) {
+            if ($srcfile =~ $wc_value) {
+                tag 'source-includes-file-in-files-excluded',$srcfile;
+                last;
+            }
+        }
+    }
+
+    return;
+}
+
 1;
 
 # Local Variables:
diff --git a/debian/changelog b/debian/changelog
index 4c53cdb..3d7a50e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -16,6 +16,9 @@ lintian (2.5.61) UNRELEASED; urgency=medium
     + [CL] Warn if a "Team upload" (ie. that string is present in the
       changelog) but the uploader is among the Maintainer/Uploaders.
       (Closes: #882954)
+  * checks/source-copyright.{desc,pm}:
+    + [CL] Warn when files specified in Files-Excluded exist in the source
+      tree.  (Closes: #871454)
 
   * data/spelling/corrections:
     + [CL] Remove "german|German" and "russian|Russian" entries - they are
diff --git a/t/tests/source-copyright-source-files-excluded/debian/.matches b/t/tests/source-copyright-source-files-excluded/debian/.matches
new file mode 100644
index 0000000..e69de29
diff --git a/t/tests/source-copyright-source-files-excluded/debian/debian/copyright b/t/tests/source-copyright-source-files-excluded/debian/debian/copyright
new file mode 100644
index 0000000..291bb45
--- /dev/null
+++ b/t/tests/source-copyright-source-files-excluded/debian/debian/copyright
@@ -0,0 +1,25 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Files-Excluded: exclude-this
+ exclude-dir
+ */exclude-dir
+ exclude-dir-2/*
+ .*
+ */js/jquery.js
+
+Files: *
+Copyright: 2011 J. Random Hacker <j.r.hacker@example.com>
+License: GPL-2
+ This package 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; version 2 dated June, 1991.
+ .
+ This package 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 package; if not, write to the Free Software Foundation, Inc., 51 Franklin
+ St, Fifth Floor, Boston, MA 02110-1301, USA.
+ .
+ On Debian systems, the full text of the GNU General Public License version 2
+ can be found in the file `/usr/share/common-licenses/GPL-2'.
diff --git a/t/tests/source-copyright-source-files-excluded/debian/exclude-dir-2/filename b/t/tests/source-copyright-source-files-excluded/debian/exclude-dir-2/filename
new file mode 100644
index 0000000..e69de29
diff --git a/t/tests/source-copyright-source-files-excluded/debian/exclude-dir/filename b/t/tests/source-copyright-source-files-excluded/debian/exclude-dir/filename
new file mode 100644
index 0000000..e69de29
diff --git a/t/tests/source-copyright-source-files-excluded/debian/exclude-dir/filename-2 b/t/tests/source-copyright-source-files-excluded/debian/exclude-dir/filename-2
new file mode 100644
index 0000000..e69de29
diff --git a/t/tests/source-copyright-source-files-excluded/debian/exclude-this b/t/tests/source-copyright-source-files-excluded/debian/exclude-this
new file mode 100644
index 0000000..e69de29
diff --git a/t/tests/source-copyright-source-files-excluded/desc b/t/tests/source-copyright-source-files-excluded/desc
new file mode 100644
index 0000000..d0287a8
--- /dev/null
+++ b/t/tests/source-copyright-source-files-excluded/desc
@@ -0,0 +1,5 @@
+Testname: source-copyright-source-files-excluded
+Version: 1.0
+Description: Test for files listed in Files-Excluded
+Test-For:
+ source-includes-file-in-files-excluded
diff --git a/t/tests/source-copyright-source-files-excluded/tags b/t/tests/source-copyright-source-files-excluded/tags
new file mode 100644
index 0000000..a97aee4
--- /dev/null
+++ b/t/tests/source-copyright-source-files-excluded/tags
@@ -0,0 +1,4 @@
+W: source-copyright-source-files-excluded source: source-includes-file-in-files-excluded .matches
+W: source-copyright-source-files-excluded source: source-includes-file-in-files-excluded exclude-dir-2/filename
+W: source-copyright-source-files-excluded source: source-includes-file-in-files-excluded exclude-dir/filename
+W: source-copyright-source-files-excluded source: source-includes-file-in-files-excluded exclude-this

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


Reply to: