Control: tag -1 patch

On Sat, Jul 25, 2015 at 03:59:12PM +0200, Raphaël Hertzog wrote:
> I would have never expected this patch to break my package, yet it did:
> --- a/debian/control
> +++ b/debian/control
> @@ -8,6 +8,8 @@ Build-Depends:
>   debhelper (>= 9),
>   dh-python,
>   pylint (>= 1.0.0),
> +# Enable once pylint3 is in unstable
> +# pylint3,
>   python-all,
>   python-astroid,
>   python-pylint-plugin-utils,
> 
> I guess that the reason is that pybuild stopped parsing Build-Depends at the
> comment lines and thus assumed that there was no target Python versions to
> build the package for. The end result is that the packages are empty...

Attached patch should fix the issue.

Cheers,
-- 
James
GPG Key: 4096R/331BA3DB 2011-12-05 James McCoy <james...@debian.org>
From 3282130a0da4930ab3832855a886dcadb92af1b1 Mon Sep 17 00:00:00 2001
From: James McCoy <james...@debian.org>
Date: Sat, 25 Jul 2015 14:49:54 -0400
Subject: [PATCH] pybuild: Use Dpkg::Control to parse debian/control

The manual parsing failed to handle comment lines in the Build-Depends
field.  Using Dpkg::Control avoids this since the resulting string
already has comments removed.
---
 debian/control |  4 ++--
 dh/pybuild.pm  | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/debian/control b/debian/control
index 2666816..8325f33 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@ Section: python
 Priority: optional
 Maintainer: Piotr Ożarowski <pi...@debian.org>
 Uploaders: Stefano Rivera <stefa...@debian.org>, Barry Warsaw <ba...@debian.org>
-Build-Depends: debhelper (>= 9), python3-minimal, libpython3-stdlib,
+Build-Depends: debhelper (>= 9), python3-minimal, libpython3-stdlib, libdpkg-perl,
 # provides rst2man command (python3-docutils not used to avoid circular deps):
  python-docutils
 Standards-Version: 3.9.6
@@ -14,7 +14,7 @@ X-Python3-Version: >= 3.2
 Package: dh-python
 Architecture: all
 Multi-Arch: foreign
-Depends: ${misc:Depends}, ${python3:Depends}
+Depends: libdpkg-perl, ${misc:Depends}, ${python3:Depends}
 Breaks:
 # due to /usr/bin/dh_python3 and debhelper files
  python3 (<< 3.3.2-4~)
diff --git a/dh/pybuild.pm b/dh/pybuild.pm
index eef5818..a447067 100644
--- a/dh/pybuild.pm
+++ b/dh/pybuild.pm
@@ -8,6 +8,7 @@
 package Debian::Debhelper::Buildsystem::pybuild;
 
 use strict;
+use Dpkg::Control;
 use Debian::Debhelper::Dh_Lib qw(error doit);
 use base 'Debian::Debhelper::Buildsystem';
 
@@ -155,15 +156,14 @@ sub python_build_dependencies {
 	my $this=shift;
 
 	my @result;
-	open (CONTROL, 'debian/control') || error("cannot read debian/control: $!\n");
-	foreach my $builddeps (join('', <CONTROL>) =~ 
-			/^Build-Depends[^:]*:.*\n(?:^[^\w\n#].*\n)*/gmi) {
-		while ($builddeps =~ /[\s,](pypy|python[0-9\.]*(-all)?((-dev)|(-dbg))?)[\s,]|$/g) {
+	my $c = Dpkg::Control->new(type => CTRL_INFO_SRC);
+	if ($c->load('debian/control')) {
+		my $builddeps = $c->{'Build-Depends'};
+		while ($builddeps =~ /(?:^|[\s,])(pypy|python[0-9\.]*(-all)?((-dev)|(-dbg))?)(?:[\s,]|$)/g) {
 			if ($1) {push @result, $1};
 		}
 	}
 
-	close CONTROL;
 	return @result;
 }
 
-- 
2.4.6

Attachment: signature.asc
Description: Digital signature

Reply via email to