aboutsummaryrefslogtreecommitdiffstats
path: root/clean_files
blob: 8427140ece6d1e3bf6c1dda75999bd251e5d97c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl
# remove backup files
# $Id: clean_files 257535 2009-05-23 12:47:30Z guillomovitch $

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);