aboutsummaryrefslogtreecommitdiffstats
path: root/clean_files
blob: 9b4408c4015f3f3051c028c8c74ce415079d80d2 (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
#!/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);