Bug#582511: [checks/debhelper] check for dh + ${python:Depends} but no Python helper
Reply-To:
In-Reply-To: <20110820142645.GA429@jwilk.net>
tags 582511 + patch
thanks
I run the check for all the packages that had "python:Depends" or
"python3:Depends" in their debian/control and there were:
- at least a dozen of true positives;
- a few sort-of false positives caused by the fact that
${python:Depends} was used though it wasn't actually needed;
- one "serious" false positive: rpm.
To deal correctly with rpm, one would have to track and expand
variables. It'd like to postpone it for indefinite future, and I'm
marking the tags as experimental for the moment.
--
Jakub Wilk
diff --git a/checks/debhelper b/checks/debhelper
--- a/checks/debhelper
+++ b/checks/debhelper
@@ -81,6 +81,9 @@
my $seenmaintscript = 0;
my $bdepends_noarch;
my $bdepends;
+my $seen_dh = 0;
+my $seen_python_helper = 0;
+my $seen_python3_helper = 0;
open(RULES, '<', "$droot/rules") or fail("cannot read debian/rules: $!");
@@ -108,13 +111,21 @@
}
if ($dhcommand eq 'dh_python') {
tag 'dh_python-is-obsolete', "line $.";
+ $seen_python_helper = 1;
}
if ($dhcommand eq 'dh_pycentral') {
tag 'dh_pycentral-is-obsolete', "line $.";
+ $seen_python_helper = 1;
}
if ($dhcommand eq 'dh_installmanpages') {
tag 'dh_installmanpages-is-obsolete', "line $.";
}
+ if ($dhcommand eq 'dh_python3') {
+ $seen_python3_helper = 1;
+ }
+ if ($dhcommand =~ m,^dh_(?:pysupport$|python(?:2$|\$.*)),) {
+ $seen_python_helper = 1;
+ }
# Don't warn about recently deprecated commands in code that may be
# optional. It may be there only for backports.
@@ -153,6 +164,7 @@
$seencommand = 1;
$needbuilddepends = 1;
} elsif (m,^\s+dh\s+,) {
+ $seen_dh = 1;
$seencommand = 1;
$needbuilddepends = 1;
$needtomodifyscripts = 1;
@@ -165,8 +177,16 @@
if (defined $depends) {
$missingbdeps_addons{$depends} = $addon;
}
+ if ($addon =~ m,python(?:2|_central|_support)$,) {
+ $seen_python_helper = 1;
+ } elsif ($addon eq 'python3') {
+ $seen_python3_helper = 1;
+ }
}
}
+ if ($seen_python_helper == 0) {
+ $seen_python_helper = -1; # maybe; we'll check that later
+ }
} elsif (m,^include\s+/usr/share/cdbs/1/rules/debhelper.mk,) {
$seencommand = 1;
$needbuilddepends = 1;
@@ -405,6 +425,37 @@
tag 'temporary-debhelper-file', "$f$otext";
}
+if ($seen_python_helper == -1 and $level >= 9) {
+ $seen_python_helper = 0;
+}
+if ($seen_dh and $seen_python_helper != 1) {
+ my %python_depends = ();
+ for my $binpkg (keys %$pkgs) {
+ if ($info->binary_relation($binpkg, 'all')->implies('${python:Depends}')) {
+ $python_depends{$binpkg} = 1;
+ }
+ }
+ if (%python_depends) {
+ if ($seen_python_helper == -1) {
+ $seen_python_helper = $bdepends_noarch->implies('python-support');
+ }
+ if (not $seen_python_helper) {
+ tag 'python-depends-but-no-python-helper', sort(keys %python_depends);
+ }
+ }
+}
+if ($seen_dh and $seen_python3_helper != 1) {
+ my %python3_depends = ();
+ for my $binpkg (keys %$pkgs) {
+ if ($info->binary_relation($binpkg, 'all')->implies('${python3:Depends}')) {
+ $python3_depends{$binpkg} = 1;
+ }
+ }
+ if (%python3_depends and not $seen_python3_helper) {
+ tag 'python3-depends-but-no-python3-helper', sort(keys %python3_depends);
+ }
+}
+
}
1;
diff --git a/checks/debhelper.desc b/checks/debhelper.desc
--- a/checks/debhelper.desc
+++ b/checks/debhelper.desc
@@ -288,3 +288,22 @@
Info: The package build-depends on cdbs, but does not include any cdbs
files in <tt>debian/rules</tt>.
+Tag: python-depends-but-no-python-helper
+Severity: serious
+Certainty: possible
+Experimental: yes
+Info: The source package declares a dependency on ${python:Depends} in the
+ given binary package's debian/control entry. However, debian/rules doesn't
+ call any helper that would generate this substitution variable.
+ .
+ When using debhelper compatibility level below 9, dh will call dh_pysupport by
+ default if it's installed, but the build dependency on python-support is still
+ necessary.
+
+Tag: python3-depends-but-no-python3-helper
+Severity: serious
+Certainty: possible
+Experimental: yes
+Info: The source package declares a dependency on ${python3:Depends} in the
+ given binary package's debian/control entry. However, debian/rules doesn't
+ call any helper that would generate this substitution variable.
Reply to: