mirror of
https://github.com/lutris/lutris
synced 2024-10-04 14:59:37 +00:00
Add runtime and terminal option to installer's execute task
This commit is contained in:
parent
c0f63b1621
commit
55f87c3657
|
@ -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
|
||||
------------------------------------
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue