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

[lintian] 02/02: Warn about Python 3 packages that depend on Python 2 packages and vice versa. (Closes: #782277)



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

lamby pushed a commit to branch master
in repository lintian.

commit c7efe44809a27239201874df70a1dd0781e4ede0
Author: Chris Lamb <lamby@debian.org>
Date:   Sun Dec 24 20:04:23 2017 +0000

    Warn about Python 3 packages that depend on Python 2 packages and vice versa. (Closes: #782277)
---
 checks/python.desc                                 |  8 ++++----
 checks/python.pm                                   | 23 ++++++++++++----------
 debian/changelog                                   |  4 ++--
 .../debian/debian/control.in                       |  6 +++---
 .../desc                                           |  6 ++++++
 .../tags                                           |  7 +++++++
 .../desc                                           |  6 ------
 .../tags                                           |  4 ----
 8 files changed, 35 insertions(+), 29 deletions(-)

diff --git a/checks/python.desc b/checks/python.desc
index 38075b0..5144fb0 100644
--- a/checks/python.desc
+++ b/checks/python.desc
@@ -90,12 +90,12 @@ Info: The specified package declares a dependency on <tt>${python:Depends}</tt>
  .
  Please adjust the substvar to match the intended Python version.
 
-Tag: python-package-depends-on-variant-of-itself
+Tag: python-package-depends-on-package-from-other-python-variant
 Severity: normal
 Certainty: certain
-Info: Either the specified Python 3.x package declares a dependency on the
- Python 2.x version of itself, or specified Python 2.x package depends on
- the the Python 3.x version of itself.
+Info: Either the specified Python 3.x package declares a dependency on a
+ Python 2.x package, or the specified Python 2.x package depends on a Python
+ 3.x pakvage.
  .
  This is likely a typo in <tt>debian/control</tt> or due to misconfigured
  calls to, for example, <tt>dh_installdocs --link-doc=PKG</tt>.
diff --git a/checks/python.pm b/checks/python.pm
index 7899d92..6e26fa0 100644
--- a/checks/python.pm
+++ b/checks/python.pm
@@ -26,6 +26,7 @@ use autodie;
 use List::MoreUtils qw(any);
 
 use Lintian::Tags qw(tag);
+use Lintian::Relation qw(:constants);
 
 my @FIELDS = qw(Depends Pre-Depends Recommends Suggests);
 my @PYTHON2 = qw(python python2.7 python-dev);
@@ -112,17 +113,19 @@ sub _run_binary {
           if not $info->relation('strong')->implies($version);
     }
 
-    if ($pkg =~ /^python([23]?)-(.*)(?<!-doc)$/) {
-        my $version = $1 // '2'; # Assume python-foo is a Python 2.x package
-        my @candidates
-          = ($version eq '2')
-          ? ("python3-$2")
-          : ("python-$2", "python2-$2");
+    if ($pkg =~ /^python([23]?)-.*(?<!-doc)$/) {
+        my $version = $1 || '2'; # Assume python-foo is a Python 2.x package
+        my @prefixes = ($version eq '2') ? 'python3' : ('python', 'python2');
+
         for my $field (@FIELDS) {
-            for my $other (@candidates) {
-                tag 'python-package-depends-on-variant-of-itself',
-                  "($field: $other)"
-                  if $info->relation($field)->implies("$other:any");
+            for my $prefix (@prefixes) {
+                my $visit = sub {
+                    #<<< No tidy (tag name too long)
+                    tag 'python-package-depends-on-package-from-other-python-variant',
+                        "($field: $_)" if m/^$prefix-/;
+                    #>>>
+                };
+                $info->relation($field)->visit($visit, VISIT_PRED_NAME);
             }
         }
     }
diff --git a/debian/changelog b/debian/changelog
index 5d1f02c..b474ca1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -31,8 +31,8 @@ lintian (2.5.66) UNRELEASED; urgency=medium
       Python 3.x packages using ${python:Depends}. Thanks to Mattia
       Rizzolo for the idea.  (Closes: #884676)
     + [CL] Factor out definition of dependency fields.
-    + [CL] Warn about Python 3.x packages that depend on the Python 2.x
-      variants of themselves (and vice versa).  (Closes: #782277)
+    + [CL] Warn about Python 3 packages that depend on Python 2 packages
+      and vice versa.  (Closes: #782277)
   * checks/rules.{desc,pm}:
     + [CL] Check for override_dh_clean targets that are missing calls to
       dh_clean. Thanks to Andreas Beckmann for the idea.  (Closes: #884817)
diff --git a/t/tests/python-package-depends-on-variant-of-itself/debian/debian/control.in b/t/tests/python-package-depends-on-package-from-other-python-variant/debian/debian/control.in
similarity index 81%
rename from t/tests/python-package-depends-on-variant-of-itself/debian/debian/control.in
rename to t/tests/python-package-depends-on-package-from-other-python-variant/debian/debian/control.in
index eb1ed37..97f05dd 100644
--- a/t/tests/python-package-depends-on-variant-of-itself/debian/debian/control.in
+++ b/t/tests/python-package-depends-on-package-from-other-python-variant/debian/debian/control.in
@@ -8,7 +8,7 @@ Rules-Requires-Root: no
 
 Package: python-foo
 Architecture: all
-Depends: $\{misc:Depends\}, python2.7, python3-foo
+Depends: $\{misc:Depends\}, python2.7, python3-foo, python3-foo, python3-bar, python-falsepositive
 Description: Python 2 package depending on python3-foo
  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
@@ -17,7 +17,7 @@ Description: Python 2 package depending on python3-foo
 
 Package: python2-foo
 Architecture: all
-Depends: $\{misc:Depends\}, python2.7, python3-foo
+Depends: $\{misc:Depends\}, python2.7, python3-foo, python2-bar, python2-falsepositive
 Description: Python 2 package depending on python3-foo (explicit)
  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
@@ -28,7 +28,7 @@ Description: Python 2 package depending on python3-foo (explicit)
 
 Package: python3-foo
 Architecture: all
-Depends: $\{misc:Depends\}, python3, python-foo, python2-foo
+Depends: $\{misc:Depends\}, python3, python-foo, python2-foo, python2-bar, python3-falsepositive
 Description: Python 3 package depending on python-foo and python2-foo
  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
diff --git a/t/tests/python-package-depends-on-package-from-other-python-variant/desc b/t/tests/python-package-depends-on-package-from-other-python-variant/desc
new file mode 100644
index 0000000..a53a727
--- /dev/null
+++ b/t/tests/python-package-depends-on-package-from-other-python-variant/desc
@@ -0,0 +1,6 @@
+Testname: python-package-depends-on-package-from-other-python-variant
+Sequence: 6000
+Version: 1.0
+Description: Check for Python packages that depend on variants of themselves
+Test-For:
+ python-package-depends-on-package-from-other-python-variant
diff --git a/t/tests/python-package-depends-on-package-from-other-python-variant/tags b/t/tests/python-package-depends-on-package-from-other-python-variant/tags
new file mode 100644
index 0000000..bae9680
--- /dev/null
+++ b/t/tests/python-package-depends-on-package-from-other-python-variant/tags
@@ -0,0 +1,7 @@
+W: python-foo: python-package-depends-on-package-from-other-python-variant (Depends: python3-bar)
+W: python-foo: python-package-depends-on-package-from-other-python-variant (Depends: python3-foo)
+W: python-package-depends-on-package-from-other-python-variant source: intra-source-package-circular-dependency python-foo python2-foo python3-foo
+W: python2-foo: python-package-depends-on-package-from-other-python-variant (Depends: python3-foo)
+W: python3-foo: python-package-depends-on-package-from-other-python-variant (Depends: python-foo)
+W: python3-foo: python-package-depends-on-package-from-other-python-variant (Depends: python2-bar)
+W: python3-foo: python-package-depends-on-package-from-other-python-variant (Depends: python2-foo)
diff --git a/t/tests/python-package-depends-on-variant-of-itself/desc b/t/tests/python-package-depends-on-variant-of-itself/desc
deleted file mode 100644
index 228da85..0000000
--- a/t/tests/python-package-depends-on-variant-of-itself/desc
+++ /dev/null
@@ -1,6 +0,0 @@
-Testname: python-package-depends-on-variant-of-itself
-Sequence: 6000
-Version: 1.0
-Description: Check for Python packages that depend on variants of themselves
-Test-For:
- python-package-depends-on-variant-of-itself
diff --git a/t/tests/python-package-depends-on-variant-of-itself/tags b/t/tests/python-package-depends-on-variant-of-itself/tags
deleted file mode 100644
index 5333085..0000000
--- a/t/tests/python-package-depends-on-variant-of-itself/tags
+++ /dev/null
@@ -1,4 +0,0 @@
-W: python-package-depends-on-variant-of-itself source: intra-source-package-circular-dependency python-foo python2-foo python3-foo
-W: python2-foo: python-package-depends-on-variant-of-itself (Depends: python3-foo)
-W: python3-foo: python-package-depends-on-variant-of-itself (Depends: python-foo)
-W: python3-foo: python-package-depends-on-variant-of-itself (Depends: python2-foo)

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


Reply to: