From b95abf1988a7ba50c19ef14c4a4007e0de02c222 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Sun, 10 Feb 2008 14:36:27 +0000 Subject: use same pattern-based exclusion mecanism as other scripts --- compress_files | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/compress_files b/compress_files index f5d028f..8fc5a1b 100755 --- a/compress_files +++ b/compress_files @@ -16,6 +16,13 @@ die "No build root defined" unless $buildroot; die "Invalid build root" unless -d $buildroot; chdir($buildroot) or die "Can't cd to $buildroot: $!"; +my $exclude_pattern = join('|', + map { '(:?' . quotemeta($_) . ')' } + $ENV{EXCLUDE_FROM_COMPRESS} ? + split(' ', $ENV{EXCLUDE_FROM_COMPRESS}) : () +); +$exclude_pattern = qr/$exclude_pattern/; + # Now the .so conversion. my (@sofiles, @sodests); foreach my $dir (qw{usr/man usr/X11R6/man usr/lib/perl5/man}) { @@ -57,22 +64,6 @@ if ($ext ne '.lzma') { } } -# Exclude files from compression. -if (@files && defined($ENV{EXCLUDE_FROM_COMPRESS})) { - my @new; - foreach (@files) { - my $ok = 1; - foreach my $x (split(' ', $ENV{EXCLUDE_FROM_COMPRESS})) { - if (/\Q$x\E/) { - $ok = ''; - last; - } - } - push @new,$_ if $ok; - } - @files = @new; -} - # Look for files with hard links. If we are going to compress both, # we can preserve the hard link across the compression and save # space in the end. @@ -175,6 +166,8 @@ sub find_so_man() { if (! -f $_ || -s $_ > 1024) { return; } + # skip excluded files + return if $File::Find::name =~ $exclude_pattern; # Test first line of file for the .so thing. my $SOTEST; -- cgit v1.2.1