From feca5d9b9d67b81e3cde055ef921604dedf0c1cf Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Wed, 31 Jul 2019 18:46:05 +0100
Subject: [PATCH] Improve support for using a chroot as the runtime

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 README.md               | 16 ++++++++++++++--
 pressure-vessel-test-ui |  7 ++++++-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 38b83c6c7..0ab5195a6 100644
--- a/README.md
+++ b/README.md
@@ -242,6 +242,16 @@ Instructions for testing
             -C ~/.steam/steam/steamapps/common/SteamLinuxRuntime/scout_sdk/files/lib/debug/ \
             -xzvf ~/com.valvesoftware.SteamRuntime.Sdk-amd64,i386-scout-debug.tar.gz
 
+    Or if you have a `chroot` environment with extra packages installed,
+    such as the `/var/chroots/steamrt_scout_amd64` generated by
+    [`setup_chroot.sh`][], you can use that by making `files` a symbolic
+    link to it:
+
+        $ rm -fr ~/.steam/root/common/SteamLinuxRuntime/scout-chroot
+        $ mkdir -p ~/.steam/root/common/SteamLinuxRuntime/scout-chroot
+        $ ln -s /var/chroots/steamrt_scout_amd64 \
+            ~/.steam/root/common/SteamLinuxRuntime/scout-chroot/files
+
 * Launch a game once without pressure-vessel
 
 * Configure the launch options for the chosen game. Either use the Steam
@@ -278,8 +288,8 @@ Instructions for testing
     - Next to pressure-vessel's `bin` and `lib` directories
     - The directory above pressure-vessel's `bin` and `lib` directories
 
-    Runtimes intended for the test UI must have a `files` subdirectory
-    and a `metadata` file, like Flatpak runtimes.
+    Runtimes intended for the test UI must have a `files` subdirectory,
+    like Flatpak runtimes.
 
     You can also choose to use the host system `/usr` directly.
 
@@ -327,6 +337,8 @@ the host system or the runtime, whichever appears to be newer. This
 is currently hard-coded in `pressure-vessel-wrap` and cannot be
 configured.
 
+[`setup_chroot.sh`]: https://github.com/ValveSoftware/steam-runtime
+
 ### Debugging
 
 * To see the filesystem in which the game is executing, get the process ID
diff --git a/pressure-vessel-test-ui b/pressure-vessel-test-ui
index ce84eec46..cc638f19f 100755
--- a/pressure-vessel-test-ui
+++ b/pressure-vessel-test-ui
@@ -66,7 +66,7 @@ class Gui:
                 files = os.path.join(path, 'files')
                 metadata = os.path.join(path, 'metadata')
 
-                if os.path.isdir(files) and os.path.exists(metadata):
+                if os.path.isdir(files):
                     description = self._describe_runtime(path)
                     self.runtimes[path] = description
 
@@ -155,6 +155,9 @@ class Gui:
         files = os.path.join(path, 'files')
         metadata = os.path.join(path, 'metadata')
 
+        if os.path.islink(files):
+            description = os.path.realpath(files)
+
         if description.startswith(self.home + '/'):
             description = '~' + description[len(self.home):]
 
@@ -176,6 +179,8 @@ class Gui:
                 name = keyfile.get_string('Runtime', 'runtime')
             except GLib.Error:
                 pass
+            else:
+                variant = name.split('.')[-1]
         except GLib.Error:
             pass
 
-- 
GitLab