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 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
23 #*# *~ DEADJOE *.orig *.rej *.SUMS TAGS .deps/* *.P *-stamp
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.
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>.
37 Can list other files to be removed.
45 =item B<-k>, B<--keep>
47 This is deprecated, use L<dh_prep(1)> instead.
49 =item B<-d>, B<--dirs-only>
51 Only clean the package build directories, do not clean up any other files
54 =item B<-X>I<item> B<--exclude=>I<item>
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.
62 Delete these I<file>s too.
69 "dirs-only" => \$dh{D_FLAG},
74 # dh_prep will be emulated (mostly) by the code below.
75 warning("dh_clean -k is deprecated; use dh_prep instead");
78 foreach my $package (@{$dh{DOPACKAGES}}) {
79 my $tmp=tmpdir($package);
80 my $ext=pkgext($package);
83 doit("rm","-f","debian/${ext}substvars")
84 unless excludefile("debian/${ext}substvars");
86 # These are all debhelper temp files, and so it is safe to
88 complex_doit("rm -f debian/$ext*.debhelper");
91 doit("rm","-f","debian/${ext}debhelper.log");
95 doit ("rm","-rf",$tmp."/")
96 unless excludefile($tmp);
101 doit("rm","-f","--",@ARGV);
105 if (!compat(6) && -e "debian/clean") {
106 my @clean=grep { ! excludefile($_) }
107 filearray("debian/clean", ".");
108 doit("rm","-f","--",@clean) if @clean;
111 doit("rm","-f","debian/files")
112 unless excludefile("debian/files");
115 # See if some files that would normally be deleted are excluded.
117 if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
118 $find_options="! \\( $dh{EXCLUDE_FIND} \\) -a";
121 # Remove other temp files.
122 complex_doit("find . $find_options \\( \\( -type f -a \\
123 \\( -name '#*#' -o -name '.*~' -o -name '*~' -o -name DEADJOE \\
124 -o -name '*.orig' -o -name '*.rej' -o -name '*.bak' \\
125 -o -name '.*.orig' -o -name .*.rej -o -name '.SUMS' \\
126 -o -name TAGS -o \\( -path '*/.deps/*' -a -name '*.P' \\) \\
127 \\) -exec rm -f {} \\; \\) -o \\
128 \\( -type d -a -name autom4te.cache -prune -exec rm -rf {} \\; \\) \\)");
131 doit('rm', '-rf', 'debian/tmp') if -x 'debian/tmp' && ! compat(1) &&
132 ! excludefile("debian/tmp");
134 if (!compat(6) && !$dh{K_FLAG}) {
135 complex_doit('rm -f *-stamp');
142 This program is a part of debhelper.
146 Joey Hess <joeyh@debian.org>