From 0e4b325c199354ce54cc4687532cced1440fd496 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 286685f..212a945 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -1213,7 +1213,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);
     }
 
@@ -1245,7 +1245,7 @@ gnupg_sysconfdir (void)
   if (dir)
     return dir;
   else
-    return GNUPG_SYSCONFDIR;
+    return getenv("GNUPG_SYSCONFDIR") ?: GNUPG_SYSCONFDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1281,7 +1281,7 @@ gnupg_bindir (void)
       return name;
     }
   else
-    return GNUPG_BINDIR;
+    return getenv("GNUPG_BINDIR") ?: GNUPG_BINDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1308,7 +1308,7 @@ gnupg_libexecdir (void)
       return name;
     }
   else
-    return GNUPG_LIBEXECDIR;
+    return getenv("GNUPG_LIBEXECDIR") ?: GNUPG_LIBEXECDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1338,7 +1338,7 @@ gnupg_libdir (void)
       return name;
     }
   else
-    return GNUPG_LIBDIR;
+    return getenv("GNUPG_LIBDIR") ?: GNUPG_LIBDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1369,7 +1369,7 @@ gnupg_datadir (void)
       return name;
     }
   else
-    return GNUPG_DATADIR;
+    return getenv("GNUPG_DATADIR") ?: GNUPG_DATADIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1401,7 +1401,7 @@ gnupg_localedir (void)
       return name;
     }
   else
-    return LOCALEDIR;
+    return getenv("LOCALEDIR") ?: LOCALEDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
