From 89ae4f03307104689e1857d9857d452af6b35ac4 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 260aeb2..1aeb08d 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -1143,7 +1143,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);
     }
 
@@ -1175,7 +1175,7 @@ gnupg_sysconfdir (void)
   if (dir)
     return dir;
   else
-    return GNUPG_SYSCONFDIR;
+    return getenv("GNUPG_SYSCONFDIR") ?: GNUPG_SYSCONFDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1211,7 +1211,7 @@ gnupg_bindir (void)
       return name;
     }
   else
-    return GNUPG_BINDIR;
+    return getenv("GNUPG_BINDIR") ?: GNUPG_BINDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1238,7 +1238,7 @@ gnupg_libexecdir (void)
       return name;
     }
   else
-    return GNUPG_LIBEXECDIR;
+    return getenv("GNUPG_LIBEXECDIR") ?: GNUPG_LIBEXECDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1268,7 +1268,7 @@ gnupg_libdir (void)
       return name;
     }
   else
-    return GNUPG_LIBDIR;
+    return getenv("GNUPG_LIBDIR") ?: GNUPG_LIBDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1299,7 +1299,7 @@ gnupg_datadir (void)
       return name;
     }
   else
-    return GNUPG_DATADIR;
+    return getenv("GNUPG_DATADIR") ?: GNUPG_DATADIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
@@ -1331,7 +1331,7 @@ gnupg_localedir (void)
       return name;
     }
   else
-    return LOCALEDIR;
+    return getenv("LOCALEDIR") ?: LOCALEDIR;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
