From 3fc0d1eafae7643111ec6a1a01e2f1a90b4c3701 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Tue, 29 Jan 2008 22:03:13 +0000 Subject: rewrite in pure perl --- clean_files | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'clean_files') 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); -- cgit v1.2.1