From f9d55eb947f20e650d11a8b4c00d856a17a33c65 Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Wed, 26 Feb 2020 16:48:51 +0000 Subject: [PATCH] runtime: Precompute the path to the runtime's /usr Signed-off-by: Simon McVittie <smcv@collabora.com> --- src/runtime.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/runtime.c b/src/runtime.c index 15d887c39..576c48eea 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -56,6 +56,7 @@ struct _PvRuntime gchar *overrides_bin; gchar *container_access; FlatpakBwrap *container_access_adverb; + gchar *runtime_usr; /* either source_files or that + "/usr" */ PvRuntimeFlags flags; gboolean any_libc_from_host; @@ -251,6 +252,15 @@ pv_runtime_initable_init (GInitable *initable, self->overrides_bin = g_build_filename (self->overrides, "bin", NULL); g_mkdir (self->overrides_bin, 0700); + self->runtime_usr = g_build_filename (self->source_files, "usr", NULL); + + if (!g_file_test (self->runtime_usr, G_FILE_TEST_IS_DIR)) + { + /* source_files is just a merged /usr. */ + g_free (self->runtime_usr); + self->runtime_usr = g_strdup (self->source_files); + } + return TRUE; } @@ -282,6 +292,7 @@ pv_runtime_finalize (GObject *object) pv_runtime_cleanup (self); g_free (self->bubblewrap); + g_free (self->runtime_usr); g_free (self->source_files); g_free (self->tools_dir); pv_bwrap_lock_free (self->runtime_lock); @@ -1581,11 +1592,7 @@ pv_runtime_use_host_graphics_stack (PvRuntime *self, best_libdrm_data_from_host = g_strdup (pv_hash_table_get_arbitrary_key (libdrm_data_from_host)); } - g_autofree gchar *runtime_usr = g_build_filename (self->source_files, "usr", NULL); - if (g_file_test (runtime_usr, G_FILE_TEST_IS_DIR)) - libdrm_data_in_runtime = g_build_filename (runtime_usr, "share", "libdrm", NULL); - else - libdrm_data_in_runtime = g_build_filename (self->source_files, "share", "libdrm", NULL); + libdrm_data_in_runtime = g_build_filename (self->runtime_usr, "share", "libdrm", NULL); if (best_libdrm_data_from_host != NULL && g_file_test (libdrm_data_in_runtime, G_FILE_TEST_IS_DIR)) -- GitLab