[lintian] 01/01: Warn about Python 2.x packages using ${python3:Depends} and Python 3.x packages using ${python:Depends}. Thanks to Mattia Rizzolo for the idea. (Closes: #884676)
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository lintian.
commit 97add1aa71e9633861d3a4baaba40ab10aee85eb
Author: Chris Lamb <lamby@debian.org>
Date: Tue Dec 19 14:17:41 2017 +0000
Warn about Python 2.x packages using ${python3:Depends} and Python 3.x packages using ${python:Depends}. Thanks to Mattia Rizzolo for the idea. (Closes: #884676)
---
checks/python.desc | 9 ++++
checks/python.pm | 15 ++++++
debian/changelog | 4 ++
.../debian/debian/control.in | 55 ++++++++++++++++++++++
t/tests/python-mismatched-python-substvar/desc | 5 ++
t/tests/python-mismatched-python-substvar/tags | 4 ++
6 files changed, 92 insertions(+)
diff --git a/checks/python.desc b/checks/python.desc
index fa46519..bab9281 100644
--- a/checks/python.desc
+++ b/checks/python.desc
@@ -80,3 +80,12 @@ Info: This package appears to be library module for the Django web development
itself.
.
Please add a Depends on <tt>python-django</tt> or <tt>python3-django</tt>.
+
+Tag: mismatched-python-substvar
+Severity: normal
+Certainty: certain
+Info: The specified package declares a dependency on <tt>${python:Depends}</tt>
+ whilst appearing to be a Python 2.x package or a dependency on
+ <tt>${python3:Depends}</tt> when it appears to be a package for Python 2.x.
+ .
+ Please adjust the substvar to match the intended Python version.
diff --git a/checks/python.pm b/checks/python.pm
index 9be5ce2..66c8e2f 100644
--- a/checks/python.pm
+++ b/checks/python.pm
@@ -29,6 +29,11 @@ use Lintian::Tags qw(tag);
my @PYTHON2 = qw(python python2.7 python-dev);
+my %MISMATCHED_SUBSTVARS = (
+ '^python3-.+' => '${python:Depends}',
+ '^python2?-.+' => '${python3:Depends}',
+);
+
sub run {
my ($pkg, $type, $info) = @_;
@@ -63,6 +68,16 @@ sub _run_source {
if $info->field('build-depends', '')
=~ m,\bpython-sphinx\s+\|\s+python3-sphinx\b,g;
+ # Mismatched substvars
+ foreach my $regex (keys %MISMATCHED_SUBSTVARS) {
+ my $substvar = $MISMATCHED_SUBSTVARS{$regex};
+ for my $binpkg ($info->binaries) {
+ next if $binpkg !~ qr/$regex/;
+ tag 'mismatched-python-substvar', $binpkg, $substvar
+ if $info->binary_relation($binpkg, 'all')->implies($substvar);
+ }
+ }
+
return;
}
diff --git a/debian/changelog b/debian/changelog
index 58d8227..a53f4ff 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,10 @@ lintian (2.5.66) UNRELEASED; urgency=medium
+ [CL] Check for Microsoft Windows Portable Executable (PE) files that
are missing security hardening features. Thanks to Petter
Reinholdtsen for the report. (Closes: #837548)
+ * checks/python.{pm,desc}:
+ + [CL] Warn about Python 2.x packages using ${python3:Depends} and
+ Python 3.x packages using ${python:Depends}. Thanks to Mattia
+ Rizzolo for the idea. (Closes: #884676)
* t/tests/files-multiarch-foreign-files:
+ [CL] Don't hardcode architecture triplet to fix FTBFS on non-amd64
diff --git a/t/tests/python-mismatched-python-substvar/debian/debian/control.in b/t/tests/python-mismatched-python-substvar/debian/debian/control.in
new file mode 100644
index 0000000..5650697
--- /dev/null
+++ b/t/tests/python-mismatched-python-substvar/debian/debian/control.in
@@ -0,0 +1,55 @@
+Source: {$source}
+Priority: optional
+Section: {$section}
+Maintainer: {$author}
+Standards-Version: {$standards_version}
+Build-Depends: {$build_depends}
+Rules-Requires-Root: no
+
+Package: python-{$source}
+Section: python
+Architecture: all
+Depends: $\{misc:Depends\}, $\{python3:Depends\}
+Description: Mismatched substvar for Python 2.X
+ This is a test package designed to exercise some feature or tag of
+ Lintian. It is part of the Lintian test suite and may do very odd
+ things. It should not be installed like a regular package. It may
+ be an empty package.
+ .
+ For Python 2.X.
+
+Package: python3-{$source}
+Section: python
+Architecture: all
+Depends: $\{misc:Depends\}, $\{python:Depends\}
+Description: Mismatched substvar for Python 3.X
+ This is a test package designed to exercise some feature or tag of
+ Lintian. It is part of the Lintian test suite and may do very odd
+ things. It should not be installed like a regular package. It may
+ be an empty package.
+ .
+ For Python 3.X.
+
+Package: python-{$source}-nonrel
+Section: python
+Architecture: all
+Depends: $\{misc:Depends\}, $\{python:Depends\}
+Description: False positive for Python 2.X
+ This is a test package designed to exercise some feature or tag of
+ Lintian. It is part of the Lintian test suite and may do very odd
+ things. It should not be installed like a regular package. It may
+ be an empty package.
+ .
+ False positive package For Python 2.X.
+
+Package: python3-{$source}-nonrel
+Section: python
+Architecture: all
+Depends: $\{misc:Depends\}, $\{python3:Depends\}
+Description: False positive Python 3.X
+ This is a test package designed to exercise some feature or tag of
+ Lintian. It is part of the Lintian test suite and may do very odd
+ things. It should not be installed like a regular package. It may
+ be an empty package.
+ .
+ False positive package for Python 3.X.
diff --git a/t/tests/python-mismatched-python-substvar/desc b/t/tests/python-mismatched-python-substvar/desc
new file mode 100644
index 0000000..bebca57
--- /dev/null
+++ b/t/tests/python-mismatched-python-substvar/desc
@@ -0,0 +1,5 @@
+Testname: python-mismatched-python-substvar
+Version: 1.0
+Description: Check for Python packages with mismatched substvars.
+Test-For:
+ mismatched-python-substvar
diff --git a/t/tests/python-mismatched-python-substvar/tags b/t/tests/python-mismatched-python-substvar/tags
new file mode 100644
index 0000000..ade1108
--- /dev/null
+++ b/t/tests/python-mismatched-python-substvar/tags
@@ -0,0 +1,4 @@
+E: python-mismatched-python-substvar source: python-depends-but-no-python-helper python-python-mismatched-python-substvar-nonrel python3-python-mismatched-python-substvar
+E: python-mismatched-python-substvar source: python3-depends-but-no-python3-helper python-python-mismatched-python-substvar python3-python-mismatched-python-substvar-nonrel
+W: python-mismatched-python-substvar source: mismatched-python-substvar python-python-mismatched-python-substvar ${python3:Depends}
+W: python-mismatched-python-substvar source: mismatched-python-substvar python3-python-mismatched-python-substvar ${python:Depends}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: