1
0
mirror of https://github.com/lutris/lutris synced 2024-07-05 16:38:42 +00:00

Supply a missing architecture for a wine version taken from an install script.

Resolves #5362
This commit is contained in:
Daniel Johnson 2024-03-26 16:49:39 -04:00
parent e513e442a6
commit eb96626451
2 changed files with 23 additions and 9 deletions

View File

@ -195,17 +195,30 @@ def download_runner_versions(runner_name: str) -> list:
def format_runner_version(version_info: Dict[str, str]) -> str:
version = version_info.get("version")
if not version:
return ""
version = version_info.get("version") or ""
arch = version_info.get("architecture")
return format_version_architecture(version, arch)
def normalize_version_architecture(version_name: str) -> str:
"""Ensures the version name has an architecture on the end ofit;
adds the system's architecture if it is missing."""
base_version, arch = parse_version_architecture(version_name)
return format_version_architecture(base_version, arch) if base_version else ""
def format_version_architecture(base_version: str, arch: Optional[str] = None) -> str:
"""Assembles a version with architecture from the version and architecture."""
if not base_version:
return ""
if arch:
return "{}-{}".format(version, arch)
return "{}-{}".format(base_version, arch)
return version
return base_version
def parse_version_architecture(version_name: Optional[str]) -> Tuple[Optional[str], str]:
def parse_version_architecture(version_name: str) -> Tuple[str, str]:
"""Splits a version that ends with an architecture into the plain version and
architecture, as a tuple. If the version has no architecture, this provides
the system's architecture instead."""
@ -216,7 +229,7 @@ def parse_version_architecture(version_name: Optional[str]) -> Tuple[Optional[st
return version_name, LINUX_SYSTEM.arch
def get_default_runner_version_info(runner_name: str, version: str = None) -> Dict[str, str]:
def get_default_runner_version_info(runner_name: str, version: Optional[str] = None) -> Dict[str, str]:
"""Get the appropriate version for a runner
Params:
@ -228,7 +241,7 @@ def get_default_runner_version_info(runner_name: str, version: str = None) -> Di
a dict containing only the version itself.
"""
version, arch = parse_version_architecture(version)
version, arch = parse_version_architecture(version or "")
def get_from_cache():
# Prefer to provide the info from our local cache if we can; if this can't find

View File

@ -6,7 +6,7 @@ from gettext import gettext as _
from typing import Dict, Optional, Tuple
from lutris import runtime, settings
from lutris.api import format_runner_version
from lutris.api import format_runner_version, normalize_version_architecture
from lutris.config import LutrisConfig
from lutris.database.games import get_game_by_field
from lutris.exceptions import (
@ -789,6 +789,7 @@ class wine(Runner):
version = None
if installer.script.get(installer.runner):
version = installer.script[installer.runner].get("version")
version = normalize_version_architecture(version)
# If the installer is an extension, use the wine version from the base game
elif installer.requires:
db_game = get_game_by_field(installer.requires, field="installer_slug")