5 dh_clean - clean up package build directories
10 use Debian::Debhelper::Dh_Lib;
14 B<dh_clean> [S<I<debhelper options>>] [B<-k>] [B<-d>] [B<-X>I<item>] [S<I<file ...>>]
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 some
20 other files including debian/files, and any detritus left behind by other
21 debhelper commands. It also removes common files that should not appear in a
23 #*# *~ DEADJOE *.orig *.rej *.SUMS TAGS core .deps/* *.P
29 =item B<-k>, B<--keep>
31 Do not delete debian/files. When do you want to use this? Anytime you have a
32 debian/rules that has 2 binary targets that build different .deb packages;
33 for example, one target is binary-arch, and the other is binary-indep, or
34 one target builds the shared library, and the other the -dev package. If you
35 didn't use -k in these cases, then debian/files would be deleted in the
36 middle, and your changes file will only contain the last binary package that
39 =item B<-d>, B<--dirs-only>
41 Only clean the package build directories, do not clean up any other files
44 =item B<-X>I<item> B<--exclude=>I<item>
46 Exclude files that contain "item" anywhere in their filename from being
47 deleted, even if they would normally be deleted. You may use this option
48 multiple times to build up a list of things to exclude.
52 Delete these files too.
60 foreach my $package (@{$dh{DOPACKAGES}}) {
61 my $tmp=tmpdir($package);
62 my $ext=pkgext($package);
65 doit("rm","-f","debian/${ext}substvars")
66 unless excludefile("debian/${ext}substvars");
68 # These are all debhelper temp files, and so it is safe to
70 complex_doit("rm -f debian/$ext*.debhelper");
73 doit ("rm","-rf",$tmp)
74 unless excludefile($tmp);
79 doit("rm","-f","--",@ARGV);
83 doit("rm","-f","debian/files")
84 unless excludefile("debian/files");
87 # See if some files that would normally be deleted are excluded.
89 if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
90 $find_options="-a ! \\( $dh{EXCLUDE_FIND} \\)";
93 # Remove other temp files.
94 complex_doit("find . -type f -a \\
95 \\( -name '#*#' -o -name '.*~' -o -name '*~' -o -name DEADJOE \\
96 -o -name '*.orig' -o -name '*.rej' -o -name '*.bak' \\
97 -o -name '.*.orig' -o -name .*.rej -o -name '.SUMS' \\
98 -o -name TAGS -o -name core -o \\( -path '*/.deps/*' -a -name '*.P' \\) \\
99 \\) $find_options -exec rm -f {} \\;");
101 # Stupid autoconf cache directory.
102 doit("rm", "-rf", "autom4te.cache")
103 unless excludefile("autom4te.cache");
106 doit('rm', '-rf', 'debian/tmp') if -x 'debian/tmp' && ! compat(1) &&
107 ! excludefile("debian/tmp");
113 This program is a part of debhelper.
117 Joey Hess <joeyh@debian.org>