Explorar o código

Dpkg::Arch: Add support for arch ABI attribute overrides

For architectures where the ABI changes some attributes, like MIPS n32
or AMD64 x32, the architecture bits do not match the ones from the cpu,
so we need to override them.
Guillem Jover %!s(int64=14) %!d(string=hai) anos
pai
achega
ad0cb5d13d
Modificáronse 4 ficheiros con 46 adicións e 2 borrados
  1. 5 1
      Makefile.am
  2. 9 0
      abitable
  3. 1 0
      debian/changelog
  4. 31 1
      scripts/Dpkg/Arch.pm

+ 5 - 1
Makefile.am

@@ -18,7 +18,11 @@ SUBDIRS = \
 ACLOCAL_AMFLAGS = -I m4
 
 
-dist_pkgdata_DATA = cputable ostable triplettable
+dist_pkgdata_DATA = \
+	cputable \
+	ostable \
+	abitable \
+	triplettable
 
 EXTRA_DIST = \
 	.mailmap \

+ 9 - 0
abitable

@@ -0,0 +1,9 @@
+# This file contains the table of arch ABI attribute overrides.
+#
+# If the ABI is not present here then the attribute information for a
+# Debian triplet matches the one on the cputable.
+#
+# Column 1 is the Debian name for the ABI.
+# Column 2 is the size (in bits) of the ABI integers/pointers.
+#
+# <Debian name>	<Bits>

+ 1 - 0
debian/changelog

@@ -27,6 +27,7 @@ dpkg (1.16.3) UNRELEASED; urgency=low
     current locale (although this was only affecting the old deb format).
   * Ignore the minor format version number for deb-split format, unifying
     the behaviour with the deb format.
+  * Add support for an abitable containing arch attribute overrides.
 
   [ Helge Kreutzmann ]
   * Fix a typo in man/dpkg-buildflags.1.

+ 31 - 1
scripts/Dpkg/Arch.pm

@@ -28,6 +28,7 @@ our @EXPORT_OK = qw(get_raw_build_arch get_raw_host_arch
                     debtriplet_to_debarch debarch_to_debtriplet
                     gnutriplet_to_multiarch debarch_to_multiarch);
 
+use POSIX qw(:errno_h);
 use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
@@ -36,6 +37,7 @@ my (@cpu, @os);
 my (%cputable, %ostable);
 my (%cputable_re, %ostable_re);
 my (%cpubits, %cpuendian);
+my %abibits;
 
 my %debtriplet_to_debarch;
 my %debarch_to_debtriplet;
@@ -169,6 +171,32 @@ sub read_ostable
     close OSTABLE;
 }
 
+my $abitable_loaded = 0;
+sub abitable_load()
+{
+    return if ($abitable_loaded);
+
+    local $_;
+    local $/ = "\n";
+
+    # Because the abitable is only for override information, do not fail if
+    # it does not exist, as that will only mean the other tables do not have
+    # an entry needing to be overridden. This way we do not require a newer
+    # dpkg by libdpkg-perl.
+    if (open ABITABLE, "$pkgdatadir/abitable") {
+        while (<ABITABLE>) {
+            if (m/^(?!\#)(\S+)\s+(\S+)/) {
+                $abibits{$1} = $2;
+            }
+        }
+        close ABITABLE;
+    } elsif ($! != ENOENT) {
+        syserr(_g("cannot open %s"), "abitable");
+    }
+
+    $abitable_loaded = 1;
+}
+
 sub read_triplettable()
 {
     read_cputable() if (!@cpu);
@@ -336,7 +364,9 @@ sub debarch_to_cpuattrs($)
     my ($abi, $os, $cpu) = debarch_to_debtriplet($arch);
 
     if (defined($cpu)) {
-        return ($cpubits{$cpu}, $cpuendian{$cpu});
+        abitable_load();
+
+        return ($abibits{$abi} || $cpubits{$cpu}, $cpuendian{$cpu});
     } else {
         return undef;
     }