]> git.donarmstrong.com Git - debhelper.git/blob - dh_clean
cmake: Pass CPPFLAGS in CFLAGS. Closes: #668813 Thanks, Simon Ruderich for the patch...
[debhelper.git] / dh_clean
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_clean - clean up package build directories
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_clean> [S<I<debhelper options>>] [B<-k>] [B<-d>] [B<-X>I<item>] [S<I<file> ...>]
15
16 =head1 DESCRIPTION
17
18 B<dh_clean> is a debhelper program that is responsible for cleaning up after a
19 package is built. It removes the package build directories, and removes some
20 other files including F<debian/files>, and any detritus left behind by other
21 debhelper commands. It also removes common files that should not appear in a
22 Debian diff:
23   #*# *~ DEADJOE *.orig *.rej *.SUMS TAGS .deps/* *.P *-stamp
24
25 It does not run "make clean" to clean up after the build process. Use
26 L<dh_auto_clean(1)> to do things like that.
27
28 B<dh_clean> (or "B<dh clean>") should be the last debhelper command run in the
29 B<clean> target in F<debian/rules>.
30
31 =head1 FILES
32
33 =over 4
34
35 =item F<debian/clean>
36
37 Can list other files to be removed.
38
39 =back
40
41 =head1 OPTIONS
42
43 =over 4
44
45 =item B<-k>, B<--keep>
46
47 This is deprecated, use L<dh_prep(1)> instead.
48
49 =item B<-d>, B<--dirs-only>
50
51 Only clean the package build directories, do not clean up any other files
52 at all.
53
54 =item B<-X>I<item> B<--exclude=>I<item>
55
56 Exclude files that contain I<item> anywhere in their filename from being
57 deleted, even if they would normally be deleted. You may use this option
58 multiple times to build up a list of things to exclude.
59
60 =item I<file> ...
61
62 Delete these I<file>s too.
63
64 =back
65
66 =cut
67
68 init(options => {
69         "dirs-only" => \$dh{D_FLAG},
70 });
71 inhibit_log();
72
73 if ($dh{K_FLAG}) {
74         # dh_prep will be emulated (mostly) by the code below.
75         warning("dh_clean -k is deprecated; use dh_prep instead");
76 }
77
78 foreach my $package (@{$dh{DOPACKAGES}}) {
79         my $tmp=tmpdir($package);
80         my $ext=pkgext($package);
81
82         if (! $dh{D_FLAG}) {
83                 doit("rm","-f","debian/${ext}substvars")
84                         unless excludefile("debian/${ext}substvars");
85                 
86                 # These are all debhelper temp files, and so it is safe to 
87                 # wildcard them.
88                 complex_doit("rm -f debian/$ext*.debhelper");
89         }
90         
91         doit ("rm","-rf",$tmp."/")
92                 unless excludefile($tmp);
93 }
94
95 # Remove all debhelper logs.
96 if (! $dh{D_FLAG} && ! $dh{K_FLAG}) {
97         complex_doit("rm","-f","debian/*.debhelper.log");
98         if (compat(1)) {
99                 doit("rm","-f","debian/debhelper.log");
100         }
101 }
102
103 if (! $dh{D_FLAG}) {
104         if (@ARGV) {
105                 doit("rm","-f","--",@ARGV);
106         }
107
108         if (! $dh{K_FLAG}) {
109                 if (!compat(6) && -e "debian/clean") {
110                         my @clean=grep { ! excludefile($_) }
111                                 filearray("debian/clean", ".");
112                         doit("rm","-f","--",@clean) if @clean;
113                 }
114
115                 doit("rm","-f","debian/files")
116                         unless excludefile("debian/files");
117         }
118
119         # See if some files that would normally be deleted are excluded.
120         my $find_options='';
121         if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
122                 $find_options="! \\( $dh{EXCLUDE_FIND} \\) -a";
123         }
124
125         # Remove other temp files.
126         complex_doit("find . $find_options \\( \\( -type f -a \\
127                 \\( -name '#*#' -o -name '.*~' -o -name '*~' -o -name DEADJOE \\
128                  -o -name '*.orig' -o -name '*.rej' -o -name '*.bak' \\
129                  -o -name '.*.orig' -o -name .*.rej -o -name '.SUMS' \\
130                  -o -name TAGS -o \\( -path '*/.deps/*' -a -name '*.P' \\) \\
131                 \\) -exec rm -f {} \\; \\) -o \\
132                 \\( -type d -a -name autom4te.cache -prune -exec rm -rf {} \\; \\) \\)");
133 }
134
135 doit('rm', '-rf', 'debian/tmp') if -x 'debian/tmp' && ! compat(1) &&
136                                    ! excludefile("debian/tmp");
137
138 if (!compat(6) && !$dh{K_FLAG}) {
139         complex_doit('rm -f *-stamp');
140 }
141
142 =head1 SEE ALSO
143
144 L<debhelper(7)>
145
146 This program is a part of debhelper.
147
148 =head1 AUTHOR
149
150 Joey Hess <joeyh@debian.org>
151
152 =cut