From b3fe64c577aa2fa5804d68419aa97a56ec89d744 Mon Sep 17 00:00:00 2001
From: Ludovico de Nittis <ludovico.denittis@collabora.com>
Date: Mon, 26 Oct 2020 15:57:39 +0100
Subject: [PATCH] runtime: Set LD_LIBRARY_PATH before using
 capsule-capture-libs

At this stage we expect to have `LD_LIBRARY_PATH` set to the
`SYSTEM_LD_LIBRARY_PATH` of `steam.sh`.

This means that we should treat the `LD_LIBRARY_PATH` entries as
OS-level search path too.

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
---
 pressure-vessel/runtime.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/pressure-vessel/runtime.c b/pressure-vessel/runtime.c
index f294fb5e8..60c50b15e 100644
--- a/pressure-vessel/runtime.c
+++ b/pressure-vessel/runtime.c
@@ -1183,8 +1183,15 @@ static FlatpakBwrap *
 pv_runtime_get_capsule_capture_libs (PvRuntime *self,
                                      RuntimeArchitecture *arch)
 {
+  const gchar *ld_library_path;
   FlatpakBwrap *ret = pv_bwrap_copy (self->container_access_adverb);
 
+  /* If we have a custom "LD_LIBRARY_PATH", we want to preserve
+   * it when calling capsule-capture-libs */
+  ld_library_path = g_environ_getenv (self->original_environ, "LD_LIBRARY_PATH");
+  if (ld_library_path != NULL)
+    flatpak_bwrap_set_env (ret, "LD_LIBRARY_PATH", ld_library_path, TRUE);
+
   flatpak_bwrap_add_args (ret,
                           arch->capsule_capture_libs,
                           "--container", self->container_access,
-- 
GitLab