Package: glib2.0 / 2.42.1-1

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
Description: Handle the G_HOME environment variable to override the passwd entry
 This will allow to fix various kinds of build failures due to restricted
 build environments.
Author: Josselin Mouette <joss@debian.org>
Origin: vendor

--- a/docs/reference/glib/running.xml
+++ b/docs/reference/glib/running.xml
@@ -244,6 +244,24 @@
   </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">
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -806,6 +806,12 @@
  * 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: the current user's home directory
  */
 const gchar *
@@ -818,7 +824,9 @@
       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.