aboutsummaryrefslogtreecommitdiffstats
path: root/clean_files
blob: 60c5e7e3871d3d38fa3a068bbd850bf7f1e84942 (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$

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