[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] Add new DEB_HOST_MULTIARCH, DEB_BUILD_MULTIARCH variables to dpkg-architecture using the output of lsb_architecture in lsb-base.



From: Steve Langasek <steve.langasek@canonical.com>

---
 debian/changelog             |    4 ++++
 debian/control               |    3 ++-
 man/dpkg-architecture.1      |    8 ++++++++
 scripts/Dpkg/Arch.pm         |   28 +++++++++++++++++++++++++++-
 scripts/dpkg-architecture.pl |   10 ++++++++--
 5 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 68ddf0c..36081cc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -73,6 +73,10 @@ dpkg (1.16.0) UNRELEASED; urgency=low
   [ Updated dselect translations ]
   * Spanish (Javier Fernandez-Sanguino).
 
+  [ Steve Langasek ]
+  * Add new DEB_HOST_MULTIARCH, DEB_BUILD_MULTIARCH variables to
+    dpkg-architecture using the output of lsb_architecture in lsb-base.
+
  -- Guillem Jover <guillem@debian.org>  Thu, 29 Jul 2010 11:00:22 +0200
 
 dpkg (1.15.8.10) unstable; urgency=low
diff --git a/debian/control b/debian/control
index 0a0b08a..5bbaf17 100644
--- a/debian/control
+++ b/debian/control
@@ -49,7 +49,8 @@ Section: utils
 Priority: optional
 Architecture: all
 Depends: libdpkg-perl (= ${source:Version}), bzip2, xz-utils,
- patch, make, binutils, base-files (>= 5.0.0), ${misc:Depends}
+ patch, make, binutils, base-files (>= 5.0.0),
+ lsb-base (>= 4.0-0ubuntu9+multiarch.1), ${misc:Depends}
 Recommends: gcc | c-compiler, build-essential, fakeroot, gnupg, gpgv, libalgorithm-merge-perl
 Suggests: debian-keyring
 Breaks: dpkg-cross (<< 2.0.0), devscripts (<< 2.10.26)
diff --git a/man/dpkg-architecture.1 b/man/dpkg-architecture.1
index 4ca309e..3321d74 100644
--- a/man/dpkg-architecture.1
+++ b/man/dpkg-architecture.1
@@ -96,6 +96,10 @@ Examples: linux\-any, any\-i386, hurd\-any.
 An architecture specification string consisting of two parts separated by
 a dash: cpu and system. Examples: i386\-linux\-gnu, sparc\-linux\-gnu,
 i386\-gnu, x86_64\-netbsd.
+.IP "multiarch tuple" 4
+An architecture specification string used to compose system library paths
+for multiarch packages.  It consists of three parts separated by dashes:
+cpu, kernel, libc.  Examples: x86\-linux\-glibc, mips64\-linux\-glibc_n32.
 .
 .SH VARIABLES
 The following variables are set by \fBdpkg\-architecture\fP:
@@ -115,6 +119,8 @@ The \s-1CPU\s0 part of \s-1DEB_BUILD_GNU_TYPE\s0.
 The System part of \s-1DEB_BUILD_GNU_TYPE\s0.
 .IP "\s-1DEB_BUILD_GNU_TYPE\s0" 4
 The \s-1GNU\s0 system type of the build machine.
+.IP "\s-1DEB_BUILD_MULTIARCH\s0" 4
+The multiarch tuple of the build machine.
 .IP "\s-1DEB_HOST_ARCH\s0" 4
 The Debian architecture of the host machine.
 .IP "\s-1DEB_HOST_ARCH_OS\s0" 4
@@ -131,6 +137,8 @@ The \s-1CPU\s0 part of \s-1DEB_HOST_GNU_TYPE\s0.
 The System part of \s-1DEB_HOST_GNU_TYPE\s0.
 .IP "\s-1DEB_HOST_GNU_TYPE\s0" 4
 The \s-1GNU\s0 system type of the host machine.
+.IP "\s-1DEB_BUILD_MULTIARCH\s0" 4
+The multiarch tuple of the host machine.
 .
 .SH "DEBIAN/RULES"
 The environment variables set by \fBdpkg\-architecture\fP are passed to
