From: Guillem Jover Date: Fri, 23 Nov 2007 02:42:25 +0000 (+0200) Subject: Dpkg::Arch: Make get_host_arch and get_build_arch read from the environment X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac7d8b96b7b86ab74b3448554970b1ba64d4b5dd;p=dpkg 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. --- diff --git a/ChangeLog b/ChangeLog index 7c950e1a..18c52e3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2007-11-23 Guillem Jover + + * 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 * scripts/dpkg-architecture.pl (%env): Rename to ... diff --git a/debian/changelog b/debian/changelog index 5b3a911e..25584a06 100644 --- a/debian/changelog +++ b/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) diff --git a/scripts/Dpkg/Arch.pm b/scripts/Dpkg/Arch.pm index 080ee591..3cf0a942 100644 --- a/scripts/Dpkg/Arch.pm +++ b/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() diff --git a/scripts/dpkg-architecture.pl b/scripts/dpkg-architecture.pl index 4cd6cba5..90e96c40 100755 --- a/scripts/dpkg-architecture.pl +++ b/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: