]> git.donarmstrong.com Git - debhelper.git/blob - dh_clean
r420: big monsta changes
[debhelper.git] / dh_clean
1 #!/usr/bin/perl -w
2 #
3 # Clean up $TMP and other tepmorary files generated by the
4 # build process.
5
6 use strict;
7 use Debian::Debhelper::Dh_Lib;
8 init();
9
10 foreach my $package (@{$dh{DOPACKAGES}}) {
11         my $tmp=tmpdir($package);
12         my $ext=pkgext($package);
13
14         if (! $dh{D_FLAG}) {
15                 doit("rm","-f","debian/${ext}substvars",
16                         "debian/${ext}postinst.debhelper",
17                         "debian/${ext}postrm.debhelper",
18                         "debian/${ext}preinst.debhelper",
19                         "debian/${ext}prerm.debhelper");
20         }
21         
22         doit ("rm","-rf",$tmp);
23 }
24
25 if (! $dh{D_FLAG}) {
26         if (@ARGV) {
27                 doit("rm","-f","--",@ARGV);
28         }
29
30         if (! $dh{K_FLAG}) {
31                 doit("rm","-f","debian/files");
32         }
33
34         # See if some files that would normally be deleted are excluded.
35         my $find_options='';
36         if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
37                 $find_options="-a ! ( $dh{EXCLUDE_FIND} )";
38         }
39
40         # Remove other temp files.
41         # (The \s+ is important, \s won't work because find would get null
42         # parameters). Note that you _don't_ quote wildcards used by find
43         # in here.
44         doit(split(/\s+/,"find . -type f -a
45                 ( -name #*# -o -name *~ -o -name DEADJOE
46                  -o -name *.orig -o -name *.rej -o -name *.bak
47                  -o -name .*.orig -o -name .*.rej -o -name .SUMS
48                  -o -name TAGS -o -name core -o ( -path */.deps/* -a -name *.P )
49                 ) $find_options -exec rm -f {} ;"));
50 }
51
52 doit('rm', '-rf', 'debian/tmp') if -x 'debian/tmp' && ! compat(1);
53