From 1e34e1d477f843c0ee2f1a3fddc20201f0233e81 Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton@intel.com>
Date: Wed, 19 Sep 2018 14:44:40 +0100
Subject: [PATCH] Allow the environment to override where gnupg looks for its
 own files. Useful in native builds.

Upstream-Status: Inappropriate [OE-specific]
Signed-off-by: Ross Burton <ross.burton@intel.com>

Signed-off-by: Alexander Kanavin <alex@linutronix.de>

---
 common/homedir.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/common/homedir.c b/common/homedir.c
index 174d961..f4c25fb 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -1161,7 +1161,7 @@ gnupg_socketdir (void)
   if (!name)
     {
       unsigned int dummy;
-      name = _gnupg_socketdir_internal (0, &dummy);
+      name = getenv("GNUPG_SOCKETDIR") ?: _gnupg_socketdir_internal (0, &dummy);
       gpgrt_annotate_leaked_object (name);
     }
 
@@ -1193,7 +1193,7 @@ gnupg_sysconfdir (void)
   if (dir)
     return dir;
   else
-    return GNUPG_SYSCONFDIR;
+    return getenv("GNUPG_SYSCONFDIR") ?: GNUPG_SYSCONFDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1229,7 +1229,7 @@ gnupg_bindir (void)
       return name;
     }
   else
-    return GNUPG_BINDIR;
+    return getenv("GNUPG_BINDIR") ?: GNUPG_BINDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1256,7 +1256,7 @@ gnupg_libexecdir (void)
       return name;
     }
   else
-    return GNUPG_LIBEXECDIR;
+    return getenv("GNUPG_LIBEXECDIR") ?: GNUPG_LIBEXECDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1286,7 +1286,7 @@ gnupg_libdir (void)
       return name;
     }
   else
-    return GNUPG_LIBDIR;
+    return getenv("GNUPG_LIBDIR") ?: GNUPG_LIBDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1317,7 +1317,7 @@ gnupg_datadir (void)
       return name;
     }
   else
-    return GNUPG_DATADIR;
+    return getenv("GNUPG_DATADIR") ?: GNUPG_DATADIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1349,7 +1349,7 @@ gnupg_localedir (void)
       return name;
     }
   else
-    return LOCALEDIR;
+    return getenv("LOCALEDIR") ?: LOCALEDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
