[debhelper-devel] [debhelper] 01/01: Dh_Lib: Fix parse error for empty line before source paragraph

Niels Thykier nthykier at moszumanska.debian.org
Thu Oct 26 18:34:42 UTC 2017


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

nthykier pushed a commit to branch master
in repository debhelper.

commit db695893e896b6e8984723455b8c8eb333b24b77
Author: Niels Thykier <niels at thykier.net>
Date:   Thu Oct 26 18:33:12 2017 +0000

    Dh_Lib: Fix parse error for empty line before source paragraph
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 debian/changelog               |  3 +++
 lib/Debian/Debhelper/Dh_Lib.pm |  3 +++
 t/Dh_Lib/control-parsing.t     | 36 ++++++++++++++++++++++++++++++++++++
 t/Dh_Lib/debian/changelog      |  5 +++++
 t/Dh_Lib/debian/control        | 19 +++++++++++++++++++
 5 files changed, 66 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index dcc901e..1c09459 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,9 @@ debhelper (10.10.5) UNRELEASED; urgency=medium
 
   * meson.pm: Add missing import of generated_file that broke
     cross building.
+  * Dh_Lib: Fix regression where an empty line before the source
+    paragraph in d/control would cause parse error.
+    (Closes: #879762)
 
  -- Niels Thykier <niels at thykier.net>  Thu, 26 Oct 2017 17:46:14 +0000
 
diff --git a/lib/Debian/Debhelper/Dh_Lib.pm b/lib/Debian/Debhelper/Dh_Lib.pm
index 1fbcb10..190d376 100644
--- a/lib/Debian/Debhelper/Dh_Lib.pm
+++ b/lib/Debian/Debhelper/Dh_Lib.pm
@@ -1343,6 +1343,8 @@ sub getpackages {
 	while (<$fd>) {
 		chomp;
 		s/\s+$//;
+		next if m/^\s*+\#/;
+
 		if (/^Source:\s*(.*)/i) {
 			$sourcepackage = $1;
 			next;
@@ -1355,6 +1357,7 @@ sub getpackages {
 			$source_section = $1;
 			next;
 		}
+		next if not $_ and not defined($sourcepackage);
 		last if (!$_ or eof); # end of stanza.
 	}
 	error("could not find Source: line in control file.") if not defined($sourcepackage);
diff --git a/t/Dh_Lib/control-parsing.t b/t/Dh_Lib/control-parsing.t
new file mode 100755
index 0000000..0658256
--- /dev/null
+++ b/t/Dh_Lib/control-parsing.t
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More;
+
+use Cwd qw(abs_path);
+use File::Basename qw(dirname);
+
+BEGIN {
+	my $dir = dirname(abs_path(__FILE__));
+	unshift(@INC, dirname($dir));
+	chdir($dir) or error("chdir($dir) failed: $!");
+};
+
+use Test::DH;
+
+use Debian::Debhelper::Dh_Lib qw(!dirname);
+
+plan(tests => 10);
+
+is_deeply([getpackages()], [qw(foo-any foo-all)], 'packages list correct and in order');
+is_deeply([getpackages('both')], [qw(foo-any foo-all)], 'packages list correct and in order');
+is_deeply([getpackages('arch')], [qw(foo-any)], 'arch:linux-any');
+is_deeply([getpackages('indep')], [qw(foo-all)], 'arch:all');
+
+
+is(package_section('foo-any'), 'devel', 'binary section');
+is(package_section('foo-all'), 'misc', 'binary section (inherit from source)');
+
+	
+is(package_declared_arch('foo-any'), 'linux-any', 'binary architecture (linux-any');
+is(package_declared_arch('foo-all'), 'all', 'binary architecture (all)');
+
+ok(! package_is_arch_all('foo-any'), 'foo-any is not arch:all');
+ok(package_is_arch_all('foo-all'), 'foo-all is arch:all');
diff --git a/t/Dh_Lib/debian/changelog b/t/Dh_Lib/debian/changelog
new file mode 100644
index 0000000..5850f0e
--- /dev/null
+++ b/t/Dh_Lib/debian/changelog
@@ -0,0 +1,5 @@
+foo (1.0-1) unstable; urgency=low
+
+  * Initial release. (Closes: #XXXXXX)
+
+ -- Test <testing at nowhere>  Mon, 11 Jul 2016 18:10:59 +0200
diff --git a/t/Dh_Lib/debian/control b/t/Dh_Lib/debian/control
new file mode 100644
index 0000000..b1f0aa3
--- /dev/null
+++ b/t/Dh_Lib/debian/control
@@ -0,0 +1,19 @@
+# Comment before the source field
+
+Source: foo
+Section: misc
+Priority: optional
+Maintainer: Test <testing at nowhere>
+Standards-Version: 3.9.8
+
+Package: foo-any
+Section: devel
+Architecture: linux-any
+Description: package foo-any
+ Package foo-any
+
+Package: foo-all
+Architecture: all
+Description: package foo-all
+ Package foo-all
+

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




More information about the debhelper-devel mailing list