Niels wrote: > $dir->children('breadth-first')
That's the one! Updated WIP patch attached: commit 5e3e7c9e4254831eb91b28881ec550eb40f12fdd Author: Chris Lamb <la...@debian.org> Date: Sat Jan 20 21:16:35 2018 +1100 * checks/patch-systems.{desc,pm}: Check patch files under the debian/patches that are not mentioned in any series file. Thanks to Paul Wise, (Closes: #887817) checks/patch-systems.desc | 8 ++++++++ checks/patch-systems.pm | 10 ++++++++++ debian/changelog | 3 +++ 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/debian/patches/file-not-referenced-in-series | 1 + .../debian/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 ++ 11 files changed, 30 insertions(+) Regards, -- ,''`. : :' : Chris Lamb `. `'` la...@debian.org / chris-lamb.co.uk `-
>From 5e3e7c9e4254831eb91b28881ec550eb40f12fdd Mon Sep 17 00:00:00 2001 From: Chris Lamb <la...@debian.org> Date: Sat, 20 Jan 2018 21:16:35 +1100 Subject: [PATCH] * checks/patch-systems.{desc,pm}: Check patch files under the debian/patches that are not mentioned in any series file. Thanks to Paul Wise, (Closes: #887817) --- checks/patch-systems.desc | 8 ++++++++ checks/patch-systems.pm | 10 ++++++++++ debian/changelog | 3 +++ 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/debian/patches/file-not-referenced-in-series | 1 + .../debian/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 ++ 11 files changed, 30 insertions(+) create mode 100644 t/tests/patch-systems-quilt-general/debian/debian/patches/file-not-referenced-in-series create mode 100644 t/tests/patch-systems-quilt-general/debian/debian/patches/subdir/file-not-referenced-in-series-2 diff --git a/checks/patch-systems.desc b/checks/patch-systems.desc index 475355496..9f387f99d 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" 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 24cc2b6c8..714db2d0c 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 %patches_seen = ('series' => 1); # 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; + $patches_seen{$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; + $patches_seen{$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) { + $patches_seen{$patch_name}++; my $patch_file = $dpdir->child($patch_name); $patch_file = $dpdir->child("${patch_name}.dpatch") if not $patch_file; @@ -164,6 +168,7 @@ sub run { # Check each patch. foreach my $patch_filename (@patches) { + $patches_seen{$patch_filename}++; my $patch = $dpdir->resolve_path($patch_filename); if (not $patch or not $patch->is_file) { tag 'quilt-series-references-non-existent-patch', @@ -244,6 +249,11 @@ sub run { tag 'direct-changes-in-diff-but-no-patch-system', $files if (not $uses_patch_system); } + foreach my $file ($dpdir->children('breadth-first')) { + my $name = substr($file, length $dpdir); + tag 'patch-file-present-but-not-mentioned-in-series', $name + unless defined $patches_seen{$name}; + } return; } diff --git a/debian/changelog b/debian/changelog index 18d0afe61..cf4ac1f61 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,9 @@ 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 patch files under the debian/patches that are not + mentioned in any series file. Thanks to Paul Wise. (Closes: #887817) * checks/python.{desc,pm}: + [CL] Don't emit "python-package-missing-depends-on-python" for debug packages diff --git a/t/tests/legacy-scripts/desc b/t/tests/legacy-scripts/desc index 3a241c965..e91ece10a 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 aba9fddf1..6f63d5edd 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 dab83a64c..48e8ed016 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 518f640c9..d2e60e8b2 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-not-referenced-in-series b/t/tests/patch-systems-quilt-general/debian/debian/patches/file-not-referenced-in-series new file mode 100644 index 000000000..257cc5642 --- /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/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 000000000..257cc5642 --- /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 e50984249..b002a8a1e 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 257cee662..7eccf4aaa 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 -- 2.15.1