[debhelper-devel] [debhelper] 03/03: dh_clean: Bulk delete most files and dirs

Niels Thykier nthykier at moszumanska.debian.org
Sun Jun 4 13:28:22 UTC 2017


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit d263d2719b9f2ee45fa75170e91f35157b8e0e5f
Author: Niels Thykier <niels at thykier.net>
Date:   Sun Jun 4 13:26:00 2017 +0000

    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.
---
 debian/changelog |  3 +++
 dh_clean         | 15 +++++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index aa11c07..f6d5543 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,9 @@ debhelper (10.5) UNRELEASED; urgency=medium
     override targets to be ignored.  Thanks to Gianfranco Costamagna
     for reporting it and Iain Lane for tracing it to the commit
     that introduced the issue.  (Closes: #863887)
+  * dh_clean: Bulk delete most files and directories, which gives a
+    noticable speed up for source packages building many binary
+    packages.
 
   [ Iain Lane ]
   * Dh_Lib: Re-add warning + exit 0 for the -i/-a shortcut that was
diff --git a/dh_clean b/dh_clean
index 7da59ac..b0c7af3 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 '') {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list