From d263d2719b9f2ee45fa75170e91f35157b8e0e5f Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Sun, 4 Jun 2017 13:26:00 +0000 Subject: dh_clean: Bulk delete most files and dirs This cuts dh_clean runtime in half as measured in the debhelper source package with 1000 dummy packages added to d/control. --- dh_clean | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'dh_clean') diff --git a/dh_clean b/dh_clean index 7da59acd..b0c7af37 100755 --- a/dh_clean +++ b/dh_clean @@ -88,12 +88,14 @@ if ($dh{K_FLAG}) { # Remove the debhelper stamp file doit('rm', '-f', 'debian/debhelper-build-stamp') if not $dh{D_FLAG}; +my (@clean_files, @clean_dirs); + foreach my $package (@{$dh{DOPACKAGES}}) { my $tmp=tmpdir($package); my $ext=pkgext($package); if (! $dh{D_FLAG}) { - doit("rm","-f","debian/${ext}substvars") + push(@clean_files, "debian/${ext}substvars") unless excludefile("debian/${ext}substvars"); # These are all debhelper temp files, and so it is safe to @@ -101,7 +103,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) { complex_doit("rm -f debian/$ext*.debhelper"); } - doit ("rm","-rf",$tmp."/") + push(@clean_dirs , "${tmp}/") unless excludefile($tmp); } @@ -121,7 +123,6 @@ if (! $dh{D_FLAG} && ! $dh{K_FLAG}) { } if (! $dh{D_FLAG}) { - my (@clean_files, @clean_dirs); if (@ARGV) { push(@clean_files, grep { !m@/$@ } @ARGV); push(@clean_dirs, grep { m@/$@ } @ARGV); @@ -135,13 +136,15 @@ if (! $dh{D_FLAG}) { push(@clean_dirs, grep { m@/$@ } @clean); } - doit("rm","-f","debian/files") + push(@clean_files, 'debian/files') unless excludefile("debian/files"); } +} - doit('rm', '-f', '--', @clean_files) if @clean_files; - doit('rm', '-fr', '--', @clean_dirs) if @clean_dirs; +xargs(\@clean_files, 'rm', '-f', '--') if @clean_files; +xargs(\@clean_dirs, 'rm', '-fr', '--') if @clean_dirs; +if (! $dh{D_FLAG}) { # See if some files that would normally be deleted are excluded. my $find_options=''; if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') { -- cgit v1.2.3