[debhelper-devel] [debhelper] 01/02: Dh_Lib: Print environment changes when printing *doit commands

Niels Thykier nthykier at moszumanska.debian.org
Sat Jan 20 14:13:31 UTC 2018


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

nthykier pushed a commit to branch master
in repository debhelper.

commit 7853ec7cae69a9e63dd6f8aceb68045a1cba6b04
Author: Niels Thykier <niels at thykier.net>
Date:   Sat Jan 20 14:04:15 2018 +0000

    Dh_Lib: Print environment changes when printing *doit commands
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 debian/changelog               |  3 +++
 lib/Debian/Debhelper/Dh_Lib.pm | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index c150ca6..b6821b3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,9 @@ debhelper (11.1.3) UNRELEASED; urgency=medium
   * debian/control: Add a Breaks on meson to ensure that we have
     meson (>= 0.40.0) as the meson build system uses --wrap-mode.
     This is mostly relevant for backports.
+  * Dh_Lib.pm: When printing commands (e.g. for doit), also show
+    changes to the environment (when done as a part of the
+    command).
 
  -- Niels Thykier <niels at thykier.net>  Sun, 14 Jan 2018 09:54:57 +0000
 
diff --git a/lib/Debian/Debhelper/Dh_Lib.pm b/lib/Debian/Debhelper/Dh_Lib.pm
index 67577c9..9410292 100644
--- a/lib/Debian/Debhelper/Dh_Lib.pm
+++ b/lib/Debian/Debhelper/Dh_Lib.pm
@@ -364,6 +364,25 @@ sub _format_cmdline {
 	my (@cmd) = @_;
 	my $options = ref($cmd[0]) ? shift(@cmd) : {};
 	my $cmd_line = escape_shell(@cmd);
+	if (defined(my $update_env = $options->{update_env})) {
+		my $need_env = 0;
+		my @params;
+		for my $key (sort(keys(%{$update_env}))) {
+			my $value = $update_env->{$key};
+			if (defined($value)) {
+				my $quoted_key = escape_shell($key);
+				push(@params, join('=', $quoted_key, escape_shell($value)));
+				# shell does not like: "FU BAR"=1 cmd
+				# if the ENV key has weird symbols, the best bet is to use env
+				$need_env = 1 if $quoted_key ne $key;
+			} else {
+				$need_env = 1;
+				push(@params, escape_shell("--unset=${key}"));
+			}
+		}
+		unshift(@params, 'env', '--') if $need_env;
+		$cmd_line = join(' ', @params, $cmd_line);
+	}
 	if (defined(my $dir = $options->{chdir})) {
 		$cmd_line = join(' ', 'cd', escape_shell($dir), '&&', $cmd_line) if $dir 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