From 1b6b1bb07276cb4247e459a1472a5df55b5d6eb2 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Fri, 8 May 2009 16:36:18 +0000 Subject: fix exception handling: - exported string is now a single regexp, as automatic dependencies exceptions - don't change directory in compress_file, so as to match absolute path easily, as $File::Find::name will always be relative to $buildroot --- compress_files | 19 ++++++++----------- fix_eol | 10 +++------- strip_and_check_elf_files | 5 ++--- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/compress_files b/compress_files index 8894d73..3a05143 100755 --- a/compress_files +++ b/compress_files @@ -15,21 +15,18 @@ die "Unknown extension $ext" unless $ext =~ /^\.(?:gz|bz2|lzma|xz)$/; 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: $!"; +# normalize build root +$buildroot =~ s|/$||; -my $exclude_pattern = join('|', - map { '(:?' . quotemeta($_) . ')' } - $ENV{EXCLUDE_FROM_COMPRESS} ? - split(' ', $ENV{EXCLUDE_FROM_COMPRESS}) : () -); -$exclude_pattern = qr/$exclude_pattern/; +my $exclude_pattern = $ENV{EXCLUDE_FROM_COMPRESS} ? + qr/$ENV{EXCLUDE_FROM_COMPRESS}/ : undef; -my @sodirs = qw{ +my @sodirs = map { "$buildroot/$_" } qw{ usr/man usr/X11R6/man usr/lib/perl5/man }; -my @mandirs = qw{ +my @mandirs = map { "$buildroot/$_" } qw{ usr/info usr/share/info usr/man @@ -49,7 +46,7 @@ my $so_function = sub { # to open every man page. 1024 is arbitrary. return if -s $_ > 1024; # skip excluded files - return if $File::Find::name =~ $exclude_pattern; + return if $exclude_pattern && $File::Find::name =~ $exclude_pattern; # Test first line of file for the .so thing. my $SOTEST; @@ -86,7 +83,7 @@ my $function = sub { # skip directories return if -d $_; # skip excluded files - return if $File::Find::name =~ $exclude_pattern; + return if $exclude_pattern && $File::Find::name =~ $exclude_pattern; # skip compressed files return if $_ =~ /\.(?:gz|bz2|lzma|xz)$/; # skip particular files diff --git a/fix_eol b/fix_eol index 8634b46..4381cf5 100755 --- a/fix_eol +++ b/fix_eol @@ -13,12 +13,8 @@ die "Invalid build root" unless -d $buildroot; # normalize build root $buildroot =~ s|/$||; -my $exclude_string = join('|', - map { '(:?' . quotemeta($_) . ')' } - $ENV{EXCLUDE_FROM_EOL_CONVERSION} ? - split(' ', $ENV{EXCLUDE_FROM_EOL_CONVERSION}) : () -); -my $exclude_pattern = qr/$exclude_string/; +my $exclude_pattern = $ENV{EXCLUDE_FROM_EOL_CONVERSION} ? + qr/$ENV{EXCLUDE_FROM_EOL_CONVERSION}/ : undef; find(\&convert, $buildroot); @@ -30,7 +26,7 @@ sub convert { # skip binary files return unless -T $_; # skip excluded files - return if $exclude_string && $File::Find::name =~ $exclude_pattern; + return if $exclude_pattern && $File::Find::name =~ $exclude_pattern; # check if first line has less than 80 characters and ends with \r\n open(my $in, '<', $_) or die "Unable to open file $_: $!"; diff --git a/strip_and_check_elf_files b/strip_and_check_elf_files index 0870e99..b11e099 100755 --- a/strip_and_check_elf_files +++ b/strip_and_check_elf_files @@ -22,9 +22,8 @@ sub strip_files { my @to_strip = (@shared_libs, @executables); if ($ENV{EXCLUDE_FROM_STRIP}) { - my $exclude_pattern = join('|', - map { '(:?' . quotemeta($_) . ')' } split(' ', $ENV{EXCLUDE_FROM_STRIP})); - @to_strip = grep { !/$exclude_pattern/ } @to_strip; + my $exclude_pattern = qr/$ENV{EXCLUDE_FROM_STRIP}/; + @to_strip = grep { !/$exclude_pattern/ } @to_strip; } system( -- cgit v1.2.1