[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



Hi,

This patch supersedes the previous one.  It sanitises $CC before
calling dpkg-architecture, so that this doesn't fork-bomb when
invoked with CC=/tmp/gccross.*/$arch-gcc -> gccross, from gccross.

Cheers,
Ron


diff --git a/dpkg-cross.pl b/dpkg-cross.pl
index 134f783..bf537fc 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 = `CC=$arch-gcc 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,14 @@ sub get_tool {
 		return $t_ if ($t_);
 	}
 
+	my $cc_     = "gcc";
+	$cc_        = $arch_ . "-gcc" if $arch_;
+	my $prefix_ = `CC=$cc_ 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





Reply to: