[debhelper-devel] [debhelper] 01/01: Dh_Lib: Use File::Path instead of "install -d"

Niels Thykier nthykier at moszumanska.debian.org
Sun Jun 25 11:20:28 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 da2bcf70a826f66de14139109695f89711632a47
Author: Niels Thykier <niels at thykier.net>
Date:   Sun Jun 25 11:17:33 2017 +0000

    Dh_Lib: Use File::Path instead of "install -d"
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 Debian/Debhelper/Dh_Lib.pm | 27 ++++++++++++++++++++++++---
 debian/changelog           |  6 +++++-
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index e7ac2d2..4aec5ef 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -376,9 +376,30 @@ sub error_exitcode {
 	}
 }
 
-sub install_dir {
-	my @to_create = grep { not -d $_ } @_;
-	doit('install', '-d', @to_create) if @to_create;
+{
+	my $_loaded = 0;
+	sub install_dir {
+		my @to_create = grep { not -d $_ } @_;
+		return if not @to_create;
+		if (not $_loaded) {
+			$_loaded++;
+			require File::Path;
+		}
+		verbose_print(sprintf('install -d %s', escape_shell(@to_create)))
+			if $dh{VERBOSE};
+		return 1 if $dh{NO_ACT};
+		eval {
+			File::Path::make_path(@to_create, {
+				# install -d uses 0755 (no umask), make_path uses 0777 (& umask) by default.
+				# Since we claim to run install -d, then ensure the mode is correct.
+				'chmod' => 0755,
+			});
+		};
+		if (my $err = "$@") {
+			$err =~ s/\s+at\s+\S+\s+line\s+\d+\.?\n//;
+			error($err);
+		}
+	}
 }
 
 sub rename_path {
diff --git a/debian/changelog b/debian/changelog
index 682a2eb..2e7f12f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,7 +18,8 @@ debhelper (10.5) UNRELEASED; urgency=medium
     is not needed.
   * Dh_Lib.pm: Fix typo in error message.
   * Dh_Lib.pm: Rewrite install_* to use File::Copy to avoid the
-    overhead of a fork+exec per file.
+    overhead of a fork+exec per file.  For simplicity, the verbose
+    output still claim debhelper uses "install -p -m <mode>" for this.
   * Dh_Lib.pm: Replace most of the fork+exec calls to mv for simple
     file renames.
   * Dh_Lib.pm: Add sub to make common dh_* tools do their thing in
@@ -55,6 +56,9 @@ debhelper (10.5) UNRELEASED; urgency=medium
     (Closes: #761024)
   * dh_installcatalogs: Check the return code of close when generating
     a catalog for sgml-base.
+  * Dh_Lib.pm: Emulate "install -d" with File::Path to avoid a fork+exec
+    for creating directories.  For simplicity, the verbose output still
+    claim debhelper uses "install -d" for this.
 
   [ Iain Lane ]
   * Dh_Lib: Re-add warning + exit 0 for the -i/-a shortcut that was

-- 
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