From 55f87c3657ce5209ddae1543678cb9b6a1bdff3d Mon Sep 17 00:00:00 2001 From: Xodetaetl Date: Mon, 4 May 2015 23:58:47 +0200 Subject: [PATCH] Add runtime and terminal option to installer's execute task --- docs/installers.rst | 8 ++++++-- lutris/installer.py | 11 +++++++++-- lutris/util/runtime.py | 10 ++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/docs/installers.rst b/docs/installers.rst index 6b0f801fd..124632e8b 100644 --- a/docs/installers.rst +++ b/docs/installers.rst @@ -202,8 +202,11 @@ Example: ``- chmodx: $GAMEDIR/game_binary`` Executing a file ---------------- -Execute files with the ``execute`` directive. Use the ``args`` parameter to add -command arguments, and ``file`` to reference a ``file id`` or a path. +Execute files with the ``execute`` directive. Use the ``file`` parameter to +reference a ``file id`` or a path, ``args`` to add command arguments, +``terminal`` (set to "true") to execute in a new terminal window. +The command is executed within the Lutris Runtime (resolving most shared +library dependencies). Example: @@ -212,6 +215,7 @@ Example: - execute: args: --argh file: $great-id + terminal: true Writing into an INI type config file ------------------------------------ diff --git a/lutris/installer.py b/lutris/installer.py index 821242553..7063c2aef 100644 --- a/lutris/installer.py +++ b/lutris/installer.py @@ -7,7 +7,6 @@ import shutil import urllib2 import platform import shlex -import subprocess import webbrowser from gi.repository import Gdk @@ -17,6 +16,7 @@ from lutris.util import extract, devices, system from lutris.util.fileio import EvilConfigParser, MultiOrderedDict from lutris.util.jobs import async_call from lutris.util.log import logger +from lutris.util.runtime import get_runtime_env from lutris.game import Game from lutris.config import LutrisConfig @@ -25,6 +25,7 @@ from lutris.gui.dialogs import ErrorDialog, NoInstallerDialog from lutris.runners import ( wine, winesteam, steam, import_task, import_runner, InvalidRunner ) +from lutris.thread import LutrisThread class ScriptingError(Exception): @@ -496,9 +497,15 @@ class ScriptInterpreter(object): raise ScriptingError("Unable to find required executable", exec_path) self.chmodx(exec_path) + + terminal = data.get('terminal') + if terminal: + terminal = system.get_default_terminal() + command = [exec_path] + args logger.debug("Executing %s" % command) - subprocess.call(command) + thread = LutrisThread(command, env=get_runtime_env(), term=terminal) + thread.run() def extract(self, data): """Extract a file, guessing the compression method.""" diff --git a/lutris/util/runtime.py b/lutris/util/runtime.py index 187c2f6bd..713298ce0 100644 --- a/lutris/util/runtime.py +++ b/lutris/util/runtime.py @@ -68,6 +68,16 @@ def update_runtime(set_status): logger.debug("Runtime updated") +def get_runtime_env(): + """Return a dict containing LD_LIBRARY_PATH and STEAM_RUNTIME env vars. + + Ready for use! (Batteries not included (but not necessary)) + """ + runtime_dir = os.path.join(settings.RUNTIME_DIR, 'steam') + ld_library_path = ':'.join(get_runtime_paths()) + ':$LD_LIBRARY_PATH' + return {'STEAM_RUNTIME': runtime_dir, 'LD_LIBRARY_PATH': ld_library_path} + + def get_runtime_paths(): """Return a list of paths containing the runtime libraries.""" runtime_dir = os.path.join(settings.RUNTIME_DIR, 'steam')