Skip to content
Snippets Groups Projects
Commit 96ace65d authored by Simon McVittie's avatar Simon McVittie
Browse files

utils: Always look in helpers directory before PATH


Previously, we always looked for vulkaninfo and wflinfo in the PATH.
Now we look in the helpers directory, and only search the PATH if the
necessary executable isn't there.

This enables us to ship relative symlinks from the helpers directory
/usr/libexec/steam-runtime-tools-0 to an adjacent /usr/bin directory,
so that if the Steam Runtime is relocated to (for example)
.../steam-runtime, we will find vulkaninfo and wflinfo in
.../steam-runtime/usr/bin.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent cb41a76a
Branches
Tags
1 merge request!77Look for vulkaninfo, wflinfo in SRT_HELPERS_PATH
......@@ -265,21 +265,6 @@ _srt_get_helper (const char *helpers_path,
}
}
if ((flags & SRT_HELPER_FLAGS_SEARCH_PATH) != 0
&& helpers_path == NULL)
{
/* For helpers that are not part of steam-runtime-tools, such as
* *-wflinfo and *-vulkaninfo, we currently only search PATH,
* unless helpers_path has been overridden */
if (multiarch == NULL)
prefixed = g_strdup (base);
else
prefixed = g_strdup_printf ("%s-%s", multiarch, base);
g_ptr_array_add (argv, g_steal_pointer (&prefixed));
return argv;
}
if (helpers_path == NULL)
{
helpers_path = _srt_get_helpers_path (error);
......@@ -291,6 +276,9 @@ _srt_get_helper (const char *helpers_path,
}
}
/* Prefer a helper from ${SRT_HELPERS_PATH} or
* ${libexecdir}/steam-runtime-tools-${_SRT_API_MAJOR}
* if it exists */
path = g_strdup_printf ("%s/%s%s%s",
helpers_path,
multiarch == NULL ? "" : multiarch,
......@@ -304,7 +292,8 @@ _srt_get_helper (const char *helpers_path,
g_ptr_array_add (argv, g_steal_pointer (&path));
return argv;
}
else
if ((flags & SRT_HELPER_FLAGS_SEARCH_PATH) == 0)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"%s not found", path);
......@@ -312,6 +301,18 @@ _srt_get_helper (const char *helpers_path,
g_ptr_array_unref (argv);
return NULL;
}
/* For helpers that are not part of steam-runtime-tools, such as
* *-wflinfo and *-vulkaninfo, we fall back to searching $PATH */
g_free (path);
if (multiarch == NULL)
prefixed = g_strdup (base);
else
prefixed = g_strdup_printf ("%s-%s", multiarch, base);
g_ptr_array_add (argv, g_steal_pointer (&prefixed));
return argv;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment