diff --git a/pressure-vessel/runtime.c b/pressure-vessel/runtime.c index 8da0c03175b246dc89771ec70b128c4ba0631a3c..ffd59dbec1ce3af5ad9f4fdf29040a5c168864dd 100644 --- a/pressure-vessel/runtime.c +++ b/pressure-vessel/runtime.c @@ -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", diff --git a/pressure-vessel/runtime.h b/pressure-vessel/runtime.h index 958577e5c69c38e3bf0958883046d7ac084eaba7..6b3b91da926f63433f3f9b7e3fd40ef68c3ca20f 100644 --- a/pressure-vessel/runtime.h +++ b/pressure-vessel/runtime.h @@ -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; diff --git a/pressure-vessel/wrap.1.md b/pressure-vessel/wrap.1.md index b7521870738d2854b8d04b19433df37910e787b9..ed7e5181b6347e0f612c4ac84cf937c1a8c14ab8 100644 --- a/pressure-vessel/wrap.1.md +++ b/pressure-vessel/wrap.1.md @@ -183,6 +183,13 @@ pressure-vessel-wrap - run programs in a bubblewrap container same as in that previous run, resulting in the previous runtime being reused. +`--search-cwd`, `--no-search-cwd` +: If `--search-cwd` is specified, append the game install path to + LD_LIBRARY_PATH. This should be 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. + The default is `--no-search-cwd`. + `--share-home`, `--unshare-home` : If `--unshare-home` is specified, use the home directory given by `--home`, `--freedesktop-app-id`, `--steam-app-id` or their @@ -366,6 +373,10 @@ The following environment variables (among others) are read by `PRESSURE_VESSEL_RUNTIME_ID` (string matching `^[A-Za-z0-9_][-A-Za-z0-9_.]*$`) : Equivalent to `--runtime-id="$PRESSURE_VESSEL_RUNTIME_ID"`. +`PRESSURE_VESSEL_SEARCH_CWD` (boolean) +: If set to `1`, equivalent to `--search-cwd`. + If set to `0`, equivalent to `--no-search-cwd`. + `PRESSURE_VESSEL_SHARE_HOME` (boolean) : If set to `1`, equivalent to `--share-home`. If set to `0`, equivalent to `--unshare-home`. diff --git a/pressure-vessel/wrap.c b/pressure-vessel/wrap.c index 80865c7c9d0c6a6ff9bda5b6bd912a92785fac11..1f9a4ce356d619aa8ceaaed48ca9cbf0a1f879c5 100644 --- a/pressure-vessel/wrap.c +++ b/pressure-vessel/wrap.c @@ -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 */