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 .deps/* *.P *-stamp
25 The debian/clean file can list other files to be removed.
27 It does not run "make clean" to clean up after the build process. Use
28 L<dh_auto_clean(1)> to do things like that.
30 dh_clean (or "dh clean") should be the last debhelper command run in the
31 clean target in debian/rules.
37 =item B<-k>, B<--keep>
39 This is deprecated, use L<dh_prep(1)> instead.
41 =item B<-d>, B<--dirs-only>
43 Only clean the package build directories, do not clean up any other files
46 =item B<-X>I<item> B<--exclude=>I<item>
48 Exclude files that contain "item" anywhere in their filename from being
49 deleted, even if they would normally be deleted. You may use this option
50 multiple times to build up a list of things to exclude.
54 Delete these files too.
61 "dirs-only" => \$dh{D_FLAG},
66 # dh_prep will be emulated (mostly) by the code below.
67 # TODO deprecation warning
70 foreach my $package (@{$dh{DOPACKAGES}}) {
71 my $tmp=tmpdir($package);
72 my $ext=pkgext($package);
75 doit("rm","-f","debian/${ext}substvars")
76 unless excludefile("debian/${ext}substvars");
78 # These are all debhelper temp files, and so it is safe to
80 complex_doit("rm -f debian/$ext*.debhelper");
83 doit("rm","-f","debian/${ext}debhelper.log");
87 doit ("rm","-rf",$tmp."/")
88 unless excludefile($tmp);
93 doit("rm","-f","--",@ARGV);
97 if (!compat(6) && -e "debian/clean") {
98 my @clean=grep { ! excludefile($_) }
99 filearray("debian/clean", ".");
100 doit("rm","-f","--",@clean) if @clean;
103 doit("rm","-f","debian/files")
104 unless excludefile("debian/files");
107 # See if some files that would normally be deleted are excluded.
109 if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
110 $find_options="! \\( $dh{EXCLUDE_FIND} \\) -a";
113 # Remove other temp files.
114 complex_doit("find . $find_options \\( \\( -type f -a \\
115 \\( -name '#*#' -o -name '.*~' -o -name '*~' -o -name DEADJOE \\
116 -o -name '*.orig' -o -name '*.rej' -o -name '*.bak' \\
117 -o -name '.*.orig' -o -name .*.rej -o -name '.SUMS' \\
118 -o -name TAGS -o \\( -path '*/.deps/*' -a -name '*.P' \\) \\
119 \\) -exec rm -f {} \\; \\) -o \\
120 \\( -type d -a -name autom4te.cache -prune -exec rm -rf {} \\; \\) \\)");
123 doit('rm', '-rf', 'debian/tmp') if -x 'debian/tmp' && ! compat(1) &&
124 ! excludefile("debian/tmp");
126 if (!compat(6) && !$dh{K_FLAG}) {
127 complex_doit('rm -f *-stamp');
134 This program is a part of debhelper.
138 Joey Hess <joeyh@debian.org>