From 68c747c60d6fb8d116bcafa3dab01f5acd88c258 Mon Sep 17 00:00:00 2001
From: Ludovico de Nittis <ludovico.denittis@collabora.com>
Date: Mon, 21 Sep 2020 09:59:41 +0200
Subject: [PATCH] Reapply "runtime: Set STEAM_RUNTIME=/ if running in scout"

Setting STEAM_RUNTIME=/ caused configuration changes in libraries like
Pango and GTK, which broke module loading when not in the
LD_LIBRARY_PATH Steam Runtime. We updated the affected libraries' search
paths so it is safe now to reimplement the STEAM_RUNTIME change.

This reverts commit dc71943a and reapplies commit eb716698.

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
---
 pressure-vessel/runtime.c               | 10 ++++++++++
 tests/pressure-vessel/inside-runtime.py |  6 +++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/pressure-vessel/runtime.c b/pressure-vessel/runtime.c
index 41ea410c3..679b5b1b9 100644
--- a/pressure-vessel/runtime.c
+++ b/pressure-vessel/runtime.c
@@ -3225,6 +3225,16 @@ pv_runtime_bind (PvRuntime *self,
       self->adverb_in_container = "/run/pressure-vessel/pv-from-host/bin/pressure-vessel-adverb";
     }
 
+  /* Some games detect that they have been run outside the Steam Runtime
+   * and try to re-run themselves via Steam. Trick them into thinking
+   * they are in the LD_LIBRARY_PATH Steam Runtime.
+   *
+   * We do not do this for games developed against soldier, because
+   * backwards compatibility is not a concern for game developers who
+   * have specifically opted-in to using the newer runtime. */
+  if (self->is_scout)
+    flatpak_bwrap_set_env (bwrap, "STEAM_RUNTIME", "/", TRUE);
+
   pv_runtime_set_search_paths (self, bwrap);
 
   return TRUE;
diff --git a/tests/pressure-vessel/inside-runtime.py b/tests/pressure-vessel/inside-runtime.py
index cb83c29d2..97ee4292c 100755
--- a/tests/pressure-vessel/inside-runtime.py
+++ b/tests/pressure-vessel/inside-runtime.py
@@ -153,7 +153,11 @@ class TestInsideRuntime(BaseTest):
         logger.info(
             'LD_LIBRARY_PATH: %r', os.environ.get('LD_LIBRARY_PATH')
         )
-        # No actual *tests* here just yet - we just log what's there.
+
+        if os.environ.get('TEST_INSIDE_RUNTIME_IS_SCOUT'):
+            self.assertEqual(os.environ.get('STEAM_RUNTIME'), '/')
+        elif os.environ.get('TEST_INSIDE_RUNTIME_IS_SOLDIER'):
+            self.assertEqual(os.environ.get('STEAM_RUNTIME'), None)
 
     def test_overrides(self) -> None:
         if os.getenv('TEST_INSIDE_RUNTIME_IS_COPY'):
-- 
GitLab