From 941bd627753d5d2decff21d2d6407548fd6a963e Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Tue, 29 Sep 2020 15:02:16 +0100 Subject: [PATCH] graphics: Canonicalize relative filenames before prepending sysroot Otherwise we'll treat them as relative to `/` instead of the current working directory, which breaks some of the tests when we move to always using a non-NULL sysroot (that is sometimes `/`). Signed-off-by: Simon McVittie <smcv@collabora.com> --- steam-runtime-tools/graphics.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/steam-runtime-tools/graphics.c b/steam-runtime-tools/graphics.c index 861c3a696..24d1a5485 100644 --- a/steam-runtime-tools/graphics.c +++ b/steam-runtime-tools/graphics.c @@ -1761,6 +1761,7 @@ load_json_dir (const char *sysroot, { g_autoptr(GError) error = NULL; g_autoptr(GDir) dir_iter = NULL; + g_autofree gchar *canon = NULL; g_autofree gchar *sysrooted_dir = NULL; g_autofree gchar *suffixed_dir = NULL; const char *iter_dir; @@ -1773,6 +1774,12 @@ load_json_dir (const char *sysroot, if (dir == NULL) return; + if (!g_path_is_absolute (dir)) + { + canon = g_canonicalize_filename (dir, NULL); + dir = canon; + } + if (suffix != NULL) { suffixed_dir = g_build_filename (dir, suffix, NULL); @@ -2336,11 +2343,18 @@ egl_icd_load_json (const char *sysroot, GList **list) { g_autoptr(GError) error = NULL; + g_autofree gchar *canon = NULL; g_autofree gchar *in_sysroot = NULL; g_autofree gchar *library_path = NULL; g_return_if_fail (list != NULL); + if (!g_path_is_absolute (filename)) + { + canon = g_canonicalize_filename (filename, NULL); + filename = canon; + } + if (sysroot != NULL) in_sysroot = g_build_filename (sysroot, filename, NULL); @@ -4761,12 +4775,19 @@ vulkan_icd_load_json (const char *sysroot, GList **list) { g_autoptr(GError) error = NULL; + g_autofree gchar *canon = NULL; g_autofree gchar *in_sysroot = NULL; g_autofree gchar *api_version = NULL; g_autofree gchar *library_path = NULL; g_return_if_fail (list != NULL); + if (!g_path_is_absolute (filename)) + { + canon = g_canonicalize_filename (filename, NULL); + filename = canon; + } + if (sysroot != NULL) in_sysroot = g_build_filename (sysroot, filename, NULL); -- GitLab