Keep track of when prefix setup tasks need to be re-done.

This commit is contained in:
Esme Povirk 2020-07-16 22:38:24 -05:00 committed by Andrew Eikum
parent 0e34540c66
commit debb619d17

72
proton
View File

@ -69,6 +69,13 @@ def try_copy(src, dst):
else: else:
raise raise
def getmtimestr(*path_fragments):
path = os.path.join(*path_fragments)
try:
return str(os.path.getmtime(path))
except IOError:
return "0"
EXT2_IOC_GETFLAGS = 0x80086601 EXT2_IOC_GETFLAGS = 0x80086601
EXT2_IOC_SETFLAGS = 0x40086602 EXT2_IOC_SETFLAGS = 0x40086602
@ -148,6 +155,7 @@ class CompatData:
self.base_dir = compatdata + "/" self.base_dir = compatdata + "/"
self.prefix_dir = self.path("pfx/") self.prefix_dir = self.path("pfx/")
self.version_file = self.path("version") self.version_file = self.path("version")
self.config_info_file = self.path("config_info")
self.tracked_files_file = self.path("tracked_files") self.tracked_files_file = self.path("tracked_files")
self.prefix_lock = FileLock(self.path("pfx.lock"), timeout=-1) self.prefix_lock = FileLock(self.path("pfx.lock"), timeout=-1)
@ -249,8 +257,6 @@ class CompatData:
log("Unable to write new registry file to " + self.prefix_dir + "system.reg") log("Unable to write new registry file to " + self.prefix_dir + "system.reg")
pass pass
self.update_builtin_libs()
except ValueError: except ValueError:
log("Prefix has an invalid version?! You may want to back up user files and delete this prefix.") log("Prefix has an invalid version?! You may want to back up user files and delete this prefix.")
#Just let the Wine upgrade happen and hope it works... #Just let the Wine upgrade happen and hope it works...
@ -346,9 +352,11 @@ class CompatData:
with self.prefix_lock: with self.prefix_lock:
if os.path.exists(self.version_file): if os.path.exists(self.version_file):
with open(self.version_file, "r") as f: with open(self.version_file, "r") as f:
self.upgrade_pfx(f.readline().strip()) old_ver = f.readline().strip()
else: else:
self.upgrade_pfx(None) old_ver = None
self.upgrade_pfx(old_ver)
if not os.path.exists(self.prefix_dir): if not os.path.exists(self.prefix_dir):
makedirs(self.prefix_dir + "/drive_c") makedirs(self.prefix_dir + "/drive_c")
@ -357,19 +365,57 @@ class CompatData:
if not os.path.exists(self.prefix_dir + "/user.reg"): if not os.path.exists(self.prefix_dir + "/user.reg"):
self.copy_pfx() self.copy_pfx()
with open(self.version_file, "w") as f: # collect configuration info
f.write(CURRENT_PREFIX_VERSION + "\n")
#create font files symlinks
self.create_fonts_symlinks()
#copy steam files into place
if "STEAM_COMPAT_CLIENT_INSTALL_PATH" in os.environ: if "STEAM_COMPAT_CLIENT_INSTALL_PATH" in os.environ:
#modern steam client sets this #modern steam client sets this
steamdir = os.environ["STEAM_COMPAT_CLIENT_INSTALL_PATH"] steamdir = os.environ["STEAM_COMPAT_CLIENT_INSTALL_PATH"]
else: else:
#linux-only fallback, really shouldn't get here #linux-only fallback, really shouldn't get here
steamdir = os.environ["HOME"] + ".steam/root/" steamdir = os.environ["HOME"] + ".steam/root/"
use_wined3d = "wined3d" in g_session.compat_config
use_dxvk_dxgi = "WINEDLLOVERRIDES" in os.environ and "dxgi=n" in os.environ["WINEDLLOVERRIDES"]
# If any of this info changes, we must rerun the tasks below
prefix_info = '\n'.join((
CURRENT_PREFIX_VERSION,
g_proton.fonts_dir,
g_proton.lib_dir,
g_proton.lib64_dir,
steamdir,
getmtimestr(steamdir, 'legacycompat', 'steamclient.dll'),
getmtimestr(steamdir, 'legacycompat', 'steamclient64.dll'),
getmtimestr(steamdir, 'legacycompat', 'Steam.dll'),
g_proton.default_pfx_dir,
getmtimestr(g_proton.default_pfx_dir, 'system.reg'),
str(use_wined3d),
str(use_dxvk_dxgi),
))
if old_ver == CURRENT_PREFIX_VERSION:
# check whether any prefix config has changed
try:
with open(self.config_info_file, "r") as f:
old_prefix_info = f.read()
except IOError:
old_prefix_info = ""
if old_prefix_info == prefix_info:
return
with open(self.config_info_file, "w") as f:
f.write(prefix_info)
with open(self.version_file, "w") as f:
f.write(CURRENT_PREFIX_VERSION + "\n")
#create font files symlinks
self.create_fonts_symlinks()
# update builtin dll symlinks or copies
self.update_builtin_libs()
#copy steam files into place
dst = self.prefix_dir + "/drive_c/Program Files (x86)/" dst = self.prefix_dir + "/drive_c/Program Files (x86)/"
makedirs(dst + "Steam") makedirs(dst + "Steam")
filestocopy = ["steamclient.dll", filestocopy = ["steamclient.dll",
@ -391,7 +437,7 @@ class CompatData:
try_copy(g_proton.lib_dir + "wine/dxvk/openvr_api_dxvk.dll", self.prefix_dir + "/drive_c/windows/syswow64/") try_copy(g_proton.lib_dir + "wine/dxvk/openvr_api_dxvk.dll", self.prefix_dir + "/drive_c/windows/syswow64/")
try_copy(g_proton.lib64_dir + "wine/dxvk/openvr_api_dxvk.dll", self.prefix_dir + "/drive_c/windows/system32/") try_copy(g_proton.lib64_dir + "wine/dxvk/openvr_api_dxvk.dll", self.prefix_dir + "/drive_c/windows/system32/")
if "wined3d" in g_session.compat_config: if use_wined3d:
dxvkfiles = ["dxvk_config"] dxvkfiles = ["dxvk_config"]
wined3dfiles = ["d3d11", "d3d10", "d3d10core", "d3d10_1", "d3d9"] wined3dfiles = ["d3d11", "d3d10", "d3d10core", "d3d10_1", "d3d9"]
else: else:
@ -399,7 +445,7 @@ class CompatData:
wined3dfiles = [] wined3dfiles = []
#if the user asked for dxvk's dxgi (dxgi=n), then copy it into place #if the user asked for dxvk's dxgi (dxgi=n), then copy it into place
if "WINEDLLOVERRIDES" in os.environ and "dxgi=n" in os.environ["WINEDLLOVERRIDES"]: if use_dxvk_dxgi:
dxvkfiles.append("dxgi") dxvkfiles.append("dxgi")
else: else:
wined3dfiles.append("dxgi") wined3dfiles.append("dxgi")