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

[lintian] 02/02: Refactor django-package-does-not-depend-on-django check to correctly check Django packages called python2-django-foo.



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

lamby pushed a commit to branch master
in repository lintian.

commit cf15803c922406e85b5a4d21077aca9f198459f2
Author: Chris Lamb <lamby@debian.org>
Date:   Fri Dec 29 14:25:50 2017 +0000

    Refactor django-package-does-not-depend-on-django check to correctly check Django packages called python2-django-foo.
---
 checks/python.pm                                         | 16 ++++++++++------
 debian/changelog                                         |  2 ++
 .../debian/debian/control.in                             | 11 +++++++++++
 .../python-django-package-does-not-depend-on-django/tags |  1 +
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/checks/python.pm b/checks/python.pm
index cb7a3dd..a8e9c5f 100644
--- a/checks/python.pm
+++ b/checks/python.pm
@@ -32,6 +32,10 @@ my @FIELDS = qw(Depends Pre-Depends Recommends Suggests);
 my @IGNORE = qw(-dev$ -docs?$ -common$ -tools$);
 my @PYTHON2 = qw(python python2.7 python-dev);
 
+my %DJANGO_PACKAGES = (
+    '^python3-django-' => 'python3-django',
+    '^python2?-django-' => 'python-django',
+);
 my %MISMATCHED_SUBSTVARS = (
     '^python3-.+' => '${python:Depends}',
     '^python2?-.+' => '${python3:Depends}',
@@ -109,12 +113,12 @@ sub _run_binary {
     }
 
     # Django modules
-    if (    $pkg =~ /^(python[23]?-django)-/
-        and $pkg !~ /^python3?-django$/
-        and none { $pkg =~ m/$_$/ } @IGNORE) {
-        my $version = $1;
-        tag 'django-package-does-not-depend-on-django', $version
-          if not $info->relation('strong')->implies($version);
+    foreach my $regex (keys %DJANGO_PACKAGES) {
+        my $basepkg = $DJANGO_PACKAGES{$regex};
+        next if $pkg !~ /$regex/;
+        next if $pkg =~ /^python3?-django$/;
+        tag 'django-package-does-not-depend-on-django', $basepkg
+          if not $info->relation('strong')->implies($basepkg);
     }
 
     if ($pkg =~ /^python([23]?)-/ and none { $pkg =~ /$_/ } @IGNORE) {
diff --git a/debian/changelog b/debian/changelog
index ea18eda..24cb22b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -17,6 +17,8 @@ lintian (2.5.67) UNRELEASED; urgency=medium
       intra-Python variant dependency checking, python-but-no-python3, etc.
     + [CL] Drop parens in depends-on-package-from-other-python-variant
       output.
+    + [CL] Refactor django-package-does-not-depend-on-django check to
+      correctly check Django packages called python2-django-foo.
   * checks/rules.{desc.pm}:
     + [CL] Suggest using /usr/share/dpkg/architecture.mk as a solution to
       debian-rules-sets-dpkg-architecture-variable rather than simply
diff --git a/t/tests/python-django-package-does-not-depend-on-django/debian/debian/control.in b/t/tests/python-django-package-does-not-depend-on-django/debian/debian/control.in
index ffd6462..3e3970e 100644
--- a/t/tests/python-django-package-does-not-depend-on-django/debian/debian/control.in
+++ b/t/tests/python-django-package-does-not-depend-on-django/debian/debian/control.in
@@ -15,6 +15,17 @@ Description: Python 2 package without corresponding python-django dependency
  things.  It should not be installed like a regular package.  It may
  be an empty package.
 
+Package: python2-django-positive
+Architecture: all
+Depends: $\{misc:Depends\}, python2.7
+Description: Python 2 package without corresponding python-django dependency (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
+ things.  It should not be installed like a regular package.  It may
+ be an empty package.
+ .
+ Explicit Python 2 variant.
+
 Package: python3-django-positive
 Architecture: all
 Depends: $\{misc:Depends\}, python3
diff --git a/t/tests/python-django-package-does-not-depend-on-django/tags b/t/tests/python-django-package-does-not-depend-on-django/tags
index 1871794..70e503b 100644
--- a/t/tests/python-django-package-does-not-depend-on-django/tags
+++ b/t/tests/python-django-package-does-not-depend-on-django/tags
@@ -1,2 +1,3 @@
 W: python-django-positive: django-package-does-not-depend-on-django python-django
+W: python2-django-positive: django-package-does-not-depend-on-django python-django
 W: python3-django-positive: django-package-does-not-depend-on-django python3-django

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


Reply to: