From bf18013139a7db511be17319079bd108f76146ee Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Wed, 24 Feb 2021 16:40:40 +0000
Subject: [PATCH] pv-wrap: Don't try so hard to use host graphics by default

For historical reasons, we assume that /run/host is a relatively
complete view of the host system, like it would be inside Flatpak.
However, in a systemd-nspawn container, /run/host contains other
things but not usually /usr or /etc.

Previously, the default was exactly equivalent to the old
PRESSURE_VESSEL_HOST_GRAPHICS=1, which in turn is equivalent to either
PRESSURE_VESSEL_GRAPHICS_PROVIDER=/run/host (if we appear to be in a
container) or PRESSURE_VESSEL_GRAPHICS_PROVIDER=/ (if not).

Now, the default is basically PRESSURE_VESSEL_GRAPHICS_PROVIDER=/, to
maximize the chance that if Steam games can run in the older
LD_LIBRARY_PATH-based Steam Runtime, they'll also run in our containers.

Resolves: https://github.com/ValveSoftware/steam-runtime/issues/367
Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 pressure-vessel/wrap.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/pressure-vessel/wrap.c b/pressure-vessel/wrap.c
index fbe9436dc..7b295af26 100644
--- a/pressure-vessel/wrap.c
+++ b/pressure-vessel/wrap.c
@@ -1074,7 +1074,7 @@ static GOptionEntry options[] =
     "and will be adjusted for use on the host system if pressure-vessel "
     "is run in a container. The empty string means use the graphics "
     "stack from container."
-    "[Default: $PRESSURE_VESSEL_GRAPHICS_PROVIDER or '/run/host' or '/']", "PATH" },
+    "[Default: $PRESSURE_VESSEL_GRAPHICS_PROVIDER or '/']", "PATH" },
   { "launcher", '\0',
     G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_launcher,
     "Instead of specifying a command with its arguments to execute, all the "
@@ -1431,12 +1431,24 @@ main (int argc,
   if (opt_graphics_provider == NULL)
     {
       /* Also check the deprecated 'PRESSURE_VESSEL_HOST_GRAPHICS' */
-      if (!pv_boolean_environment ("PRESSURE_VESSEL_HOST_GRAPHICS", TRUE))
-        opt_graphics_provider = g_strdup ("");
-      else if (g_file_test ("/run/host", G_FILE_TEST_IS_DIR))
-        opt_graphics_provider = g_strdup ("/run/host");
+      Tristate value = tristate_environment ("PRESSURE_VESSEL_HOST_GRAPHICS");
+
+      if (value == TRISTATE_MAYBE)
+        {
+          opt_graphics_provider = g_strdup ("/");
+        }
       else
-        opt_graphics_provider = g_strdup ("/");
+        {
+          g_warning ("$PRESSURE_VESSEL_HOST_GRAPHICS is deprecated, "
+                     "please use PRESSURE_VESSEL_GRAPHICS_PROVIDER instead");
+
+          if (value == TRISTATE_NO)
+            opt_graphics_provider = g_strdup ("");
+          else if (g_file_test ("/run/host", G_FILE_TEST_IS_DIR))
+            opt_graphics_provider = g_strdup ("/run/host");
+          else
+            opt_graphics_provider = g_strdup ("/");
+        }
     }
 
   g_assert (opt_graphics_provider != NULL);
-- 
GitLab