[Reproducible-commits] [dpkg] 18/30: Dpkg::Deps: Add support for tests dependencies

Mattia Rizzolo mattia at debian.org
Mon May 9 09:02:51 UTC 2016


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

mattia pushed a commit to branch pu/reproducible_builds
in repository dpkg.

commit 608f93858f2fc44e86538fbf585d4e0fa9cf7743
Author: Guillem Jover <guillem at debian.org>
Date:   Sat May 7 17:52:57 2016 +0200

    Dpkg::Deps: Add support for tests dependencies
    
    These include package names with the usually invalid character ‘@’.
    Used when parsing debian/tests/control files.
---
 debian/changelog      |  3 +++
 scripts/Dpkg/Deps.pm  | 23 ++++++++++++++++++++++-
 scripts/t/Dpkg_Deps.t | 10 +++++++++-
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 7406071..1b55c48 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -23,6 +23,9 @@ dpkg (1.18.7) UNRELEASED; urgency=medium
       around versions, architectures and profile restrictions.
       Regression introduced in 1.18.5. Closes: #823431
     - Add new require_strong_checksums option to Dpkg::Source::Package.
+    - Add new tests_dep option to Dpkg::Deps deps_parse() to allow the
+      otherwise invalid ‘@’ character in dependencies. To be used when
+      parsing the debian/tests/control file.
   * Documentation:
     - Shorten example symbol names in dpkg-gensymbols to avoid a mandb
       warning due to unwrappable lines in translations.
diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm
index 5ee6b9d..cdd2587 100644
--- a/scripts/Dpkg/Deps.pm
+++ b/scripts/Dpkg/Deps.pm
@@ -237,6 +237,12 @@ this when parsing non-dependency fields like Conflicts.
 If set to 1, allow build-dep only arch qualifiers, that is “:native”.
 This should be set whenever working with build-deps.
 
+=item tests_dep (defaults to 0)
+
+If set to 1, allow tests-specific package names in dependencies, that is
+"@" and "@builddeps@" (since dpkg 1.18.7). This should be set whenever
+working with dependency fields from F<debian/tests/control>.
+
 =back
 
 =cut
@@ -254,6 +260,7 @@ sub deps_parse {
     $options{reduce_restrictions} //= 0;
     $options{union} //= 0;
     $options{build_dep} //= 0;
+    $options{tests_dep} //= 0;
 
     if ($options{reduce_restrictions}) {
         $options{reduce_arch} = 1;
@@ -265,6 +272,7 @@ sub deps_parse {
         host_arch => $options{host_arch},
         build_arch => $options{build_arch},
         build_dep => $options{build_dep},
+        tests_dep => $options{tests_dep},
     );
 
     # Strip trailing/leading spaces
@@ -571,6 +579,7 @@ sub new {
     $self->{host_arch} = $opts{host_arch} || Dpkg::Arch::get_host_arch();
     $self->{build_arch} = $opts{build_arch} || Dpkg::Arch::get_build_arch();
     $self->{build_dep} = $opts{build_dep} // 0;
+    $self->{tests_dep} = $opts{tests_dep} // 0;
     $self->parse_string($arg) if defined($arg);
     return $self;
 }
@@ -594,9 +603,17 @@ sub parse {
 
 sub parse_string {
     my ($self, $dep) = @_;
+
+    my $pkgname_re;
+    if ($self->{tests_dep}) {
+        $pkgname_re = qr/[\@a-zA-Z0-9][\@a-zA-Z0-9+.-]*/;
+    } else {
+        $pkgname_re = qr/[a-zA-Z0-9][a-zA-Z0-9+.-]*/;
+    }
+
     return if not $dep =~
            m{^\s*                           # skip leading whitespace
-              ([a-zA-Z0-9][a-zA-Z0-9+.-]*)  # package name
+              ($pkgname_re)                 # package name
               (?:                           # start of optional part
                 :                           # colon for architecture
                 ([a-zA-Z0-9][a-zA-Z0-9-]*)  # architecture name
@@ -1473,6 +1490,10 @@ sub _evaluate_simple_dep {
 
 =head1 CHANGES
 
+=head2 Version 1.06 (dpkg 1.18.7)
+
+New option: Add tests_dep option to Dpkg::Deps::deps_parse().
+
 =head2 Version 1.05 (dpkg 1.17.14)
 
 New function: Dpkg::Deps::deps_iterate().
diff --git a/scripts/t/Dpkg_Deps.t b/scripts/t/Dpkg_Deps.t
index c561b3d..a4deccc 100644
--- a/scripts/t/Dpkg_Deps.t
+++ b/scripts/t/Dpkg_Deps.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 50;
+use Test::More tests => 52;
 
 use Dpkg::Arch qw(get_host_arch);
 use Dpkg::Version;
@@ -63,6 +63,14 @@ is($dep_ma_native2->implies($dep_ma_any), 1, 'foo:native -> foo:any');
 is($dep_ma_any->implies($dep_ma_native), undef, 'foo:any !-> foo');
 is($dep_ma_any->implies($dep_ma_native2), undef, 'foo:any !-> foo:native');
 
+my $field_tests = 'self, @, @builddeps@';
+$SIG{__WARN__} = sub {};
+my $dep_tests_fail = deps_parse($field_tests);
+is($dep_tests_fail, undef, 'normal deps with @ in pkgname');
+delete $SIG{__WARN__};
+my $dep_tests_pass = deps_parse($field_tests, tests_dep => 1);
+is($dep_tests_pass->output(), $field_tests, 'tests deps with @ in pkgname');
+
 my $field_arch = 'libc6 (>= 2.5) [!alpha !hurd-i386], libc6.1 [alpha], libc0.1 [hurd-i386]';
 my $dep_i386 = deps_parse($field_arch, reduce_arch => 1, host_arch => 'i386');
 my $dep_alpha = deps_parse($field_arch, reduce_arch => 1, host_arch => 'alpha');

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



More information about the Reproducible-commits mailing list