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

Bug#430507: dpkg-cross: [Patch] Check dpkg-architecture before falling back to internal tables



Package: dpkg-cross
Version: 1.38
Severity: normal

Hi,

Please apply the following patch, it queries dpkg-architecture before
falling back to %archtable and %crossprefixtable entries.  I have
removed all entries from %archtable that simply reproduce what current
dpkg outputs, and flagged with #XXX those which actually output
something different.  Those should probably be removed too, but I'll
leave that decision to others, they may indicate changes that also
need to be made elsewhere.  The remaining few in %archtable are unique
to dpkg-cross and not recognised by dpkg.

Everything else should be fairly self evident, but bug me back if it
needs fixing or justifying further.

Cheers,
Ron


---
 dpkg-cross.pl |   48 +++++++++++++++++++-----------------------------
 1 files changed, 19 insertions(+), 29 deletions(-)

diff --git a/dpkg-cross.pl b/dpkg-cross.pl
index 134f783..0f63715 100644
--- a/dpkg-cross.pl
+++ b/dpkg-cross.pl
@@ -44,36 +44,18 @@ foreach my $var_ ( @intern_vars ) {
 $DPKGCROSSVERSION = "1.38";
 
 # Convertion table for Debian GNU/Linux architecture name (``$arch'') to GNU
-# type.
+# type.  This lists additional arch names that are not already supported by
+# dpkg-architecture.
 %archtable = (
-	'i386' => 'i486-linux-gnu',
-	'sparc' => 'sparc-linux-gnu',
 	'sparc64' => 'sparc-linux-gnu',
-	'alpha' => 'alpha-linux-gnu',
-	'm68k' => 'm68k-linux-gnu',
-	'arm' => 'arm-linux-gnu',
-	'armeb' => 'armeb-linux-gnueabi',
-	'armel' => 'arm-linux-gnueabi',
-	'powerpc' => 'powerpc-linux-gnu',
+	'armeb' => 'armeb-linux-gnueabi', #XXX This differs from dpkg-architecture
 	'ppc' => 'powerpc-linux-gnu',
-	'mips' => 'mips-linux-gnu',
-	'mipsel' => 'mipsel-linux-gnu',
-	'sh3' => 'sh3-linux-gnu',
-	'sh4' => 'sh4-linux-gnu',
-	'sh3eb' => 'sh3eb-linux-gnu',
-	'sh4eb' => 'sh4eb-linux-gnu',
-	'hppa' => 'hppa-linux-gnu',
-	'hurd-i386' => 'i386-gnu',
-	's390' => 's390-linux-gnu',
-	's390x' => 's390-linux-gnu',
-	'ia64' => 'ia64-linux-gnu',
- 	'm32r' => 'm32r-linux-gnu',
-	'openbsd-i386' => 'i386-openbsd',
-	'freebsd-i386' => 'i386-freebsd',
-	'darwin-powerpc' => 'powerpc-darwin',
-	'darwin-i386' => 'i386-darwin',
-	'win32-i386' => 'i386-cygwin',
-	'amd64' => 'x86_64-linux-gnu');
+	'hurd-i386' => 'i386-gnu',        #XXX This differs from dpkg-architecture
+	's390x' => 's390-linux-gnu',      #XXX This differs from dpkg-architecture
+	'openbsd-i386' => 'i386-openbsd', #XXX This differs from dpkg-architecture
+	'freebsd-i386' => 'i386-freebsd', #XXX This differs from dpkg-architecture
+	'darwin-i386' => 'i386-darwin',   #XXX This differs from dpkg-architecture
+	'win32-i386' => 'i386-cygwin');
 
 # Regexps to parse 'file' output to detect arch of ELF binary
 # Note that it is not always possibe to restore Debian architecture
@@ -275,8 +257,10 @@ sub setup {
 	# Set ``$arch'' to defaults if not already specified.
 	$arch = get_architecture();
 	die "$progname: Architecture is not specified.\n" unless ($arch);
-	$deb_host_gnu_type = $archtable{$arch};		# FIXME: should use dpkg-architecture here
-	
+
+	chomp($deb_host_gnu_type = `dpkg-architecture -a$arch -qDEB_HOST_GNU_TYPE 2> /dev/null`);
+	$deb_host_gnu_type     ||= $archtable{$arch};
+
 	# Finalize, no subst possible crossbase.
 	$crossbase ||= "/usr";
 	
@@ -443,6 +427,12 @@ sub get_tool {
 		return $t_ if ($t_);
 	}
 
+	my $prefix_ = `dpkg-architecture -a$arch_ -qDEB_HOST_GNU_TYPE 2> /dev/null`;
+	if( chomp($prefix_) ) {
+		my $t_ = find_in_path($prefix_ . "-" . $tool_);
+		return $t_ if ($t_);
+	}
+
 	if (defined($crossprefixtable{$arch_})) {
 		my @l_ = @{$crossprefixtable{$arch_}};
 		# move $crossprefix to the first place in the list
-- 
1.5.2.2



Reply to: