Skip to content

Commit

Permalink
Add per-arch lib detection
Browse files Browse the repository at this point in the history
  • Loading branch information
strycore committed Aug 26, 2020
1 parent 9a4f66f commit 5069f0f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lutris/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ class GameConfigError(LutrisError):

class UnavailableLibraries(RuntimeError):

def __init__(self, libraries):
def __init__(self, libraries, arch=None):
message = _(
"Some required libraries are not installed on your system, install them "
"with your package manager and restart Lutris. Libraries: %s"
) % ", ".join(libraries)
"The following %s libraries are required but are not installed on your system:\n%s"
) % (
arch if arch else "",
", ".join(libraries)
)
super().__init__(message)
self.libraries = libraries

Expand Down
1 change: 1 addition & 0 deletions lutris/runners/pcsx2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class pcsx2(Runner):
platforms = [_("Sony PlayStation 2")]
runnable_alone = True
runner_executable = "pcsx2/PCSX2"
arch = "i386"
require_libs = ["libOpenGL.so.0", "libgdk-x11-2.0.so.0", "libEGL.so.1"]
game_options = [{
"option": "main_file",
Expand Down
12 changes: 8 additions & 4 deletions lutris/runners/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class Runner: # pylint: disable=too-many-public-methods
depends_on = None
runner_executable = None
entry_point_option = "main_file"
arch = None # If the runner is only available for an architecture that isn't x86_64

def __init__(self, config=None):
"""Initialize runner."""
self.arch = system.LINUX_SYSTEM.arch # What the hell is this needed for?!
self.config = config
if config:
self.game_data = pga.get_game_by_field(self.config.game_config_id, "configpath")
Expand Down Expand Up @@ -238,10 +238,14 @@ def prelaunch(self):
available_libs = set()
for lib in set(self.require_libs):
if lib in LINUX_SYSTEM.shared_libraries:
available_libs.add(lib)
if self.arch:
if self.arch in [l.arch for l in LINUX_SYSTEM.shared_libraries[lib]]:
available_libs.add(lib)
else:
available_libs.add(lib)
unavailable_libs = set(self.require_libs) - available_libs
if unavailable_libs:
raise UnavailableLibraries(unavailable_libs)
raise UnavailableLibraries(unavailable_libs, self.arch)
return True

def get_run_data(self):
Expand Down Expand Up @@ -330,7 +334,7 @@ def get_runner_version(self, version=None):
return

versions = runner_info.get("versions") or []
arch = self.arch
arch = system.LINUX_SYSTEM.arch
if version:
if version.endswith("-i386") or version.endswith("-x86_64"):
version, arch = version.rsplit("-", 1)
Expand Down

0 comments on commit 5069f0f

Please sign in to comment.