diff --git a/scripts/Dpkg/Arch.pm b/scripts/Dpkg/Arch.pm
index da72345..e178a55 100644
--- a/scripts/Dpkg/Arch.pm
+++ b/scripts/Dpkg/Arch.pm
@@ -25,7 +25,8 @@ our @EXPORT_OK = qw(get_raw_build_arch get_raw_host_arch
                     debarch_to_cpuattrs
                     debarch_to_gnutriplet gnutriplet_to_debarch
                     debtriplet_to_gnutriplet gnutriplet_to_debtriplet
-                    debtriplet_to_debarch debarch_to_debtriplet);
+                    debtriplet_to_debarch debarch_to_debtriplet
+                    debarch_to_multiarch);
 
 use Dpkg;
 use Dpkg::Gettext;
@@ -282,6 +283,31 @@ sub debarch_to_gnutriplet($)
     return debtriplet_to_gnutriplet(debarch_to_debtriplet($arch));
 }
 
+sub debarch_to_multiarch($)
+{
+    my ($arch) = @_;
+    my ($multiarch, $savedhost);
+
+    $savedhost = $ENV{DEB_HOST_ARCH} if (defined($ENV{DEB_HOST_ARCH}));
+    $ENV{DEB_HOST_ARCH} = $arch;
+
+    open(LSB_ARCHITECTURE, '-|', "lsb_architecture")
+      || subprocerr("lsb_architecture");
+    $multiarch = <LSB_ARCHITECTURE>;
+    chomp $multiarch;
+    if (!close(LSB_ARCHITECTURE)) {
+        syserr(_g("lsb_architecture exited nonzero"));
+        $multiarch = '';
+    }
+    if (defined($ENV{DEB_HOST_ARCH})) {
+        $ENV{DEB_HOST_ARCH} = $savedhost;
+    } else {
+        $ENV{DEB_HOST_ARCH} = undef;
+    }
+
+    return $multiarch;
+}
+
 sub gnutriplet_to_debarch($)
 {
     my ($gnu) = @_;
diff --git a/scripts/dpkg-architecture.pl b/scripts/dpkg-architecture.pl
index 09d413c..a11b421 100755
--- a/scripts/dpkg-architecture.pl
+++ b/scripts/dpkg-architecture.pl
@@ -27,7 +27,8 @@ use Dpkg::ErrorHandling;
 use Dpkg::Arch qw(get_raw_build_arch get_raw_host_arch get_gcc_host_gnu_type
                   debarch_to_cpuattrs
                   get_valid_arches debarch_eq debarch_is debarch_to_debtriplet
-                  debarch_to_gnutriplet gnutriplet_to_debarch);
+                  debarch_to_gnutriplet gnutriplet_to_debarch
+                  debarch_to_multiarch);
 
 textdomain("dpkg-dev");
 
@@ -127,9 +128,11 @@ my %v;
 my @ordered = qw(DEB_BUILD_ARCH DEB_BUILD_ARCH_OS DEB_BUILD_ARCH_CPU
                  DEB_BUILD_ARCH_BITS DEB_BUILD_ARCH_ENDIAN
                  DEB_BUILD_GNU_CPU DEB_BUILD_GNU_SYSTEM DEB_BUILD_GNU_TYPE
+                 DEB_BUILD_MULTIARCH
                  DEB_HOST_ARCH DEB_HOST_ARCH_OS DEB_HOST_ARCH_CPU
                  DEB_HOST_ARCH_BITS DEB_HOST_ARCH_ENDIAN
-                 DEB_HOST_GNU_CPU DEB_HOST_GNU_SYSTEM DEB_HOST_GNU_TYPE);
+                 DEB_HOST_GNU_CPU DEB_HOST_GNU_SYSTEM DEB_HOST_GNU_TYPE
+                 DEB_HOST_MULTIARCH);
 
 $v{DEB_BUILD_ARCH} = get_raw_build_arch();
 $v{DEB_BUILD_GNU_TYPE} = debarch_to_gnutriplet($v{DEB_BUILD_ARCH});
@@ -185,6 +188,9 @@ my $abi;
 ($v{DEB_HOST_ARCH_BITS}, $v{DEB_HOST_ARCH_ENDIAN}) = debarch_to_cpuattrs($v{DEB_HOST_ARCH});
 ($v{DEB_BUILD_ARCH_BITS}, $v{DEB_BUILD_ARCH_ENDIAN}) = debarch_to_cpuattrs($v{DEB_BUILD_ARCH});
 
+$v{DEB_BUILD_MULTIARCH} = debarch_to_multiarch($v{DEB_BUILD_ARCH});
+$v{DEB_HOST_MULTIARCH} = debarch_to_multiarch($v{DEB_HOST_ARCH});
+
 for my $k (@ordered) {
     $v{$k} = $ENV{$k} if (defined ($ENV{$k}) && !$force);
 }
-- 
1.7.1


Reply to: