]> git.donarmstrong.com Git - debhelper.git/commitdiff
refactor cross command generation
authorJoey Hess <joey@kitenet.net>
Tue, 8 Feb 2011 19:32:22 +0000 (15:32 -0400)
committerJoey Hess <joey@kitenet.net>
Tue, 8 Feb 2011 19:32:22 +0000 (15:32 -0400)
Debian/Debhelper/Dh_Lib.pm
dh_makeshlibs
dh_strip

index fb83480b5324b69182c26fcc2e17587e1678332b..9b6118e90c44b871582cb5fbfb6c2792b4236729 100644 (file)
@@ -17,7 +17,8 @@ use vars qw(@ISA @EXPORT %dh);
            &is_udeb &udeb_filename &debhelper_script_subst &escape_shell
            &inhibit_log &load_log &write_log &dpkg_architecture_value
            &sourcepackage
-           &is_make_jobserver_unavailable &clean_jobserver_makeflags);
+           &is_make_jobserver_unavailable &clean_jobserver_makeflags
+           &cross_command);
 
 my $max_compat=8;
 
@@ -858,4 +859,16 @@ sub clean_jobserver_makeflags {
        }
 }
 
+# If cross-compiling, returns appropriate cross version of command.
+sub cross_command {
+       my $command=shift;
+       if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE")
+           ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) {
+               return dpkg_architecture_value("DEB_HOST_GNU_TYPE")."-$command";
+       }
+       else {
+               return $command;
+       }
+}
+
 1
index 29d3f4d3e53481ae5c16cdecdbfc8113c1525227..b6779f907638673ddfa8c92512b4d64741d636bc 100755 (executable)
@@ -121,12 +121,7 @@ init(options => {
        "add-udeb=s" => \$dh{SHLIBS_UDEB},
 });
 
-my $od = "objdump";
-# cross-compiling?
-if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE")
-    ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) {
-       $od=dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-objdump";
-}
+my $objdump=cross_command("objdump");
 
 foreach my $package (@{$dh{DOPACKAGES}}) {
        next if is_udeb($package);
@@ -153,13 +148,13 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
        while (<FIND>) {
                my ($library, $major);
                push @lib_files, $_;
-               my $objdump=`$od -p $_`;
-               if ($objdump=~m/\s+SONAME\s+(.+)\.so\.(.+)/) {
+               my $ret=`$objdump -p $_`;
+               if ($ret=~m/\s+SONAME\s+(.+)\.so\.(.+)/) {
                        # proper soname format
                        $library=$1;
                        $major=$2;
                }
-               elsif ($objdump=~m/\s+SONAME\s+(.+)-(.+)\.so/) {
+               elsif ($ret=~m/\s+SONAME\s+(.+)-(.+)\.so/) {
                        # idiotic crap soname format
                        $library=$1;
                        $major=$2;
index b4098be6fd23b5164e3c269b09a64aee70dd5c61..5cc68834d5cf4ee307729c9f5a0af4c07c60cdc8 100755 (executable)
--- a/dh_strip
+++ b/dh_strip
@@ -86,14 +86,8 @@ if (defined $ENV{DEB_BUILD_OPTIONS} && $ENV{DEB_BUILD_OPTIONS} =~ /nostrip/) {
        exit;
 }
 
-my $objcopy = "objcopy";
-my $strip = "strip";
-# cross-compiling?
-if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE")
-    ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) {
-       $objcopy=dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-objcopy";
-       $strip=dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-strip";
-}
+my $objcopy = cross_command("objcopy");
+my $strip = cross_command("strip");
 
 # I could just use `file $_[0]`, but this is safer
 sub get_file_type {