From 3b93e1cb2fbf9179f8f152380bba3e1c3e47d65a Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@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 <guillem@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

