From 4c691886fea7a44d87900c0a251e2502771a303c Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Fri, 4 Dec 2020 13:52:53 +0000
Subject: [PATCH] pressure-vessel: Include vulkaninfo and wflinfo in
 relocatable installs

Otherwise we can't produce full system diagnostics from the included
copy of steam-runtime-system-info.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 debian/control                               |  6 +++
 pressure-vessel/THIRD-PARTY.md               |  5 +++
 pressure-vessel/build-relocatable-install.py | 40 ++++++++++++++++++++
 3 files changed, 51 insertions(+)

diff --git a/debian/control b/debian/control
index b302c4437..94ed4294b 100644
--- a/debian/control
+++ b/debian/control
@@ -159,6 +159,9 @@ Multi-Arch: foreign
 Depends:
  libcapsule-tools-relocatable (>= 0.20201120.0),
  libsteam-runtime-tools-0-helpers,
+ vainfo-multiarch,
+ vulkan-tools-multiarch,
+ waffle-utils-multiarch,
  ${misc:Depends},
  ${shlibs:Depends},
 Description: Steam container launcher - cross-architecture dependencies
@@ -173,6 +176,9 @@ Multi-Arch: foreign
 Depends:
  libcapsule-tools-relocatable (>= 0.20201120.0),
  libsteam-runtime-tools-0-helpers,
+ vainfo-multiarch,
+ vulkan-tools-multiarch,
+ waffle-utils-multiarch,
  ${misc:Depends},
  ${shlibs:Depends},
 Description: Steam container launcher - cross-architecture dependencies
diff --git a/pressure-vessel/THIRD-PARTY.md b/pressure-vessel/THIRD-PARTY.md
index 27539525e..f0bcc1625 100644
--- a/pressure-vessel/THIRD-PARTY.md
+++ b/pressure-vessel/THIRD-PARTY.md
@@ -58,11 +58,16 @@ programs and libraries:
 - libjson-glib-1.0.so.0 from json-glib: [LGPL-2.0-or-later][]. See
   json-glib.txt.
 
+- vulkaninfo from Vulkan-Tools: [Apache-2.0][]. See vulkan-tools.txt.
+
+- wflinfo from waffle: [BSD-2-clause][]. See waffle.txt.
+
 Complete source code can be obtained from the same place as
 pressure-vessel, or from <https://repo.steampowered.com/steamrt/>
 and <https://repo.steampowered.com/steamrt-images-scout/snapshots/>
 
 [Apache-2.0]: https://spdx.org/licenses/Apache-2.0.html
+[BSD-2-Clause]: https://spdx.org/licenses/BSD-2-Clause.html
 [BSD-3-Clause]: https://spdx.org/licenses/BSD-3-Clause.html
 [GPL-2.0-only]: https://spdx.org/licenses/GPL-2.0-only.html
 [GPL-2.0-or-later]: https://spdx.org/licenses/GPL-2.0-or-later.html
diff --git a/pressure-vessel/build-relocatable-install.py b/pressure-vessel/build-relocatable-install.py
index 43ff05f34..c51e62c71 100755
--- a/pressure-vessel/build-relocatable-install.py
+++ b/pressure-vessel/build-relocatable-install.py
@@ -79,6 +79,8 @@ ARCHS = [
 DEPENDENCIES = {
     'libcapsule-tools-relocatable': 'libcapsule',
     'libelf1': 'elfutils',
+    'vulkan-tools-multiarch': 'vulkan-tools',
+    'waffle-utils-multiarch': 'waffle',
     'zlib1g': 'zlib',
 }
 # program to install => binary package
@@ -97,6 +99,10 @@ PRIMARY_ARCH_DEPENDENCIES = {
     'libselinux1': 'libselinux',
     'libxau6': 'libxau',
 }
+HELPERS = {
+    'vulkaninfo': 'vulkan-tools-multiarch',
+    'wflinfo': 'waffle-utils-multiarch',
+}
 SCRIPTS = [
     'pressure-vessel-locale-gen',
     'pressure-vessel-test-ui',
@@ -437,6 +443,40 @@ def main():
                     )
                 )
 
+            for helper, package in HELPERS.items():
+                exe = arch.multiarch + '-' + helper
+                path = os.path.join(args.prefix, 'bin', exe)
+
+                if not os.path.exists(path):
+                    path = '/usr/bin/{}'.format(exe)
+
+                if not os.path.exists(path):
+                    v_check_call([
+                        'apt-get',
+                        'download',
+                        package,
+                    ], cwd=tmpdir)
+                    v_check_call(
+                        'dpkg-deb -x {}_*.deb build-relocatable'.format(
+                            quote(package),
+                        ),
+                        cwd=tmpdir,
+                        shell=True,
+                    )
+                    path = '{}/build-relocatable/usr/bin/{}'.format(
+                        tmpdir, exe,
+                    )
+
+                install_exe(
+                    path,
+                    os.path.join(
+                        installation,
+                        'libexec',
+                        'steam-runtime-tools-0',
+                        exe,
+                    )
+                )
+
         # For bwrap (and possibly other programs in future) we don't have
         # a relocatable version with a RPATH/RUNPATH, so we wrap a script
         # around it instead. The script avoids setting LD_LIBRARY_PATH
-- 
GitLab