diff options
author | Guillaume Rousse <guillomovitch@mandriva.org> | 2008-01-29 22:03:13 +0000 |
---|---|---|
committer | Guillaume Rousse <guillomovitch@mandriva.org> | 2008-01-29 22:03:13 +0000 |
commit | 3fc0d1eafae7643111ec6a1a01e2f1a90b4c3701 (patch) | |
tree | 9f416c9b5e315bee4ed1118e9de1c69f36be97cc /clean_files | |
parent | 4c559287d33e4ccfd0f5bc2518d9170697af6a19 (diff) | |
download | spec-helper-3fc0d1eafae7643111ec6a1a01e2f1a90b4c3701.tar spec-helper-3fc0d1eafae7643111ec6a1a01e2f1a90b4c3701.tar.gz spec-helper-3fc0d1eafae7643111ec6a1a01e2f1a90b4c3701.tar.bz2 spec-helper-3fc0d1eafae7643111ec6a1a01e2f1a90b4c3701.tar.xz spec-helper-3fc0d1eafae7643111ec6a1a01e2f1a90b4c3701.zip |
rewrite in pure perl
Diffstat (limited to 'clean_files')
-rwxr-xr-x | clean_files | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/clean_files b/clean_files index f9d6eb9..9b4408c 100755 --- a/clean_files +++ b/clean_files @@ -1,30 +1,37 @@ #!/usr/bin/perl -#--------------------------------------------------------------- -# Project : Linux-Mandrake -# Module : spec-helper -# File : clean_files -# Version : $Id$ -# Author : Frederic Lepied -# Created On : Thu Feb 10 10:29:18 2000 -# Purpose : remove backup files. -#--------------------------------------------------------------- +# remove backup files -################################################################################ use strict; use warnings; +use File::Find; +use File::Path; 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|/$||; -system(split(/\s+/, "find . -type f -a - ( -name #*# -o -name *~ -o -name DEADJOE -o -name .cvsignore - -o -name *.orig -o -name *.rej -o -name *.bak - -o -name .*.orig -o -name .*.rej -o -name .SUMS - -o -name TAGS -o -name core -o ( -path */.deps/* -a -name *.P ) - ) -exec rm -f {} ;")); +sub clean { + if (-f $_) { + unlink $_ if $_ =~ /^(?: + #.*# | + .\*~ | + DEADJOE | + \.cvsignore | + .*\.orig | + .*\.rej | + .*\.bak | + .*\.SUMS | + TAGS | + core | + )$/x; + unlink $_ if $File::Find::name =~ /\/\.deps\// && $_ =~ /\.P$/; + } -system("find . -type d -a -name CVS | xargs rm -rf"); + if (-d $_) { + rmtree($_) if $_ =~ /^CVS$/; + } +} -# clean_files ends here +finddepth(\&clean, $buildroot); |