Bladeren bron

Dpkg::Arch: Make get_host_arch and get_build_arch read from the environment

All scripts calling get_host_arch are expected to support getting the
value overriden by the environment when cross building. Except for
dpkg-architecture, which needs more fine grained control, and calls
directly the get_raw_ functions.
Guillem Jover 18 jaren geleden
bovenliggende
commit
ac7d8b96b7
4 gewijzigde bestanden met toevoegingen van 34 en 7 verwijderingen
  1. 14 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 15 4
      scripts/Dpkg/Arch.pm
  4. 3 3
      scripts/dpkg-architecture.pl

+ 14 - 0
ChangeLog

@@ -1,3 +1,17 @@
+2007-11-23  Guillem Jover  <guillem@debian.org>
+
+	* scripts/Dpkg/Arch.pm (get_build_arch): Rename to ...
+	(get_raw_build_arch): ... this.
+	(get_build_arch): New function.
+	(get_host_arch): Rename to ...
+	(get_raw_host_arch): ... this. Use get_raw_build_arch instead of
+	get_build_arch.
+	(get_host_arch): New function.
+	(@EXPORT_OK): Add get_raw_build_arch and get_raw_host_arch.
+	* scripts/dpkg-architecture.pl: Import get_raw_build_arch and
+	get_raw_host_arch instead of get_build_arch and get_host_arch.
+	Fix all callers.
+
 2007-11-23  Guillem Jover  <guillem@debian.org>
 
 	* scripts/dpkg-architecture.pl (%env): Rename to ...

+ 2 - 0
debian/changelog

@@ -17,6 +17,8 @@ dpkg (1.14.10) UNRELEASED; urgency=low
 
   [ Guillem Jover ]
   * Add support for Package-Type in dpkg-name.
+  * Restore cross compilation support by honouring the environment host and
+    arch variables to override the default values on the dpkg-dev scripts.
 
   [ Updated man pages translations ]
   * Swedish (Peter Karlsson)

+ 15 - 4
scripts/Dpkg/Arch.pm

@@ -5,7 +5,8 @@ use warnings;
 
 use Exporter;
 our @ISA = qw(Exporter);
-our @EXPORT_OK = qw(get_build_arch get_host_arch get_gcc_host_gnu_type
+our @EXPORT_OK = qw(get_raw_build_arch get_raw_host_arch
+                    get_build_arch get_host_arch get_gcc_host_gnu_type
                     get_valid_arches debarch_eq debarch_is
                     debarch_to_gnutriplet gnutriplet_to_debarch
                     debtriplet_to_gnutriplet gnutriplet_to_debtriplet
@@ -27,7 +28,7 @@ my %debarch_to_debtriplet;
     my $host_arch;
     my $gcc_host_gnu_type;
 
-    sub get_build_arch()
+    sub get_raw_build_arch()
     {
 	return $build_arch if defined $build_arch;
 
@@ -39,6 +40,11 @@ my %debarch_to_debtriplet;
 	return $build_arch;
     }
 
+    sub get_build_arch()
+    {
+	return $ENV{DEB_BUILD_ARCH} || get_raw_build_arch();
+    }
+
     sub get_gcc_host_gnu_type()
     {
 	return $gcc_host_gnu_type if defined $gcc_host_gnu_type;
@@ -53,7 +59,7 @@ my %debarch_to_debtriplet;
 	return $gcc_host_gnu_type;
     }
 
-    sub get_host_arch()
+    sub get_raw_host_arch()
     {
 	return $host_arch if defined $host_arch;
 
@@ -77,11 +83,16 @@ my %debarch_to_debtriplet;
 
 	if (!defined($host_arch)) {
 	    # Switch to native compilation.
-	    $host_arch = get_build_arch();
+	    $host_arch = get_raw_build_arch();
 	}
 
 	return $host_arch;
     }
+
+    sub get_host_arch()
+    {
+	return $ENV{DEB_HOST_ARCH} || get_raw_host_arch();
+    }
 }
 
 sub get_valid_arches()

+ 3 - 3
scripts/dpkg-architecture.pl

@@ -25,7 +25,7 @@ use warnings;
 use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling qw(warning syserr usageerr);
-use Dpkg::Arch qw(get_build_arch get_host_arch get_gcc_host_gnu_type
+use Dpkg::Arch qw(get_raw_build_arch get_raw_host_arch get_gcc_host_gnu_type
                   get_valid_arches debarch_eq debarch_is debarch_to_debtriplet
                   debarch_to_gnutriplet gnutriplet_to_debarch);
 
@@ -130,10 +130,10 @@ my @ordered = qw(DEB_BUILD_ARCH DEB_BUILD_ARCH_OS DEB_BUILD_ARCH_CPU
                  DEB_HOST_ARCH DEB_HOST_ARCH_OS DEB_HOST_ARCH_CPU
                  DEB_HOST_GNU_CPU DEB_HOST_GNU_SYSTEM DEB_HOST_GNU_TYPE);
 
-$v{DEB_BUILD_ARCH} = get_build_arch();
+$v{DEB_BUILD_ARCH} = get_raw_build_arch();
 $v{DEB_BUILD_GNU_TYPE} = debarch_to_gnutriplet($v{DEB_BUILD_ARCH});
 
-$v{DEB_HOST_ARCH} = get_host_arch();
+$v{DEB_HOST_ARCH} = get_raw_host_arch();
 $v{DEB_HOST_GNU_TYPE} = debarch_to_gnutriplet($v{DEB_HOST_ARCH});
 
 # Set user values: