Package: debhelper
Version: 9.20150629
Severity: wishlist
Control: block 793404 by -1

Hi!

When a package is built by using dpkg-buildpackage, it will set all
dpkg-architecture variables in the environment, so that the common
idiom:

  DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

avoids having to run dpkg-architecture again.

But when using debhelper/dh, it always calls dpkg-architecture even if
those variables are already set in the environment, which can be quite
costly.

Here's a tentative untested patch that tries to do that.

Thanks,
Guillem
From 3b93e1cb2fbf9179f8f152380bba3e1c3e47d65a Mon Sep 17 00:00:00 2001
From: Guillem Jover <guil...@debian.org>
Date: Fri, 24 Jul 2015 05:35:18 +0200
Subject: [PATCH] Dh_Lib: Try to use dpkg-architecture variables from the
 environment
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This should avoid quite costly calls to dpkg-architecture, when the
user has preinitialized them either through dpkg-buildpackage or
«dpkg-architecture -c debian/rules binary» for example.

Signed-off-by: Guillem Jover <guil...@debian.org>
---
 Debian/Debhelper/Dh_Lib.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index f195367..387f90a 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -763,7 +763,10 @@ sub excludefile {
 	my %dpkg_arch_output;
 	sub dpkg_architecture_value {
 		my $var = shift;
-		if (! exists($dpkg_arch_output{$var})) {
+		if (exists($ENV{$var})) {
+			return $ENV{$var};
+		}
+		elsif (! exists($dpkg_arch_output{$var})) {
 			local $_;
 			open(PIPE, '-|', 'dpkg-architecture')
 				or error("dpkg-architecture failed");
-- 
2.5.0.rc2.392.g76e840b

Reply via email to