Package: libdpkg-perl
Version: 1.16.9
Severity: normal
Tags: patch
User: [email protected]
Usertags: origin-ubuntu ubuntu-patch raring

Dpkg::Deps::deps_parse takes a host_arch option, but doesn't take a
corresponding build_arch option.  This means that if you're evaluating
dependencies relative to a non-default build architecture, you get
Dpkg::Deps::* objects back with the wrong build_arch set, which may
cause unexpected behaviour later in simplify_deps.  Compare:

  DB<4> x deps_parse("perl", host_arch => "amd64")
0  Dpkg::Deps::AND=HASH(0x8ff78e0)
   'list' => ARRAY(0x9300fd8)
      0  Dpkg::Deps::Simple=HASH(0x930108c)
         'arches' => undef
         'archqual' => undef
         'build_arch' => 'i386'
         'build_dep' => 0
         'host_arch' => 'amd64'
         'package' => 'perl'
         'relation' => undef
         'version' => undef
  DB<5> x deps_parse("perl", build_arch => "amd64")
0  Dpkg::Deps::AND=HASH(0x92f042c)
   'list' => ARRAY(0x8ff782c)
      0  Dpkg::Deps::Simple=HASH(0x8ff79bc)
         'arches' => undef
         'archqual' => undef
         'build_arch' => 'i386'
         'build_dep' => 0
         'host_arch' => 'i386'
         'package' => 'perl'
         'relation' => undef
         'version' => undef

This patch produces more consistent results.

diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm
index 21b8e9c..aa590b3 100644
--- a/scripts/Dpkg/Deps.pm
+++ b/scripts/Dpkg/Deps.pm
@@ -259,6 +259,11 @@ Set to 0 to completely ignore that information.
 Define the host architecture. By default it uses
 Dpkg::Arch::get_host_arch() to identify the proper architecture.
 
+=item build_arch (defaults to the current architecture)
+
+Define the build architecture. By default it uses
+Dpkg::Arch::get_build_arch() to identify the proper architecture.
+
 =item reduce_arch (defaults to 0)
 
 If set to 1, ignore dependencies that do not concern the current host
@@ -286,6 +291,7 @@ sub deps_parse {
     $options{use_arch} = 1 if not exists $options{use_arch};
     $options{reduce_arch} = 0 if not exists $options{reduce_arch};
     $options{host_arch} = get_host_arch() if not exists $options{host_arch};
+    $options{build_arch} = get_build_arch() if not exists $options{build_arch};
     $options{union} = 0 if not exists $options{union};
     $options{build_dep} = 0 if not exists $options{build_dep};
 
@@ -299,6 +305,8 @@ sub deps_parse {
         foreach my $dep_or (split(/\s*\|\s*/m, $dep_and)) {
            my $dep_simple = Dpkg::Deps::Simple->new($dep_or, host_arch =>
                                                     $options{host_arch},
+                                                    build_arch =>
+                                                    $options{build_arch},
                                                     build_dep =>
                                                     $options{build_dep});
            if (not defined $dep_simple->{package}) {

Thanks,

-- 
Colin Watson                                       [[email protected]]


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to