Preserve value of LD_LIBRARY_PATH (Partially fixes #781)

This commit is contained in:
Mathieu Comandon 2018-03-05 20:52:26 -08:00
parent 8b52936a1c
commit 397424a9ba
3 changed files with 50 additions and 40 deletions

View file

@ -186,7 +186,7 @@ class Runner:
def use_runtime(self):
disable_runtime = self.system_config.get('disable_runtime')
disable_runtime_by_env = runtime.is_disabled()
disable_runtime_by_env = runtime.RUNTIME_DISABLED
if disable_runtime_by_env is True:
disable_runtime = disable_runtime_by_env
return not disable_runtime

View file

@ -113,7 +113,8 @@ def create_prefix(prefix, wine_path=None, arch='win32', overrides={},
wineboot_path = os.path.join(os.path.dirname(wine_path), 'wineboot')
if not system.path_exists(wineboot_path):
logger.error("No wineboot executable found in %s, your wine installation is most likely broken", wine_path)
logger.error("No wineboot executable found in %s, "
"your wine installation is most likely broken", wine_path)
return
if install_gecko is 'False':
@ -139,7 +140,7 @@ def create_prefix(prefix, wine_path=None, arch='win32', overrides={},
logger.info('%s Prefix created in %s', arch, prefix)
prefix_manager = WinePrefixManager(prefix)
prefix_manager.setup_defaults()
self.sandbox(prefix_manager)
def winekill(prefix, arch='win32', wine_path=None, env=None, initial_pids=None):
"""Kill processes in Wine prefix."""
@ -177,7 +178,8 @@ def winekill(prefix, arch='win32', wine_path=None, env=None, initial_pids=None):
if not running_processes:
break
if num_cycles > 20:
logger.warning("Some wine processes are still running: %s", ', '.join(running_processes))
logger.warning("Some wine processes are still running: %s",
', '.join(running_processes))
break
time.sleep(0.1)
@ -235,8 +237,11 @@ def wineexec(executable, args="", wine_path=None, prefix=None, arch=None,
wineenv['WINEPREFIX'] = prefix
wine_config = config or LutrisConfig(runner_slug='wine')
if (not wine_config.system_config['disable_runtime'] and
not runtime.is_disabled() and not disable_runtime):
if (
not runtime.RUNTIME_DISABLED and
not disable_runtime and
not wine_config.system_config['disable_runtime']
):
wineenv['LD_LIBRARY_PATH'] = ':'.join(runtime.get_paths())
if overrides:
@ -323,6 +328,7 @@ def detect_prefix_arch(directory=None):
return 'win32'
logger.debug("Can't detect prefix arch for %s", directory)
def set_drive_path(prefix, letter, path):
dosdevices_path = os.path.join(prefix, "dosdevices")
if not os.path.exists(dosdevices_path):
@ -553,7 +559,7 @@ class wine(Runner):
'label': 'x360ce dinput 8 mode',
'type': 'bool',
'default': False,
'help': "Configure x360ce with dinput8.dll, required for some games such as Darksiders 1"
'help': "Configure x360ce with dinput8.dll, required for some games"
},
{
'option': 'x360ce-xinput9',
@ -634,9 +640,13 @@ class wine(Runner):
('Disabled', 'disabled')],
'default': 'disabled',
'advanced': True,
'help': ("This option ensures any pending drawing operations are submitted to the driver, but at"
" a significant performance cost. Set to \"enabled\" to enable. This setting is deprecated"
" since wine-2.6 and will likely be removed after wine-3.0. Use \"csmt\" instead.""")
'help': (
"This option ensures any pending drawing operations are "
"submitted to the driver, but at a significant performance "
"cost. Set to \"enabled\" to enable. This setting is deprecated "
"since wine-2.6 and will likely be removed after wine-3.0. "
"Use \"csmt\" instead."
)
},
{
'option': 'UseGLSL',
@ -646,8 +656,11 @@ class wine(Runner):
('Disabled', 'disabled')],
'default': 'enabled',
'advanced': True,
'help': ("When set to \"disabled\", this disables the use of GLSL for shaders."
"In general disabling GLSL is not recommended, only use this for debugging purposes.")
'help': (
"When set to \"disabled\", this disables the use of GLSL for shaders. "
"In general disabling GLSL is not recommended, "
"only use this for debugging purposes."
)
},
{
'option': 'RenderTargetLockMode',

View file

@ -9,17 +9,7 @@ from lutris.util.extract import extract_archive
from lutris.util.log import logger
def is_disabled():
"""Checks if runtime is disabled from an environment variable.
Returns True if LUTRIS_RUNTIME is set to a negative value,
False if any other value and None if LUTRIS_RUNTIME is not set.
"""
env_runtime = os.getenv('LUTRIS_RUNTIME')
if env_runtime:
if env_runtime.lower() in ('0', 'off'):
return True
else:
return False
RUNTIME_DISABLED = os.environ.get('LUTRIS_RUNTIME', '').lower() in ('0', 'off')
class RuntimeUpdater:
@ -37,7 +27,7 @@ class RuntimeUpdater:
return time.gmtime(os.path.getctime(path))
def update(self, status_updater=None):
if is_disabled():
if RUNTIME_DISABLED:
logger.debug("Runtime disabled, not updating it.")
return []
@ -128,27 +118,28 @@ class RuntimeUpdater:
def get_env():
"""Return a dict containing LD_LIBRARY_PATH and STEAM_RUNTIME env vars."""
if is_disabled():
return {}
steam_runtime_dir = os.path.join(RUNTIME_DIR, 'steam')
ld_library_path = ':'.join(get_paths()) + ':$LD_LIBRARY_PATH'
return {
'STEAM_RUNTIME': steam_runtime_dir,
'LD_LIBRARY_PATH': ld_library_path
key: value for key, value in {
'STEAM_RUNTIME': os.path.join(RUNTIME_DIR, 'steam') if not RUNTIME_DISABLED else None,
'LD_LIBRARY_PATH': ':'.join(get_paths())
} if value
}
def get_paths():
"""Return a list of paths containing the runtime libraries."""
paths = [
"lib32",
"steam/i386/lib/i386-linux-gnu",
"steam/i386/lib",
"steam/i386/usr/lib/i386-linux-gnu",
"steam/i386/usr/lib"
]
if system.is_64bit:
paths = []
if not RUNTIME_DISABLED:
paths += [
"lib32",
"steam/i386/lib/i386-linux-gnu",
"steam/i386/lib",
"steam/i386/usr/lib/i386-linux-gnu",
"steam/i386/usr/lib"
]
if system.is_64bit and not RUNTIME_DISABLED:
paths += [
"lib64",
"steam/amd64/lib/x86_64-linux-gnu",
@ -156,4 +147,10 @@ def get_paths():
"steam/amd64/usr/lib/x86_64-linux-gnu",
"steam/amd64/usr/lib"
]
return [os.path.join(RUNTIME_DIR, path) for path in paths]
paths = [os.path.join(RUNTIME_DIR, path) for path in paths]
if os.environ.get('LD_LIBRARY_PATH'):
paths.append(os.environ['LD_LIBRARY_PATH'])
return paths