#!/usr/bin/perl # 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; # normalize build root $buildroot =~ s|/$||; sub clean { if (-f $_) { unlink $_ if $_ =~ /^(?: #.*# | .\*~ | DEADJOE | \.cvsignore | .*\.orig | .*\.rej | .*\.bak | .*\.SUMS | TAGS | core | )$/x; unlink $_ if $File::Find::name =~ /\/\.deps\// && $_ =~ /\.P$/; } if (-d $_) { rmtree($_) if $_ =~ /^CVS$/; } } finddepth(\&clean, $buildroot);