Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wine-GE: Match launcher naming schemes on extract #296

Merged
merged 6 commits into from
Nov 6, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions pupgui2/datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,11 @@ def get_game_config(self):

with open(game_config, 'r') as gcf:
return json.load(gcf).get(self.app_name, {})


class Launcher(Enum):
UNKNOWN = 0
STEAM = 1
LUTRIS = 2
BOTTLES = 3
HEROIC = 4
35 changes: 31 additions & 4 deletions pupgui2/resources/ctmods/ctmod_00winege.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

from PySide6.QtCore import QObject, QCoreApplication, Signal, Property

from pupgui2.util import ghapi_rlcheck, extract_tar
from pupgui2.datastructures import Launcher
from pupgui2.util import ghapi_rlcheck, extract_tar, get_launcher_from_installdir


CT_NAME = 'Wine-GE'
Expand Down Expand Up @@ -133,12 +134,14 @@ def get_tool(self, version, install_dir, temp_dir):
if not data or 'download' not in data:
return False

protondir = f'{install_dir}lutris-ge-' + data['version'].replace('GE-', '').lower() + '-x86_64'
checksum_dir = f'{protondir}/sha512sum'
ge_extract_basename = f"lutris-{data['version']}-x86_64"
ge_extract_fullpath = os.path.join(install_dir, ge_extract_basename)

checksum_dir = os.path.join(ge_extract_fullpath, 'sha512sum')
source_checksum = self.rs.get(data['checksum']).text if 'checksum' in data else None
local_checksum = open(checksum_dir).read() if os.path.exists(checksum_dir) else None

if os.path.exists(protondir):
if os.path.exists(ge_extract_fullpath):
if local_checksum and source_checksum:
if local_checksum in source_checksum:
return False
Expand All @@ -159,10 +162,34 @@ def get_tool(self, version, install_dir, temp_dir):
if os.path.exists(checksum_dir):
open(checksum_dir, 'w').write(download_checksum)

# Make sure extracted directory name matches name launcher expects (i.e. Lutris uses a custom name format)
ge_updated_dirname = os.path.join(install_dir, self.get_launcher_extract_dirname(ge_extract_basename, install_dir))
os.rename(ge_extract_fullpath, ge_updated_dirname)

self.__set_download_progress_percent(100)

return True

def get_launcher_extract_dirname(self, original_name: str, install_dir: str) -> str:

"""
Return base extract directory name updated to match naming scheme expected for given launcher.
Example: 'lutris-GE-Proton8-17-x86_64' -> 'wine-ge-8-17-x86_64'

Return Type: str
"""

launcher_name = ''
launcher = get_launcher_from_installdir(install_dir)
if launcher == Launcher.LUTRIS:
# Lutris expects this name format for self-updating, see #294 -- ex: wine-ge-8-17-x86_64
launcher_name = original_name.lower().replace('lutris', 'wine').replace('proton', '')
elif launcher == Launcher.HEROIC:
# This matches Heroic Wine-GE naming convention -- ex: Wine-GE-Proton8-17
launcher_name = original_name.replace('lutris', 'Wine').rsplit('-', 1)[0]

return launcher_name or original_name

def get_info_url(self, version):
"""
Get link with info about version (eg. GitHub release page)
Expand Down
8 changes: 5 additions & 3 deletions pupgui2/resources/ctmods/ctmod_d8vk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

from PySide6.QtCore import QObject, QCoreApplication, Signal, Property

from pupgui2.util import ghapi_rlcheck, extract_zip
from pupgui2.datastructures import Launcher
from pupgui2.util import ghapi_rlcheck, extract_zip, get_launcher_from_installdir


CT_NAME = 'D8VK (nightly)'
Expand Down Expand Up @@ -163,9 +164,10 @@ def get_extract_dir(self, install_dir: str) -> str:
Return Type: str
"""

if 'lutris/runners' in install_dir:
launcher = get_launcher_from_installdir(install_dir)
if launcher == Launcher.LUTRIS:
return os.path.abspath(os.path.join(install_dir, '../../runtime/dxvk'))
if 'heroic/tools' in install_dir:
if launcher == Launcher.HEROIC:
return os.path.abspath(os.path.join(install_dir, '../dxvk'))
else:
return install_dir # Default to install_dir
8 changes: 5 additions & 3 deletions pupgui2/resources/ctmods/ctmod_vkd3dproton.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

from PySide6.QtCore import QObject, QCoreApplication, Signal, Property

from pupgui2.util import ghapi_rlcheck, extract_tar, extract_tar_zst
from pupgui2.datastructures import Launcher
from pupgui2.util import ghapi_rlcheck, extract_tar, extract_tar_zst, get_launcher_from_installdir


CT_NAME = 'vkd3d-proton'
Expand Down Expand Up @@ -144,9 +145,10 @@ def get_extract_dir(self, install_dir: str) -> str:
Return Type: str
"""

if 'lutris/runners' in install_dir:
launcher = get_launcher_from_installdir(install_dir)
if launcher == Launcher.LUTRIS:
return os.path.abspath(os.path.join(install_dir, '../../runtime/vkd3d'))
if 'heroic/tools' in install_dir:
if launcher == Launcher.HEROIC:
return os.path.abspath(os.path.join(install_dir, '../vkd3d'))
else:
return install_dir # Default to install_dir
8 changes: 5 additions & 3 deletions pupgui2/resources/ctmods/ctmod_z0dxvk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

from PySide6.QtCore import QObject, QCoreApplication, Signal, Property

from pupgui2.util import ghapi_rlcheck, extract_tar
from pupgui2.datastructures import Launcher
from pupgui2.util import ghapi_rlcheck, extract_tar, get_launcher_from_installdir


CT_NAME = 'DXVK'
Expand Down Expand Up @@ -142,9 +143,10 @@ def get_extract_dir(self, install_dir: str) -> str:
Return Type: str
"""

if 'lutris/runners' in install_dir:
launcher = get_launcher_from_installdir(install_dir)
if launcher == Launcher.LUTRIS:
return os.path.abspath(os.path.join(install_dir, '../../runtime/dxvk'))
if 'heroic/tools' in install_dir:
if launcher == Launcher.HEROIC:
return os.path.abspath(os.path.join(install_dir, '../dxvk'))
else:
return install_dir # Default to install_dir
21 changes: 20 additions & 1 deletion pupgui2/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from pupgui2.constants import POSSIBLE_INSTALL_LOCATIONS, CONFIG_FILE, PALETTE_DARK, TEMP_DIR
from pupgui2.constants import AWACY_GAME_LIST_URL, LOCAL_AWACY_GAME_LIST
from pupgui2.datastructures import BasicCompatTool, CTType
from pupgui2.datastructures import BasicCompatTool, CTType, Launcher
from pupgui2.steamutil import remove_steamtinkerlaunch


Expand Down Expand Up @@ -654,3 +654,22 @@ def extract_tar_zst(zst_path: str, extract_path: str) -> bool:
print(f'Could not extract archive \'{zst_path}\': {e}')

return False


def get_launcher_from_installdir(install_dir: str) -> Launcher:

"""
Return the launcher type based on the install path given.
Return Type: Launcher (Enum)
"""

if 'steam/compatibilitytools.d' in install_dir.lower():
return Launcher.STEAM
elif 'lutris/runners' in install_dir.lower():
return Launcher.LUTRIS
elif 'heroic/tools' in install_dir.lower():
return Launcher.HEROIC
elif 'bottles/runners' in install_dir.lower():
return Launcher.BOTTLES
else:
return Launcher.UNKNOWN