Package: glib2.0 / 2.58.3-1

debian/04_homedir_env.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
From: Iain Lane <laney@debian.org>
Date: Sat, 23 Feb 2013 19:27:38 +0100
Subject: Handle the G_HOME environment variable

g_get_home_dir() now respects the HOME environment variable but we'll keep
G_HOME for now as packages in Debian rely on it.

Modified from an earlier patch by Josselin Mouette.

Forwarded: not-needed, Debian-specific
---
 docs/reference/glib/running.xml | 18 ++++++++++++++++++
 glib/gutils.c                   | 10 +++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/docs/reference/glib/running.xml b/docs/reference/glib/running.xml
index 8e4ffec..ec33ea6 100644
--- a/docs/reference/glib/running.xml
+++ b/docs/reference/glib/running.xml
@@ -256,6 +256,24 @@ How to run and debug your GLib application
   </para>
 </formalpara>
 
+<formalpara id="G_HOME">
+  <title><envar>G_HOME</envar></title>
+
+  <para>
+    Historically, GLib applications ignored the <envar>HOME</envar>
+    environment variable on Unix systems, instead using the user directory
+    as specified by the <filename>passwd</filename> entry. As of GLib 2.35.3,
+    this is no longer true: <envar>HOME</envar> is respected.
+  </para>
+  <para>
+    The <envar>G_HOME</envar> environment variable will override any
+    other setting for the home directory. It is not meant for daily usage, but
+    it is useful in testing or building environments. As <envar>HOME</envar> is
+    now supported by GLib, <envar>G_HOME</envar> is deprecated and will be
+    removed in a future release.
+  </para>
+</formalpara>
+
 </refsect2>
 
 <refsect2 id="setlocale">
diff --git a/glib/gutils.c b/glib/gutils.c
index 2b750ab..4fceaa2 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -814,6 +814,12 @@ g_get_real_name (void)
  * should either directly check the `HOME` environment variable yourself
  * or unset it before calling any functions in GLib.
  *
+ * When the pre-2.36 behaviour was in effect, Debian provided the
+ * <envar>G_HOME</envar> environment variable for testing and development
+ * purposes. This is now unnecessary as <envar>HOME</envar> can be used
+ * directly, but is retained for compatibility. It is deprecated and will be
+ * removed in a future release.
+ *
  * Returns: (type filename): the current user's home directory
  */
 const gchar *
@@ -826,7 +832,9 @@ g_get_home_dir (void)
       gchar *tmp;
 
       /* We first check HOME and use it if it is set */
-      tmp = g_strdup (g_getenv ("HOME"));
+      tmp = g_strdup (g_getenv ("G_HOME"));
+      if (!tmp)
+        tmp = g_strdup (g_getenv ("HOME"));
 
 #ifdef G_OS_WIN32
       /* Only believe HOME if it is an absolute path and exists.