Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions games/tests/test_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,24 @@ def test_game_should_be_a_dict(self):
self.installer.content = json.dumps({"game": {"foo": "bar", "bar": "foo"}})
is_valid, _errors = validate_installer(self.installer)
self.assertTrue(is_valid)


class TestWineVersionValidator(TestCase):
def get_installer(self, version):
return Installer(
runner=Runner(name="Wine", slug="wine"),
version="test",
content=json.dumps({"wine": {"version": version}}),
)

def test_ge_proton_versions_are_valid(self):
"""GE-Proton builds come from GitHub, not from the Lutris API"""
for version in ("GE-Proton11-8", "GE-Proton9-26", "ge-proton"):
is_valid, errors = validate_installer(self.get_installer(version))
self.assertTrue(is_valid, (version, errors))

def test_unknown_wine_version_is_invalid(self):
for version in ("wine-unknown-1.0-x86_64", "GE-Proton11-8-x86_64", "GE-Proton"):
is_valid, errors = validate_installer(self.get_installer(version))
self.assertFalse(is_valid, version)
self.assertIn(f"Wine version {version} is not available from Lutris", errors)
11 changes: 10 additions & 1 deletion games/util/installer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Installer related utilities"""

import logging
import re

from common.util import load_yaml
from games.models import DEFAULT_INSTALLER
Expand All @@ -9,6 +10,11 @@
LOGGER = logging.getLogger(__name__)
SUCCESS = (True, "")

# The client resolves 'ge-proton' to the latest GE-Proton through umu, and downloads
# pinned GE-Proton release tags such as 'GE-Proton11-8' from GitHub, not from our API.
GE_PROTON_LATEST = "ge-proton"
GE_PROTON_TAG_RE = re.compile(r"^GE-Proton\d+-\d+$")


def get_installer_script(installer):
"""Return the installer script as a Python structure"""
Expand Down Expand Up @@ -232,7 +238,8 @@ def all_files_are_used(installer):


def uses_a_valid_wine_version(installer):
"""Checks if a referenced wine version is available from the API"""
"""Checks if a referenced wine version is available from the API, or is a
GE-Proton version that the client gets from GitHub"""

script = get_installer_script(installer)
wine_config = script.get("wine") or {}
Expand All @@ -241,6 +248,8 @@ def uses_a_valid_wine_version(installer):
script_version = wine_config.get("version")
if not script_version:
return SUCCESS
if script_version == GE_PROTON_LATEST or GE_PROTON_TAG_RE.match(str(script_version)):
return SUCCESS
versions = [
f"{v.version}-{v.architecture}" for v in RunnerVersion.objects.filter(runner__slug="wine")
]
Expand Down
Loading