diff options
author | Guillaume Rousse <guillomovitch@mandriva.org> | 2008-02-10 14:21:22 +0000 |
---|---|---|
committer | Guillaume Rousse <guillomovitch@mandriva.org> | 2008-02-10 14:21:22 +0000 |
commit | 0fd87f896eea780920497633ec02f2759e80ab89 (patch) | |
tree | 6e7e0e3fa9f85b074c579cb7db9471c8d8f6cad8 /strip_files | |
parent | 05b8aac3fb350eee3935ca1538107a8640f4cebb (diff) | |
download | spec-helper-0fd87f896eea780920497633ec02f2759e80ab89.tar spec-helper-0fd87f896eea780920497633ec02f2759e80ab89.tar.gz spec-helper-0fd87f896eea780920497633ec02f2759e80ab89.tar.bz2 spec-helper-0fd87f896eea780920497633ec02f2759e80ab89.tar.xz spec-helper-0fd87f896eea780920497633ec02f2759e80ab89.zip |
reorder code, with function at the end
Diffstat (limited to 'strip_files')
-rwxr-xr-x | strip_files | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/strip_files b/strip_files index 72e0091..336b2ff 100755 --- a/strip_files +++ b/strip_files @@ -6,11 +6,12 @@ use strict; use warnings; use File::Find; -################################################################################ -# 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: -my (@shared_libs, @executables, @static_libs); +my $buildroot = $ENV{RPM_BUILD_ROOT}; +die "No build root defined" unless $buildroot; +die "Invalid build root" unless -d $buildroot; +# normalize build root +$buildroot =~ s|/$||; + my $exclude_pattern = join('|', map { '(:?' . quotemeta($_) . ')' } $ENV{EXCLUDE_FROM_STRIP} ? @@ -19,12 +20,33 @@ my $exclude_pattern = join('|', ); $exclude_pattern = qr/$exclude_pattern/; +my (@shared_libs, @executables, @static_libs); +find(\&testfile, $buildroot); + +# Note that all calls to strip on shared libs *must* include the +# --strip-unneeded. +system( + "strip", + "--remove-section=.comment", + "--remove-section=.note", + "--strip-unneeded", + $_) foreach @shared_libs; + +system( + "strip", + "--remove-section=.comment", + "--remove-section=.note", + $_) foreach @executables; + # TODO: we should write a binding for libfile... sub expensive_test { my ($file) = @_; my $type = `file -- $file`; } +# 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: sub testfile() { # skip symlinks return if -l $_; @@ -58,27 +80,3 @@ sub testfile() { return; } } - -################################################################################ -my $buildroot = $ENV{RPM_BUILD_ROOT}; -die "No build root defined" unless $buildroot; -die "Invalid build root" unless -d $buildroot; -chdir($buildroot) or die "Can't cd to $buildroot: $!"; - -@shared_libs = @executables = @static_libs = (); -find(\&testfile, $buildroot); - -# Note that all calls to strip on shared libs *must* include the -# --strip-unneeded. -system( - "strip", - "--remove-section=.comment", - "--remove-section=.note", - "--strip-unneeded", - $_) foreach @shared_libs; - -system( - "strip", - "--remove-section=.comment", - "--remove-section=.note", - $_) foreach @executables; |