From 93743c0a36a27554c33bb37046d72909a25ee837 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Tue, 23 Feb 2021 19:57:06 +0000
Subject: [PATCH] runtime: Make sure Debian-based runtimes will look in
 /lib/terminfo

If we are using a non-Debian-based runtime's terminfo, in particular
if we're in Flatpak, then it won't normally search /lib/terminfo.
This is problematic for PRESSURE_VESSEL_SHELL, because ncurses-base
puts the xterm-256color terminfo in /lib/terminfo.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 pressure-vessel/runtime.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/pressure-vessel/runtime.c b/pressure-vessel/runtime.c
index bf31554ed..449214f6a 100644
--- a/pressure-vessel/runtime.c
+++ b/pressure-vessel/runtime.c
@@ -4584,6 +4584,7 @@ pv_runtime_set_search_paths (PvRuntime *self,
                              PvEnviron *container_env)
 {
   g_autoptr(GString) ld_library_path = g_string_new ("");
+  g_autofree char *terminfo_path = NULL;
   gsize i;
 
   /* TODO: Adapt the use_ld_so_cache code from Flatpak instead
@@ -4602,6 +4603,14 @@ pv_runtime_set_search_paths (PvRuntime *self,
       pv_search_path_append (ld_library_path, ld_path);
     }
 
+  /* If the runtime is Debian-based, make sure we search where ncurses-base
+   * puts terminfo, even if we're using a non-Debian-based libtinfo.so.6. */
+  terminfo_path = g_build_filename (self->source_files, "lib", "terminfo",
+                                    NULL);
+
+  if (g_file_test (terminfo_path, G_FILE_TEST_IS_DIR))
+    pv_environ_lock_env (container_env, "TERMINFO_DIRS", "/lib/terminfo");
+
   /* The PATH from outside the container doesn't really make sense inside the
    * container: in principle the layout could be totally different. */
   pv_environ_lock_env (container_env, "PATH", "/usr/bin:/bin");
-- 
GitLab