]> git.donarmstrong.com Git - debhelper.git/blobdiff - dh_strip
r549: * Fixed over-escaping of period when generating EXCLUDE_FIND.
[debhelper.git] / dh_strip
index a7052871e8ed230dad4129b1f28012a077f5d0d5..ac51cd5e8817380620d0a6f2e200582e8637e28f 100755 (executable)
--- a/dh_strip
+++ b/dh_strip
@@ -12,7 +12,7 @@ use Debian::Debhelper::Dh_Lib;
 
 =head1 SYNOPSIS
 
-  dh_strip [debhelper options] [-Xitem]
+B<dh_strip> [S<I<debhelper options>>] [B<-X>I<item>] [item]
 
 =head1 DESCRIPTION
 
@@ -53,6 +53,17 @@ if (defined $ENV{DEB_BUILD_OPTIONS} && $ENV{DEB_BUILD_OPTIONS} =~ /nostrip/) {
        exit;
 }
 
+# I could just use `file $_[0]`, but this is safer
+sub get_file_type {
+       my $file=shift;
+       open (FILE, '-|') # handle all filenames safely
+               || exec('file', $file)
+               || die "can't exec file: $!";
+       my $type=<FILE>;
+       close FILE;
+       return $type;
+}
+
 # Check if a file is an elf binary, shared library, or static library,
 # for use by File::Find. It'll fill the following 3 arrays with anything
 # it finds:
@@ -70,7 +81,7 @@ sub testfile {
        # Does its filename look like a shared library?
        if (m/.*\.so.*?/) {
                # Ok, do the expensive test.
-               my $type=`file $_`;
+               my $type=get_file_type($_);
                if ($type=~m/.*ELF.*shared.*/) {
                        push @shared_libs, $fn;
                        return;
@@ -81,8 +92,8 @@ sub testfile {
        my (undef,undef,$mode,undef)=stat(_);
        if ($mode & 0111) {
                # Ok, expensive test.
-               my $type=`file $_`;
-               if ($type=~m/.*ELF.*executable.*/) {
+               my $type=get_file_type($_);
+               if ($type=~m/.*ELF.*(executable|shared).*/) {
                        push @executables, $fn;
                        return;
                }