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

[PATCH] Add new variables, DEB_HOST_MULTIARCH and DEB_BUILD_MULTIARCH



Add new variables that return the "ideal" GNU triplet for each architecture
which should be used as the path component for library installation.
---
 debian/changelog             |    5 +++
 man/dpkg-architecture.1      |    6 ++++
 scripts/Dpkg/Arch.pm         |   66 +++++++++++++++++++++++++++++++++++++++++-
 scripts/dpkg-architecture.pl |   10 +++++-
 4 files changed, 84 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 9f23d32..5cbb06f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -103,6 +103,11 @@ dpkg (1.16.0) UNRELEASED; urgency=low
   [ Updated dselect translations ]
   * Spanish (Javier Fernandez-Sanguino).
 
+  [ Steve Langasek ]
+  * add new variables, DEB_HOST_MULTIARCH and DEB_BUILD_MULTIARCH, that
+    return the "ideal" GNU triplet for each architecture which should be
+    used as the path component for library installation.
+
  -- Guillem Jover <guillem@debian.org>  Thu, 29 Jul 2010 11:00:22 +0200
 
 dpkg (1.15.8.10) unstable; urgency=low
diff --git a/man/dpkg-architecture.1 b/man/dpkg-architecture.1
index 4ca309e..3176d1b 100644
--- a/man/dpkg-architecture.1
+++ b/man/dpkg-architecture.1
@@ -115,6 +115,9 @@ 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 clarified \s-1GNU\s0 system type of the build machine, used for filesystem
+paths.
 .IP "\s-1DEB_HOST_ARCH\s0" 4
 The Debian architecture of the host machine.
 .IP "\s-1DEB_HOST_ARCH_OS\s0" 4
@@ -131,6 +134,9 @@ 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 clarified \s-1GNU\s0 system type of the host machine, used for filesystem
+paths.
 .
 .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..20d7346 100644
--- a/scripts/Dpkg/Arch.pm
+++ b/scripts/Dpkg/Arch.pm
@@ -25,7 +25,9 @@ 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
+                    gnutriplet_to_multiarch multiarch_to_gnutriplet
+                    debarch_to_multiarch multiarch_to_debarch);
 
 use Dpkg;
 use Dpkg::Gettext;
@@ -39,6 +41,9 @@ my (%cpubits, %cpuendian);
 my %debtriplet_to_debarch;
 my %debarch_to_debtriplet;
 
+my %gnutriplet_to_matriplet;
+my %matriplet_to_gnutriplet;
+
 {
     my $build_arch;
     my $host_arch;
@@ -195,6 +200,25 @@ sub read_triplettable()
     close TRIPLETTABLE;
 }
 
+sub read_multiarchtable()
+{
+    local $_;
+    local $/ = "\n";
+
+    open MULTIARCHTABLE, "$pkgdatadir/multiarchtable"
+	or syserr(_g("cannot open %s"), "multiarchtable");
+    while (<MULTIARCHTABLE>) {
+	if (m/^(?!\#)(\S+)\s+(\S+)/) {
+	    my $gnutriplet = $1;
+	    my $matriplet = $2;
+
+	    $matriplet_to_gnutriplet{$2} = $1;
+	    $gnutriplet_to_matriplet{$1} = $2;
+	}
+    }
+    close MULTIARCHTABLE;
+}
+
 sub debtriplet_to_gnutriplet(@)
 {
     read_cputable() if (!@cpu);
@@ -237,6 +261,46 @@ sub gnutriplet_to_debtriplet($)
     return (split(/-/, $os, 2), $cpu);
 }
 
+sub gnutriplet_to_multiarch($)
+{
+    read_multiarchtable() if (!%gnutriplet_to_matriplet);
+
+    my ($gnu) = @_;
+
+    if (exists $gnutriplet_to_matriplet{"$gnu"}) {
+	return $gnutriplet_to_matriplet{"$gnu"};
+    } else {
+	return $gnu;
+    }
+}
+
+sub multiarch_to_gnutriplet($)
+{
+    read_multiarchtable() if (!%matriplet_to_gnutriplet);
+
+    my ($multi) = @_;
+
+    if (exists $matriplet_to_gnutriplet{"$multi"}) {
+	return $matriplet_to_gnutriplet{"$multi"};
+    } else {
+	return $multi;
+    }
+}
+
+sub debarch_to_multiarch($)
+{
+    my ($arch) = @_;
+
+    return gnutriplet_to_multiarch(debarch_to_gnutriplet($arch));
+}
+
+sub multiarch_to_debarch($)
+{
+    my ($ma) = @_;
+
+    return gnutriplet_to_debarch(multiarch_to_gnutriplet($ma));
+}
+
 sub debtriplet_to_debarch(@)
 {
     read_triplettable() if (!%debtriplet_to_debarch);
diff --git a/scripts/dpkg-architecture.pl b/scripts/dpkg-architecture.pl
index 40b680e..e030827 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});
@@ -190,6 +193,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: