On Mon, Apr 19, 2010, Raphael Hertzog wrote:
> Hum, shouldn't we call $arch-objdump only after having checked its
> availability?

 That would be ideal in the possible (albeit unlikely case) where
 binutils-multiarch is available but not a cross-binutils.

> Are there packages that can be cross-built without the binutils for the
> target host? I guess in theory no (but I don't know all esoteric languages
> that we have)... but maybe in practice there might be packages which are
> wrongly architecture specific that could be crossbuilt without it
> nevertheless. It would be sad to introduce a regression for those just
> because we're trying to call something that doesn't exist.

 I can't think of any example, but it might be.  Note that objdump can
 not be expected to parse these, so it's either our regular objdump
 failing or binutils-multiarch is installed.

> quotes not needed around $od

 Fixed in attached patch

> > -       close(P) or subprocerr(_g("objdump on \`%s'"), $file);
> > +       close(P) or subprocerr(_g("$od on \`%s'"), $file);
> 
> No variable in translated strings (I think we can remove the translation
> altogether and only put the command called in the message).

 Ah right, wasn't paying attention (just rebased an old patch I had
 tested); I dropped the translation altogether in the attached patch,
 but this means we don't mention the processed file in the error message
 anymore.

-- 
Loïc Minier
diff -Nru dpkg-1.15.6.1/debian/changelog dpkg-1.15.6.2/debian/changelog
--- dpkg-1.15.6.1/debian/changelog	2010-03-25 00:52:32.000000000 +0100
+++ dpkg-1.15.6.2/debian/changelog	2010-04-19 12:38:29.000000000 +0200
@@ -1,3 +1,9 @@
+dpkg (1.15.6.2) UNRELEASED; urgency=low
+
+  * scripts/Dpkg/Shlibs/Objdump.pm: Use triplet-objdump when cross-building.
+
+ -- Loïc Minier <[email protected]>  Mon, 19 Apr 2010 12:38:01 +0200
+
 dpkg (1.15.6.1) experimental; urgency=low
 
   [ Guillem Jover ]
diff -Nru dpkg-1.15.6.1/scripts/Dpkg/Shlibs/Objdump.pm dpkg-1.15.6.2/scripts/Dpkg/Shlibs/Objdump.pm
--- dpkg-1.15.6.1/scripts/Dpkg/Shlibs/Objdump.pm	2010-03-21 09:46:34.000000000 +0100
+++ dpkg-1.15.6.2/scripts/Dpkg/Shlibs/Objdump.pm	2010-04-19 17:15:03.000000000 +0200
@@ -80,8 +80,13 @@
 	    return $format{$file};
 	} else {
 	    local $ENV{LC_ALL} = "C";
-	    open(P, "-|", "objdump", "-a", "--", $file)
-		|| syserr(_g("cannot fork for %s"), "objdump");
+	    my $od = "objdump";
+	    # cross-compiling?
+	    if ($ENV{'DEB_BUILD_GNU_TYPE'} ne $ENV{'DEB_HOST_GNU_TYPE'}) {
+		$od = $ENV{'DEB_HOST_GNU_TYPE'} . "-objdump";
+	    }
+	    open(P, "-|", $od, "-a", "--", $file)
+		|| syserr(_g("cannot fork for %s"), $od);
 	    while (<P>) {
 		chomp;
 		if (/^\s*\S+:\s*file\s+format\s+(\S+)\s*$/) {
@@ -89,7 +94,7 @@
 		    return $format{$file};
 		}
 	    }
-	    close(P) or subprocerr(_g("objdump on \`%s'"), $file);
+	    close(P) or subprocerr($od);
 	}
     }
 }
@@ -154,8 +159,13 @@
     $self->{file} = $file;
 
     local $ENV{LC_ALL} = 'C';
-    open(my $objdump, "-|", "objdump", "-w", "-f", "-p", "-T", "-R", $file)
-	|| syserr(_g("cannot fork for %s"), "objdump");
+    my $od = "objdump";
+    # cross-compiling?
+    if ($ENV{'DEB_BUILD_GNU_TYPE'} ne $ENV{'DEB_HOST_GNU_TYPE'}) {
+	$od = $ENV{'DEB_HOST_GNU_TYPE'} . "-objdump";
+    }
+    open(my $objdump, "-|", $od, "-w", "-f", "-p", "-T", "-R", $file)
+	|| syserr(_g("cannot fork for %s"), $od);
     my $ret = $self->parse_objdump_output($objdump);
     close($objdump);
     return $ret;

Reply via email to