[SCM] Debian Qt/KDE packaging tools branch, experimental, updated. debian/0.15.5

Modestas Vainius modax at alioth.debian.org
Sun Apr 14 17:28:35 UTC 2013


Gitweb-URL: http://git.debian.org/?p=pkg-kde/pkg-kde-tools.git;a=commitdiff;h=655fce7

The following commit has been merged in the experimental branch:
commit 655fce75104e7dc2b701e7b265378d5fe1320c7b
Author: Modestas Vainius <modax at debian.org>
Date:   Sun Apr 14 18:32:28 2013 +0300

    dh_sameversiondep: do not fail on multiarch dependencies.
    
    Fix dh_sameversiondep not to fail on dependencies which have versions from
    multiple architectures installed.
    
    Thanks to Cyril Brulebois for the initial patch.
    
    (Closes: #676833)
---
 debian/changelog  |    3 ++
 dh_sameversiondep |   64 +++++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 60 insertions(+), 7 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index e62079c..8c84bbf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,8 @@
 pkg-kde-tools (0.15.5) UNRELEASED; urgency=low
 
+  * dh_sameversiondep: do not fail on dependencies which have versions from
+    multiple architectures installed. Thanks to Cyril Brulebois for the initial
+    patch. (Closes: #676833)
 
  -- Modestas Vainius <modax at debian.org>  Sun, 14 Apr 2013 14:45:39 +0300
 
diff --git a/dh_sameversiondep b/dh_sameversiondep
index 82b4324..2eaac45 100755
--- a/dh_sameversiondep
+++ b/dh_sameversiondep
@@ -52,7 +52,8 @@ name and I<dependency type> (either Depends or Recommends etc.) are determined.
 =item *
 
 All dependencies of the requested I<type> are collected for the I<dependency
-package> based on the I<dpkg-query --status> output.
+package> based on the I<dpkg-query --status> output. If a multi-arch aware dpkg
+is detected, this query is architecture-qualified as needed.
 
 =item *
 
@@ -157,6 +158,7 @@ use Dpkg::Control::Info;
 use Dpkg::Substvars;
 use Dpkg::ErrorHandling ();
 use File::Copy;
+use POSIX ":sys_wait_h";
 
 use Debian::Debhelper::Dh_Lib;
 
@@ -171,6 +173,8 @@ my $re_splitsubstvar = qr/^($re_pkgname)(?::($re_pkgname))?(?:-($re_fields))?$/;
 my $g_substvars = new Dpkg::Substvars;
 $g_substvars->load("debian/substvars") if (-r "debian/substvars");
 
+my $MULTIARCH_ARCH;
+
 sub extract_package_names {
     my $val = shift;
     $val =~ s/\([^)]+\)//g;
@@ -239,17 +243,38 @@ sub Shlibsvars::get_dep_package_names {
     return extract_package_names($val);
 }
 
-sub get_package_dpkg_status {
+sub supports_multiarch {
+    if (!defined $MULTIARCH_ARCH) {
+        my $multiarch_assert = system('dpkg', '--assert-multi-arch');
+        if ($multiarch_assert == 0) {
+            $MULTIARCH_ARCH = dpkg_architecture_value('DEB_HOST_ARCH');
+        } else {
+            $MULTIARCH_ARCH = ""; # empty indicates no multiarch support
+        }
+    }
+    return $MULTIARCH_ARCH ne "";
+}
+
+sub arch_qualify {
+    if (supports_multiarch()) {
+        return map { "$_:$MULTIARCH_ARCH" } @_;
+    } else {
+        return @_;
+    }
+}
+
+sub execute_dpkg_status {
     my $binpkgs = shift;
     my $fields = shift;
     $fields = [ "Source", "Version" ] unless defined $fields;
+    my $status = shift;
+
     my $regexp_fields = join("|", @$fields);
-    my %status;
 
     my $pid = open(DPKG, "-|");
     error("cannot fork for dpkg-query --status") unless defined($pid);
     if (!$pid) {
-        # Child process running dpkg --search and discarding errors
+        # Child process running dpkg-query --status and discarding errors
         close STDERR;
         open STDERR, ">", "/dev/null";
         $ENV{LC_ALL} = "C";
@@ -259,18 +284,43 @@ sub get_package_dpkg_status {
     while (defined($_ = <DPKG>)) {
         if (m/^Package:\s*(.*)$/) {
             $curpkg = $1;
-            $status{$curpkg} = {};
+            $status->{$curpkg} = {};
         } elsif (defined($curpkg)) {
             if (m/^($regexp_fields):\s*(.*)$/) {
                 my $field = $1;
                 error("dublicate field $field for the $curpkg package in the dpkg status file")
-                    if (exists $status{$curpkg}{$field});
-                $status{$curpkg}{$field} = $2;
+                    if (exists $status->{$curpkg}{$field});
+                $status->{$curpkg}{$field} = $2;
             }
         }
     }
     close(DPKG);
 
+    my $exit_code = $?;
+    if (WIFEXITED($exit_code)) {
+        return WEXITSTATUS($exit_code);
+    } else {
+        error("failed to terminate dpkg --status process PID $pid");
+    }
+}
+
+sub get_package_dpkg_status {
+    my $binpkgs = shift;
+    my $fields = shift;
+    my %status;
+
+    my $exit_code = execute_dpkg_status($binpkgs, $fields, \%status);
+    if ($exit_code == 2 && supports_multiarch()) {
+        # Most likely dpkg-query --status failed due to some of package names
+        # being ambiguous on this system. So just requery them using
+        # arch-qualified syntax.
+        # NOTE: we have to query twice since arch-qualified syntax won't find
+        # arch:all packages.
+        my @ambiguous_pkgs = arch_qualify(grep { ! exists $status{$_} } @$binpkgs);
+        if (@ambiguous_pkgs) {
+            execute_dpkg_status(\@ambiguous_pkgs, $fields, \%status);
+        }
+    }
     return \%status;
 }
 

-- 
Debian Qt/KDE packaging tools



More information about the pkg-kde-commits mailing list