Skip to content
Snippets Groups Projects
Commit f8211395 authored by Ludovico de Nittis's avatar Ludovico de Nittis :palm_tree:
Browse files

pressure-vessel: Add support for the STEAM_COMPAT_FLAGS=search-cwd


Add a launch option in `runtime` to correctly handle the "search-cwd"
flag in `STEAM_COMPAT_FLAGS`.

The game "current working directory" is expected to be
`STEAM_COMPAT_INSTALL_PATH`.

Fixes: #46

Signed-off-by: default avatarLudovico de Nittis <ludovico.denittis@collabora.com>
parent 22e43459
No related branches found
No related tags found
No related merge requests found
Pipeline #9659 passed
......@@ -4665,6 +4665,17 @@ pv_runtime_set_search_paths (PvRuntime *self,
pv_search_path_append (ld_library_path, ld_path);
}
if (self->flags & PV_RUNTIME_FLAGS_SEARCH_CWD)
{
const gchar *install_path = g_environ_getenv (self->original_environ,
"STEAM_COMPAT_INSTALL_PATH");
if (install_path != NULL)
pv_search_path_append (ld_library_path, install_path);
else
g_debug ("The environment variable \"STEAM_COMPAT_INSTALL_PATH\" is not set, "
"we can't append the game install path to LD_LIBRARY_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",
......
......@@ -42,6 +42,7 @@
* @PV_RUNTIME_FLAGS_UNPACK_ARCHIVE: Source is an archive, not a deployment
* @PV_RUNTIME_FLAGS_FLATPAK_SUBSANDBOX: The runtime will be used in a
* Flatpak subsandbox
* @PV_RUNTIME_FLAGS_SEARCH_CWD: Append the game install path to LD_LIBRARY_PATH
* @PV_RUNTIME_FLAGS_NONE: None of the above
*
* Flags affecting how we set up the runtime.
......@@ -56,6 +57,7 @@ typedef enum
PV_RUNTIME_FLAGS_COPY_RUNTIME = (1 << 5),
PV_RUNTIME_FLAGS_UNPACK_ARCHIVE = (1 << 6),
PV_RUNTIME_FLAGS_FLATPAK_SUBSANDBOX = (1 << 7),
PV_RUNTIME_FLAGS_SEARCH_CWD = (1 << 8),
PV_RUNTIME_FLAGS_NONE = 0
} PvRuntimeFlags;
......@@ -68,6 +70,7 @@ typedef enum
| PV_RUNTIME_FLAGS_COPY_RUNTIME \
| PV_RUNTIME_FLAGS_UNPACK_ARCHIVE \
| PV_RUNTIME_FLAGS_FLATPAK_SUBSANDBOX \
| PV_RUNTIME_FLAGS_SEARCH_CWD \
)
typedef struct _PvRuntime PvRuntime;
......
......@@ -677,6 +677,7 @@ static char *opt_runtime = NULL;
static char *opt_runtime_archive = NULL;
static char *opt_runtime_base = NULL;
static char *opt_runtime_id = NULL;
static gboolean opt_search_cwd = FALSE;
static Tristate opt_share_home = TRISTATE_MAYBE;
static gboolean opt_share_pid = TRUE;
static double opt_terminate_idle_timeout = 0.0;
......@@ -1140,6 +1141,20 @@ static GOptionEntry options[] =
G_OPTION_FLAG_NONE, G_OPTION_ARG_FILENAME, &opt_runtime_id,
"Reuse a previously-unpacked --runtime-archive if its ID matched this",
"ID" },
{ "search-cwd", '\0',
G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_search_cwd,
"Append the game install path to LD_LIBRARY_PATH. This option is used for "
"legacy purposes to cope with games that relied on LD_LIBRARY_PATH ending "
"with a colon, which ld.so interprets as the current working directory."
"But because it was a bug, rather than a feature, it has been removed, "
"breaking, as a result, a few games."
"[Default if $PRESSURE_VESSEL_SEARCH_CWD is 1]", NULL },
{ "no-search-cwd", '\0',
G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_search_cwd,
"Do not append the game install path to LD_LIBRARY_PATH."
"This option should always be used unless a game specifically relied "
"on the old behaviour of having the game directory in the LD_LIBRARY_PATH."
"[Default, unless $PRESSURE_VESSEL_SEARCH_CWD is 1]", NULL },
{ "share-home", '\0',
G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, opt_share_home_cb,
"Use the real home directory. "
......@@ -1362,6 +1377,7 @@ main (int argc,
opt_import_vulkan_layers = pv_boolean_environment ("PRESSURE_VESSEL_IMPORT_VULKAN_LAYERS",
TRUE);
opt_search_cwd = pv_boolean_environment ("PRESSURE_VESSEL_SEARCH_CWD", FALSE);
opt_share_home = tristate_environment ("PRESSURE_VESSEL_SHARE_HOME");
opt_gc_legacy_runtimes = pv_boolean_environment ("PRESSURE_VESSEL_GC_LEGACY_RUNTIMES", FALSE);
opt_gc_runtimes = pv_boolean_environment ("PRESSURE_VESSEL_GC_RUNTIMES", TRUE);
......@@ -1908,6 +1924,9 @@ main (int argc,
if (flatpak_subsandbox != NULL)
flags |= PV_RUNTIME_FLAGS_FLATPAK_SUBSANDBOX;
if (opt_search_cwd)
flags |= PV_RUNTIME_FLAGS_SEARCH_CWD;
if (opt_runtime != NULL)
{
/* already checked for mutually exclusive options */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment