]> git.donarmstrong.com Git - debhelper.git/blob - dh_clean
r353: * Modified all postinst script fragments to only run when called with
[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 Debian::Debhelper::Dh_Lib;
7 init();
8
9 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
10         $TMP=tmpdir($PACKAGE);
11         $EXT=pkgext($PACKAGE);
12
13         if (! $dh{D_FLAG}) {
14                 doit("rm","-f","debian/${EXT}substvars",
15                         "debian/${EXT}postinst.debhelper",
16                         "debian/${EXT}postrm.debhelper",
17                         "debian/${EXT}preinst.debhelper",
18                         "debian/${EXT}prerm.debhelper");
19         }
20         
21         doit ("rm","-rf",$TMP);
22 }
23
24 if (! $dh{D_FLAG}) {
25         if (@ARGV) {
26                 doit("rm","-f","--",@ARGV);
27         }
28
29         if (! $dh{K_FLAG}) {
30                 doit("rm","-f","debian/files");
31         }
32
33         # See if some files that would normally be deleted are excluded.
34         if (! defined($dh{EXCLUDE_FIND}) || $dh{EXCLUDE_FIND} eq '') {
35                 $find_options="";
36         }
37         else {
38                 $find_options="-a ! ( $dh{EXCLUDE_FIND} )";
39         }
40
41         # Remove other temp files.
42         # (The \s+ is important, \s won't work because find would get null
43         # parameters). Note that you _don't_ quote wildcards used by find
44         # in here.
45         doit(split(/\s+/,"find . -type f -a
46                 ( -name #*# -o -name *~ -o -name DEADJOE
47                  -o -name *.orig -o -name *.rej -o -name *.bak
48                  -o -name .*.orig -o -name .*.rej -o -name .SUMS
49                  -o -name TAGS -o -name core -o ( -path */.deps/* -a -name *.P )
50                 ) $find_options -exec rm -f {} ;"));
51 }
52
53 doit('rm', '-rf', 'debian/tmp')
54         if -x 'debian/tmp' && ! Debian::Debhelper::Dh_Lib::compat(1);
55