mirror of
https://github.com/ValveSoftware/Proton.git
synced 2025-01-14 23:58:17 +03:00
proton: Swap global CompatData references for instance
This commit is contained in:
parent
48c774d868
commit
975875265c
85
proton
85
proton
@ -145,15 +145,15 @@ class CompatData:
|
|||||||
def path(self, d):
|
def path(self, d):
|
||||||
return self.base_dir + d
|
return self.base_dir + d
|
||||||
|
|
||||||
def remove_tracked_files(self, prefix):
|
def remove_tracked_files(self):
|
||||||
if not os.path.exists(prefix + "/tracked_files"):
|
if not os.path.exists(self.tracked_files_file):
|
||||||
log("Prefix has no tracked_files??")
|
log("Prefix has no tracked_files??")
|
||||||
return
|
return
|
||||||
|
|
||||||
with open(prefix + "/tracked_files", "r") as tracked_files:
|
with open(self.tracked_files_file, "r") as tracked_files:
|
||||||
dirs = []
|
dirs = []
|
||||||
for f in tracked_files:
|
for f in tracked_files:
|
||||||
path = prefix + "/pfx/" + f.strip()
|
path = self.prefix_dir + f.strip()
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
if os.path.isfile(path) or os.path.islink(path):
|
if os.path.isfile(path) or os.path.islink(path):
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
@ -166,14 +166,14 @@ class CompatData:
|
|||||||
#not empty
|
#not empty
|
||||||
pass
|
pass
|
||||||
|
|
||||||
os.remove(prefix + "/tracked_files")
|
os.remove(self.tracked_files_file)
|
||||||
os.remove(prefix + "/version")
|
os.remove(self.version_file)
|
||||||
|
|
||||||
def upgrade_pfx(self, old_ver):
|
def upgrade_pfx(self, old_ver):
|
||||||
if old_ver == CURRENT_PREFIX_VERSION:
|
if old_ver == CURRENT_PREFIX_VERSION:
|
||||||
return
|
return
|
||||||
|
|
||||||
log("Upgrading prefix from " + str(old_ver) + " to " + CURRENT_PREFIX_VERSION + " (" + g_compatdata.base_dir + ")")
|
log("Upgrading prefix from " + str(old_ver) + " to " + CURRENT_PREFIX_VERSION + " (" + self.base_dir + ")")
|
||||||
|
|
||||||
if old_ver is None:
|
if old_ver is None:
|
||||||
return
|
return
|
||||||
@ -194,37 +194,38 @@ class CompatData:
|
|||||||
(int(new_proton_maj) == int(old_proton_maj) and \
|
(int(new_proton_maj) == int(old_proton_maj) and \
|
||||||
int(new_proton_min) < int(old_proton_min)):
|
int(new_proton_min) < int(old_proton_min)):
|
||||||
log("Removing newer prefix")
|
log("Removing newer prefix")
|
||||||
if old_proton_ver == "3.7" and not os.path.exists(g_compatdata.tracked_files_file):
|
if old_proton_ver == "3.7" and not os.path.exists(self.tracked_files_file):
|
||||||
#proton 3.7 did not generate tracked_files, so copy it into place first
|
#proton 3.7 did not generate tracked_files, so copy it into place first
|
||||||
try_copy(g_proton.path("proton_3.7_tracked_files"), g_compatdata.tracked_files_file)
|
try_copy(g_proton.path("proton_3.7_tracked_files"), self.tracked_files_file)
|
||||||
self.remove_tracked_files(g_compatdata.base_dir)
|
self.remove_tracked_files()
|
||||||
return
|
return
|
||||||
|
|
||||||
if old_proton_ver == "3.7" and old_prefix_ver == "1":
|
if old_proton_ver == "3.7" and old_prefix_ver == "1":
|
||||||
if not os.path.exists(g_compatdata.prefix_dir + "/drive_c/windows/syswow64/kernel32.dll"):
|
if not os.path.exists(self.prefix_dir + "/drive_c/windows/syswow64/kernel32.dll"):
|
||||||
#shipped a busted 64-bit-only installation on 20180822. detect and wipe clean
|
#shipped a busted 64-bit-only installation on 20180822. detect and wipe clean
|
||||||
log("Detected broken 64-bit-only installation, re-creating prefix.")
|
log("Detected broken 64-bit-only installation, re-creating prefix.")
|
||||||
shutil.rmtree(g_compatdata.prefix_dir)
|
shutil.rmtree(self.prefix_dir)
|
||||||
return
|
return
|
||||||
|
|
||||||
#replace broken .NET installations with wine-mono support
|
#replace broken .NET installations with wine-mono support
|
||||||
if os.path.exists(g_compatdata.prefix_dir + "/drive_c/windows/Microsoft.NET/NETFXRepair.exe") and \
|
if os.path.exists(self.prefix_dir + "/drive_c/windows/Microsoft.NET/NETFXRepair.exe") and \
|
||||||
file_is_wine_fake_dll(g_compatdata.prefix_dir + "/drive_c/windows/system32/mscoree.dll"):
|
file_is_wine_fake_dll(self.prefix_dir + "/drive_c/windows/system32/mscoree.dll"):
|
||||||
log("Broken .NET installation detected, switching to wine-mono.")
|
log("Broken .NET installation detected, switching to wine-mono.")
|
||||||
#deleting this directory allows wine-mono to work
|
#deleting this directory allows wine-mono to work
|
||||||
shutil.rmtree(g_compatdata.prefix_dir + "/drive_c/windows/Microsoft.NET")
|
shutil.rmtree(self.prefix_dir + "/drive_c/windows/Microsoft.NET")
|
||||||
|
|
||||||
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...
|
||||||
return
|
return
|
||||||
|
|
||||||
def mergedirs(self, src, dst, tracked_files):
|
def copy_pfx(self):
|
||||||
for src_dir, dirs, files in os.walk(src):
|
with open(self.tracked_files_file, "w") as tracked_files:
|
||||||
rel_dir = src_dir.replace(src, "", 1).lstrip('/')
|
for src_dir, dirs, files in os.walk(g_proton.default_pfx_dir):
|
||||||
|
rel_dir = src_dir.replace(g_proton.default_pfx_dir, "", 1).lstrip('/')
|
||||||
if len(rel_dir) > 0:
|
if len(rel_dir) > 0:
|
||||||
rel_dir = rel_dir + "/"
|
rel_dir = rel_dir + "/"
|
||||||
dst_dir = src_dir.replace(src, dst, 1)
|
dst_dir = src_dir.replace(g_proton.default_pfx_dir, self.prefix_dir, 1)
|
||||||
if not os.path.exists(dst_dir):
|
if not os.path.exists(dst_dir):
|
||||||
os.makedirs(dst_dir)
|
os.makedirs(dst_dir)
|
||||||
tracked_files.write(rel_dir + "\n")
|
tracked_files.write(rel_dir + "\n")
|
||||||
@ -240,7 +241,7 @@ class CompatData:
|
|||||||
real_copy(src_file, dst_file)
|
real_copy(src_file, dst_file)
|
||||||
tracked_files.write(rel_dir + file_ + "\n")
|
tracked_files.write(rel_dir + file_ + "\n")
|
||||||
|
|
||||||
def create_fonts_symlinks(self, prefix_path):
|
def create_fonts_symlinks(self):
|
||||||
fontsmap = [
|
fontsmap = [
|
||||||
( "LiberationSans-Regular.ttf", "arial.ttf" ),
|
( "LiberationSans-Regular.ttf", "arial.ttf" ),
|
||||||
( "LiberationSans-Bold.ttf", "arialbd.ttf" ),
|
( "LiberationSans-Bold.ttf", "arialbd.ttf" ),
|
||||||
@ -248,7 +249,7 @@ class CompatData:
|
|||||||
( "LiberationMono-Regular.ttf", "cour.ttf" ),
|
( "LiberationMono-Regular.ttf", "cour.ttf" ),
|
||||||
]
|
]
|
||||||
|
|
||||||
windowsfonts = prefix_path + "/drive_c/windows/Fonts"
|
windowsfonts = self.prefix_dir + "/drive_c/windows/Fonts"
|
||||||
makedirs(windowsfonts)
|
makedirs(windowsfonts)
|
||||||
for p in fontsmap:
|
for p in fontsmap:
|
||||||
lname = os.path.join(windowsfonts, p[1])
|
lname = os.path.join(windowsfonts, p[1])
|
||||||
@ -261,27 +262,25 @@ class CompatData:
|
|||||||
os.symlink(fname, lname)
|
os.symlink(fname, lname)
|
||||||
|
|
||||||
def setup_prefix(self, config_opts):
|
def setup_prefix(self, config_opts):
|
||||||
with g_compatdata.prefix_lock:
|
with self.prefix_lock:
|
||||||
if os.path.exists(g_compatdata.version_file):
|
if os.path.exists(self.version_file):
|
||||||
with open(g_compatdata.version_file, "r") as f:
|
with open(self.version_file, "r") as f:
|
||||||
self.upgrade_pfx(f.readline().strip())
|
self.upgrade_pfx(f.readline().strip())
|
||||||
else:
|
else:
|
||||||
self.upgrade_pfx(None)
|
self.upgrade_pfx(None)
|
||||||
|
|
||||||
if not os.path.exists(g_compatdata.prefix_dir):
|
if not os.path.exists(self.prefix_dir):
|
||||||
makedirs(g_compatdata.prefix_dir + "/drive_c")
|
makedirs(self.prefix_dir + "/drive_c")
|
||||||
set_dir_casefold_bit(g_compatdata.prefix_dir + "/drive_c")
|
set_dir_casefold_bit(self.prefix_dir + "/drive_c")
|
||||||
|
|
||||||
if not os.path.exists(g_compatdata.prefix_dir + "/user.reg"):
|
if not os.path.exists(self.prefix_dir + "/user.reg"):
|
||||||
#copy default prefix into place
|
self.copy_pfx()
|
||||||
with open(g_compatdata.tracked_files_file, "w") as tfiles:
|
|
||||||
self.mergedirs(g_proton.default_pfx_dir, g_compatdata.prefix_dir, tfiles)
|
|
||||||
|
|
||||||
with open(g_compatdata.version_file, "w") as f:
|
with open(self.version_file, "w") as f:
|
||||||
f.write(CURRENT_PREFIX_VERSION + "\n")
|
f.write(CURRENT_PREFIX_VERSION + "\n")
|
||||||
|
|
||||||
#create font files symlinks
|
#create font files symlinks
|
||||||
self.create_fonts_symlinks(g_compatdata.prefix_dir)
|
self.create_fonts_symlinks()
|
||||||
|
|
||||||
#copy steam files into place
|
#copy steam files into place
|
||||||
if "STEAM_COMPAT_CLIENT_INSTALL_PATH" in os.environ:
|
if "STEAM_COMPAT_CLIENT_INSTALL_PATH" in os.environ:
|
||||||
@ -290,7 +289,7 @@ class CompatData:
|
|||||||
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/"
|
||||||
dst = g_compatdata.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",
|
||||||
"steamclient64.dll",
|
"steamclient64.dll",
|
||||||
@ -303,13 +302,13 @@ class CompatData:
|
|||||||
try_copy(steamdir + "/legacycompat/" + f, dstfile)
|
try_copy(steamdir + "/legacycompat/" + f, dstfile)
|
||||||
|
|
||||||
#copy openvr files into place
|
#copy openvr files into place
|
||||||
dst = g_compatdata.prefix_dir + "/drive_c/vrclient/bin/"
|
dst = self.prefix_dir + "/drive_c/vrclient/bin/"
|
||||||
makedirs(dst)
|
makedirs(dst)
|
||||||
try_copy(g_proton.lib_dir + "wine/fakedlls/vrclient.dll", dst)
|
try_copy(g_proton.lib_dir + "wine/fakedlls/vrclient.dll", dst)
|
||||||
try_copy(g_proton.lib64_dir + "wine/fakedlls/vrclient_x64.dll", dst)
|
try_copy(g_proton.lib64_dir + "wine/fakedlls/vrclient_x64.dll", dst)
|
||||||
|
|
||||||
try_copy(g_proton.lib_dir + "wine/dxvk/openvr_api_dxvk.dll", g_compatdata.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", g_compatdata.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/")
|
||||||
|
|
||||||
#parse linux openvr config and present it in win32 format to the app.
|
#parse linux openvr config and present it in win32 format to the app.
|
||||||
#logic from openvr's CVRPathRegistry_Public::GetPaths
|
#logic from openvr's CVRPathRegistry_Public::GetPaths
|
||||||
@ -352,10 +351,10 @@ class CompatData:
|
|||||||
except (TypeError, ValueError, OSError):
|
except (TypeError, ValueError, OSError):
|
||||||
log("Missing or invalid openvrpaths.vrpath file! " + str(sys.exc_info()[1]))
|
log("Missing or invalid openvrpaths.vrpath file! " + str(sys.exc_info()[1]))
|
||||||
|
|
||||||
makedirs(g_compatdata.prefix_dir + "/drive_c/users/steamuser/Local Settings/Application Data/openvr")
|
makedirs(self.prefix_dir + "/drive_c/users/steamuser/Local Settings/Application Data/openvr")
|
||||||
|
|
||||||
#remove existing file
|
#remove existing file
|
||||||
vrpaths_name = g_compatdata.prefix_dir + "/drive_c/users/steamuser/Local Settings/Application Data/openvr/openvrpaths.vrpath"
|
vrpaths_name = self.prefix_dir + "/drive_c/users/steamuser/Local Settings/Application Data/openvr/openvrpaths.vrpath"
|
||||||
if os.path.exists(vrpaths_name):
|
if os.path.exists(vrpaths_name):
|
||||||
os.remove(vrpaths_name)
|
os.remove(vrpaths_name)
|
||||||
|
|
||||||
@ -395,15 +394,15 @@ class CompatData:
|
|||||||
|
|
||||||
for f in wined3dfiles:
|
for f in wined3dfiles:
|
||||||
try_copy(g_proton.default_pfx_dir + "drive_c/windows/system32/" + f + ".dll",
|
try_copy(g_proton.default_pfx_dir + "drive_c/windows/system32/" + f + ".dll",
|
||||||
g_compatdata.prefix_dir + "drive_c/windows/system32/" + f + ".dll")
|
self.prefix_dir + "drive_c/windows/system32/" + f + ".dll")
|
||||||
try_copy(g_proton.default_pfx_dir + "drive_c/windows/syswow64/" + f + ".dll",
|
try_copy(g_proton.default_pfx_dir + "drive_c/windows/syswow64/" + f + ".dll",
|
||||||
g_compatdata.prefix_dir + "drive_c/windows/syswow64/" + f + ".dll")
|
self.prefix_dir + "drive_c/windows/syswow64/" + f + ".dll")
|
||||||
|
|
||||||
for f in dxvkfiles:
|
for f in dxvkfiles:
|
||||||
try_copy(g_proton.lib64_dir + "wine/dxvk/" + f + ".dll",
|
try_copy(g_proton.lib64_dir + "wine/dxvk/" + f + ".dll",
|
||||||
g_compatdata.prefix_dir + "drive_c/windows/system32/" + f + ".dll")
|
self.prefix_dir + "drive_c/windows/system32/" + f + ".dll")
|
||||||
try_copy(g_proton.lib_dir + "wine/dxvk/" + f + ".dll",
|
try_copy(g_proton.lib_dir + "wine/dxvk/" + f + ".dll",
|
||||||
g_compatdata.prefix_dir + "drive_c/windows/syswow64/" + f + ".dll")
|
self.prefix_dir + "drive_c/windows/syswow64/" + f + ".dll")
|
||||||
dlloverrides[f] = "n"
|
dlloverrides[f] = "n"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user