]> git.donarmstrong.com Git - debhelper.git/blob - dh_clean
r425: mode pod man pages
[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   dh_clean [debhelper options] [-k] [-d] [file ...] [-Xitem]
15
16 =head1 DESCRIPTION
17
18 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
20 some
21 other files, such as debian/substvars, debian/files, and any detritus left
22 behind by other debhelper commands. It also removes common files that
23 should not appear in a debian diff:
24   #*# *~ DEADJOE *.orig *.rej *.SUMS TAGS core .deps/* *.P
25
26 =head1 OPTIONS
27
28 =over 4
29
30 =item B<-k>, B<--keep>
31
32 Do not delete debian/files. When do you want to use this? Anytime you have a
33 debian/rules that has 2 binary targets that build different .deb packages;
34 for example, one target is binary-arch, and the other is binary-indep, or
35 one target builds the shared library, and the other the -dev package. If you
36 didn't use -k in these cases, then debian/files would be deleted in the
37 middle, and your changes file will only contain the last binary package that
38 was built.
39
40 =item B<-d>, B<--dirs-only>
41
42 Only clean the package build directories, do not clean up any other files
43 at all.
44
45 =item B<-X>I<item> B<--exclude=>I<item>
46
47 Exclude files that contain "item" anywhere in their filename from being
48 deleted, even if they would normally be deleted. You may use this option
49 multiple times to build up a list of things to exclude.
50
51 =item I<file ...>
52
53 Delete these files too.
54
55 =back
56
57 =cut
58
59 init();
60
61 foreach my $package (@{$dh{DOPACKAGES}}) {
62         my $tmp=tmpdir($package);
63         my $ext=pkgext($package);
64
65         if (! $dh{D_FLAG}) {
66                 doit("rm","-f","debian/${ext}substvars",
67                         "debian/${ext}postinst.debhelper",
68                         "debian/${ext}postrm.debhelper",
69                         "debian/${ext}preinst.debhelper",
70                         "debian/${ext}prerm.debhelper");
71         }
72         
73         doit ("rm","-rf",$tmp);
74 }
75
76 if (! $dh{D_FLAG}) {
77         if (@ARGV) {
78                 doit("rm","-f","--",@ARGV);
79         }
80
81         if (! $dh{K_FLAG}) {
82                 doit("rm","-f","debian/files");
83         }
84
85         # See if some files that would normally be deleted are excluded.
86         my $find_options='';
87         if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
88                 $find_options="-a ! ( $dh{EXCLUDE_FIND} )";
89         }
90
91         # Remove other temp files.
92         # (The \s+ is important, \s won't work because find would get null
93         # parameters). Note that you _don't_ quote wildcards used by find
94         # in here.
95         doit(split(/\s+/,"find . -type f -a
96                 ( -name #*# -o -name *~ -o -name DEADJOE
97                  -o -name *.orig -o -name *.rej -o -name *.bak
98                  -o -name .*.orig -o -name .*.rej -o -name .SUMS
99                  -o -name TAGS -o -name core -o ( -path */.deps/* -a -name *.P )
100                 ) $find_options -exec rm -f {} ;"));
101 }
102
103 doit('rm', '-rf', 'debian/tmp') if -x 'debian/tmp' && ! compat(1);
104
105 =head1 SEE ALSO
106
107 L<debhelper(1)|debhelper>
108
109 This program is a part of debhelper.
110
111 =head1 AUTHOR
112
113 Joey Hess <joeyh@debian.org>
114
115 =cut