2018-10-05 17:51:21 +02:00
|
|
|
#!/usr/bin/env python3
|
2018-01-18 21:00:48 +01:00
|
|
|
|
|
|
|
#script to launch Wine with the correct environment
|
|
|
|
|
2019-06-27 21:49:29 +02:00
|
|
|
import fcntl
|
|
|
|
import array
|
2018-01-19 18:03:54 +01:00
|
|
|
import filecmp
|
2020-07-17 05:55:44 +02:00
|
|
|
import fnmatch
|
2018-01-18 21:00:48 +01:00
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import shutil
|
2019-02-01 00:02:36 +01:00
|
|
|
import errno
|
2021-09-07 22:35:18 +02:00
|
|
|
import platform
|
2020-09-15 18:37:32 +02:00
|
|
|
import stat
|
2018-01-18 21:00:48 +01:00
|
|
|
import subprocess
|
|
|
|
import sys
|
2018-01-19 18:03:54 +01:00
|
|
|
import tarfile
|
2021-11-19 21:23:45 +01:00
|
|
|
import shlex
|
2018-01-18 21:00:48 +01:00
|
|
|
|
2021-05-11 06:53:15 +02:00
|
|
|
from ctypes import CDLL
|
2021-09-07 22:35:18 +02:00
|
|
|
from ctypes import CFUNCTYPE
|
2021-05-11 06:53:15 +02:00
|
|
|
from ctypes import POINTER
|
|
|
|
from ctypes import Structure
|
|
|
|
from ctypes import addressof
|
|
|
|
from ctypes import cast
|
2021-09-07 22:35:18 +02:00
|
|
|
from ctypes import get_errno
|
|
|
|
from ctypes import sizeof
|
2021-05-11 06:53:15 +02:00
|
|
|
from ctypes import c_int
|
2021-09-07 22:35:18 +02:00
|
|
|
from ctypes import c_int64
|
|
|
|
from ctypes import c_uint
|
|
|
|
from ctypes import c_long
|
2021-05-11 06:53:15 +02:00
|
|
|
from ctypes import c_char_p
|
|
|
|
from ctypes import c_void_p
|
2021-09-07 22:35:18 +02:00
|
|
|
from ctypes import c_size_t
|
|
|
|
from ctypes import c_ssize_t
|
2021-05-11 06:53:15 +02:00
|
|
|
|
2018-10-24 21:22:22 +02:00
|
|
|
from filelock import FileLock
|
2021-05-22 00:10:23 +02:00
|
|
|
from random import randrange
|
2018-03-16 16:08:29 +01:00
|
|
|
|
2018-06-21 16:09:10 +02:00
|
|
|
#To enable debug logging, copy "user_settings.sample.py" to "user_settings.py"
|
|
|
|
#and edit it if needed.
|
2018-03-16 17:02:04 +01:00
|
|
|
|
2023-12-05 20:59:54 +01:00
|
|
|
CURRENT_PREFIX_VERSION="9.0-200"
|
2018-02-15 19:53:47 +01:00
|
|
|
|
2018-01-18 21:00:48 +01:00
|
|
|
PFX="Proton: "
|
2018-10-11 15:50:23 +02:00
|
|
|
ld_path_var = "LD_LIBRARY_PATH"
|
2018-03-06 19:13:24 +01:00
|
|
|
|
2022-02-09 16:10:04 +01:00
|
|
|
def file_exists(s, *, follow_symlinks):
|
|
|
|
if follow_symlinks:
|
|
|
|
#'exists' returns False on broken symlinks
|
|
|
|
return os.path.exists(s)
|
|
|
|
#'lexists' returns True on broken symlinks
|
|
|
|
return os.path.lexists(s)
|
|
|
|
|
2019-02-05 15:08:13 +01:00
|
|
|
def nonzero(s):
|
|
|
|
return len(s) > 0 and s != "0"
|
|
|
|
|
2020-12-03 17:46:39 +01:00
|
|
|
def prepend_to_env_str(env, variable, prepend_str, separator):
|
|
|
|
if not variable in env:
|
|
|
|
env[variable] = prepend_str
|
|
|
|
else:
|
|
|
|
env[variable] = prepend_str + separator + env[variable]
|
|
|
|
|
|
|
|
def append_to_env_str(env, variable, append_str, separator):
|
|
|
|
if not variable in env:
|
|
|
|
env[variable] = append_str
|
|
|
|
else:
|
|
|
|
env[variable] = env[variable] + separator + append_str
|
|
|
|
|
2018-01-18 21:00:48 +01:00
|
|
|
def log(msg):
|
proton: Don't crash if sys.stderr is not usable
If a Steam user runs Steam from a terminal, puts it in the background
and then exits from that terminal, or if they restart their desktop
session from a terminal (as in ValveSoftware/Proton#6277) and then exit
from that terminal, then we can inherit a stdout and/or stderr file
descriptor pointing to an invalid file descriptor. Writing to such a
file descriptor fails with EIO. Similarly, we could get write errors
as a result of OS state, such as ENOSPC if we are writing to a disk
that is full, or EPIPE if a stream to a logging framework such as the
systemd journal has been shut down.
In sufficiently pathological situations, the file descriptor could even
become invalid while the `proton` script is running, so even checking
for validity on startup would not be enough to prevent this.
The ability to log to stderr is important but not functionally critical,
and it's not like there is anything we can usefully do about a write
failure here (or even anywhere we can usefully put a warning message),
so just ignore write errors. This is similar to the behaviour of the
`logging` framework in the Python standard library (which writes to
`stderr` if a user-defined handler fails, but takes no other action)
and also similar to the approach taken to solve
ValveSoftware/steam-for-linux#8069.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Link: https://github.com/ValveSoftware/Proton/pull/6341
2022-11-25 15:23:15 +01:00
|
|
|
try:
|
|
|
|
sys.stderr.write(PFX + msg + os.linesep)
|
|
|
|
sys.stderr.flush()
|
|
|
|
except OSError:
|
|
|
|
# e.g. see https://github.com/ValveSoftware/Proton/issues/6277
|
|
|
|
# There's not much we can usefully do about this: printing a
|
|
|
|
# warning to stderr isn't going to work any better the second time
|
|
|
|
pass
|
2018-02-15 19:53:47 +01:00
|
|
|
|
2020-07-10 21:41:06 +02:00
|
|
|
def file_is_wine_builtin_dll(path):
|
|
|
|
if os.path.islink(path):
|
|
|
|
contents = os.readlink(path)
|
2022-02-08 15:45:52 +01:00
|
|
|
if os.path.dirname(contents).endswith((
|
|
|
|
'/lib/wine',
|
|
|
|
'/lib64/wine',
|
|
|
|
'/lib/wine/fakedlls',
|
|
|
|
'/lib64/wine/fakedlls',
|
|
|
|
'/lib/wine/i386-unix',
|
|
|
|
'/lib/wine/i386-windows',
|
|
|
|
'/lib64/wine/x86_64-unix',
|
|
|
|
'/lib64/wine/x86_64-windows'
|
|
|
|
)):
|
2020-07-10 21:41:06 +02:00
|
|
|
# This may be a broken link to a dll in a removed Proton install
|
|
|
|
return True
|
2022-02-09 16:10:04 +01:00
|
|
|
if not file_exists(path, follow_symlinks=True):
|
2019-04-08 21:27:31 +02:00
|
|
|
return False
|
|
|
|
try:
|
|
|
|
sfile = open(path, "rb")
|
|
|
|
sfile.seek(0x40)
|
|
|
|
tag = sfile.read(20)
|
2020-07-10 21:41:06 +02:00
|
|
|
return tag.startswith((b"Wine placeholder DLL", b"Wine builtin DLL"))
|
2019-04-08 21:27:31 +02:00
|
|
|
except IOError:
|
|
|
|
return False
|
|
|
|
|
2018-01-23 15:03:43 +01:00
|
|
|
def makedirs(path):
|
|
|
|
try:
|
2022-02-09 18:11:11 +01:00
|
|
|
#replace broken symlinks with a new directory
|
|
|
|
if os.path.islink(path) and not file_exists(path, follow_symlinks=True):
|
|
|
|
os.remove(path)
|
2018-01-23 15:03:43 +01:00
|
|
|
os.makedirs(path)
|
2018-10-11 15:50:23 +02:00
|
|
|
except OSError:
|
2018-01-23 15:03:43 +01:00
|
|
|
#already exists
|
|
|
|
pass
|
|
|
|
|
2021-05-27 18:23:08 +02:00
|
|
|
def merge_user_dir(src, dst):
|
|
|
|
extant_dirs = []
|
|
|
|
for src_dir, dirs, files in os.walk(src):
|
|
|
|
dst_dir = src_dir.replace(src, dst, 1)
|
|
|
|
|
|
|
|
#as described below, avoid merging game save subdirs, too
|
|
|
|
child_of_extant_dir = False
|
|
|
|
for dir_ in extant_dirs:
|
|
|
|
if dir_ in dst_dir:
|
|
|
|
child_of_extant_dir = True
|
|
|
|
break
|
|
|
|
if child_of_extant_dir:
|
|
|
|
continue
|
|
|
|
|
|
|
|
#we only want to copy into directories which don't already exist. games
|
|
|
|
#may not react well to two save directory instances being merged.
|
2022-02-09 16:10:04 +01:00
|
|
|
if not file_exists(dst_dir, follow_symlinks=True) or os.path.samefile(dst_dir, dst):
|
2021-05-27 18:23:08 +02:00
|
|
|
makedirs(dst_dir)
|
|
|
|
for dir_ in dirs:
|
|
|
|
src_file = os.path.join(src_dir, dir_)
|
|
|
|
dst_file = os.path.join(dst_dir, dir_)
|
2022-02-09 16:10:04 +01:00
|
|
|
if os.path.islink(src_file) and not file_exists(dst_file, follow_symlinks=True):
|
2021-08-25 18:22:12 +02:00
|
|
|
try_copy(src_file, dst_file, copy_metadata=True, follow_symlinks=False)
|
2021-05-27 18:23:08 +02:00
|
|
|
for file_ in files:
|
|
|
|
src_file = os.path.join(src_dir, file_)
|
|
|
|
dst_file = os.path.join(dst_dir, file_)
|
2022-02-09 16:10:04 +01:00
|
|
|
if not file_exists(dst_file, follow_symlinks=True):
|
2021-08-25 18:22:12 +02:00
|
|
|
try_copy(src_file, dst_file, copy_metadata=True, follow_symlinks=False)
|
2021-05-27 18:23:08 +02:00
|
|
|
else:
|
|
|
|
extant_dirs += dst_dir
|
|
|
|
|
2021-12-16 11:49:30 +01:00
|
|
|
def try_copy(src, dst, prefix=None, add_write_perm=True, copy_metadata=False, optional=False,
|
2021-12-16 12:03:53 +01:00
|
|
|
follow_symlinks=True, track_file=False, link_debug=False):
|
2019-02-01 00:02:36 +01:00
|
|
|
try:
|
2021-12-16 11:49:30 +01:00
|
|
|
if prefix is not None:
|
|
|
|
dst = os.path.join(prefix, dst)
|
|
|
|
|
2019-07-11 22:09:20 +02:00
|
|
|
if os.path.isdir(dst):
|
2021-12-16 11:34:07 +01:00
|
|
|
dst = os.path.join(dst, os.path.basename(src))
|
|
|
|
|
2022-02-09 16:10:04 +01:00
|
|
|
if file_exists(dst, follow_symlinks=False):
|
2021-12-16 11:34:07 +01:00
|
|
|
os.remove(dst)
|
2021-12-16 11:58:22 +01:00
|
|
|
elif track_file and prefix is not None:
|
|
|
|
track_file.write(os.path.relpath(dst, prefix) + '\n')
|
2020-09-15 18:37:32 +02:00
|
|
|
|
2021-09-07 22:35:18 +02:00
|
|
|
if os.path.islink(src) and not follow_symlinks:
|
|
|
|
shutil.copyfile(src, dst, follow_symlinks=False)
|
|
|
|
else:
|
|
|
|
copyfile(src, dst)
|
|
|
|
|
2021-05-27 18:23:08 +02:00
|
|
|
if copy_metadata:
|
2021-09-07 22:35:18 +02:00
|
|
|
shutil.copystat(src, dst, follow_symlinks=follow_symlinks)
|
2021-05-27 18:23:08 +02:00
|
|
|
else:
|
2021-09-07 22:35:18 +02:00
|
|
|
shutil.copymode(src, dst, follow_symlinks=follow_symlinks)
|
2020-09-15 18:37:32 +02:00
|
|
|
|
|
|
|
if add_write_perm:
|
2021-12-16 11:34:07 +01:00
|
|
|
new_mode = os.lstat(dst).st_mode | stat.S_IWUSR | stat.S_IWGRP
|
|
|
|
os.chmod(dst, new_mode)
|
2020-09-15 18:37:32 +02:00
|
|
|
|
2022-02-09 16:10:04 +01:00
|
|
|
if not file_exists(src + '.debug', follow_symlinks=True):
|
2021-12-16 12:03:53 +01:00
|
|
|
link_debug = False
|
|
|
|
|
2022-02-09 16:10:04 +01:00
|
|
|
if file_exists(dst + '.debug', follow_symlinks=False):
|
2021-12-16 12:03:53 +01:00
|
|
|
os.remove(dst + '.debug')
|
|
|
|
elif link_debug:
|
|
|
|
track_file.write(os.path.relpath(dst + '.debug', prefix) + '\n')
|
|
|
|
|
|
|
|
if link_debug:
|
|
|
|
os.symlink(src + '.debug', dst + '.debug')
|
|
|
|
|
2021-05-11 06:53:15 +02:00
|
|
|
except FileNotFoundError as e:
|
|
|
|
if optional:
|
|
|
|
log('Error while copying to \"' + dst + '\": ' + e.strerror)
|
|
|
|
else:
|
|
|
|
raise
|
|
|
|
|
2019-02-01 00:02:36 +01:00
|
|
|
except PermissionError as e:
|
|
|
|
if e.errno == errno.EPERM:
|
|
|
|
#be forgiving about permissions errors; if it's a real problem, things will explode later anyway
|
|
|
|
log('Error while copying to \"' + dst + '\": ' + e.strerror)
|
|
|
|
else:
|
|
|
|
raise
|
|
|
|
|
2021-09-07 22:35:18 +02:00
|
|
|
# copy_file_range implementation for old Python versions
|
|
|
|
__syscall__copy_file_range = None
|
|
|
|
|
|
|
|
def copy_file_range_ctypes(fd_in, fd_out, count):
|
|
|
|
"Copy data using the copy_file_range syscall through ctypes, assuming x86_64 Linux"
|
|
|
|
global __syscall__copy_file_range
|
|
|
|
__NR_copy_file_range = 326
|
|
|
|
|
|
|
|
if __syscall__copy_file_range is None:
|
|
|
|
c_int64_p = POINTER(c_int64)
|
|
|
|
prototype = CFUNCTYPE(c_ssize_t, c_long, c_int, c_int64_p,
|
|
|
|
c_int, c_int64_p, c_size_t, c_uint, use_errno=True)
|
|
|
|
__syscall__copy_file_range = prototype(('syscall', CDLL(None, use_errno=True)))
|
|
|
|
|
|
|
|
while True:
|
|
|
|
ret = __syscall__copy_file_range(__NR_copy_file_range, fd_in, None, fd_out, None, count, 0)
|
|
|
|
if ret >= 0 or get_errno() != errno.EINTR:
|
|
|
|
break
|
|
|
|
|
|
|
|
if ret < 0:
|
|
|
|
raise OSError(get_errno(), errno.errorcode.get(get_errno(), 'unknown'))
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
def copyfile_reflink(srcname, dstname):
|
|
|
|
"Copy srcname to dstname, making reflink if possible"
|
|
|
|
global copyfile
|
|
|
|
with open(srcname, 'rb', buffering=0) as src:
|
|
|
|
bytes_to_copy = os.fstat(src.fileno()).st_size
|
|
|
|
try:
|
|
|
|
with open(dstname, 'wb', buffering=0) as dst:
|
|
|
|
while bytes_to_copy > 0:
|
|
|
|
bytes_to_copy -= copy_file_range(src.fileno(), dst.fileno(), bytes_to_copy)
|
|
|
|
except OSError as e:
|
|
|
|
if e.errno not in (errno.EXDEV, errno.ENOSYS, errno.EINVAL):
|
|
|
|
raise e
|
|
|
|
if e.errno == errno.ENOSYS:
|
|
|
|
copyfile = shutil.copyfile
|
|
|
|
shutil.copyfile(srcname, dstname)
|
|
|
|
|
|
|
|
if hasattr(os, 'copy_file_range'):
|
|
|
|
copyfile = copyfile_reflink
|
|
|
|
copy_file_range = os.copy_file_range
|
|
|
|
elif sys.platform == 'linux' and platform.machine() == 'x86_64' and sizeof(c_void_p) == 8:
|
|
|
|
copyfile = copyfile_reflink
|
|
|
|
copy_file_range = copy_file_range_ctypes
|
|
|
|
else:
|
|
|
|
copyfile = shutil.copyfile
|
|
|
|
|
2020-07-28 19:30:14 +02:00
|
|
|
def try_copyfile(src, dst):
|
|
|
|
try:
|
|
|
|
if os.path.isdir(dst):
|
2021-09-07 22:35:18 +02:00
|
|
|
dst = dst + "/" + os.path.basename(src)
|
|
|
|
if file_exists(dst, follow_symlinks=False):
|
2020-07-28 19:30:14 +02:00
|
|
|
os.remove(dst)
|
2021-09-07 22:35:18 +02:00
|
|
|
copyfile(src, dst)
|
2020-07-28 19:30:14 +02:00
|
|
|
except PermissionError as e:
|
|
|
|
if e.errno == errno.EPERM:
|
|
|
|
#be forgiving about permissions errors; if it's a real problem, things will explode later anyway
|
|
|
|
log('Error while copying to \"' + dst + '\": ' + e.strerror)
|
|
|
|
else:
|
|
|
|
raise
|
|
|
|
|
2020-07-17 05:38:24 +02:00
|
|
|
def getmtimestr(*path_fragments):
|
|
|
|
path = os.path.join(*path_fragments)
|
|
|
|
try:
|
|
|
|
return str(os.path.getmtime(path))
|
|
|
|
except IOError:
|
|
|
|
return "0"
|
|
|
|
|
2020-12-03 20:36:48 +01:00
|
|
|
def try_get_game_library_dir():
|
|
|
|
if not "STEAM_COMPAT_INSTALL_PATH" in g_session.env or \
|
|
|
|
not "STEAM_COMPAT_LIBRARY_PATHS" in g_session.env:
|
|
|
|
return None
|
|
|
|
|
|
|
|
#find library path which is a subset of the game path
|
|
|
|
library_paths = g_session.env["STEAM_COMPAT_LIBRARY_PATHS"].split(":")
|
|
|
|
for l in library_paths:
|
|
|
|
if l in g_session.env["STEAM_COMPAT_INSTALL_PATH"]:
|
|
|
|
return l
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
2022-03-11 17:10:42 +01:00
|
|
|
def try_get_steam_dir():
|
|
|
|
if not "STEAM_COMPAT_CLIENT_INSTALL_PATH" in g_session.env:
|
|
|
|
return None
|
|
|
|
|
|
|
|
return g_session.env["STEAM_COMPAT_CLIENT_INSTALL_PATH"]
|
|
|
|
|
|
|
|
def setup_dir_drive(compat_option, drive_name, dest_dir):
|
|
|
|
drive_path = g_compatdata.prefix_dir + "dosdevices/" + drive_name
|
|
|
|
if compat_option in g_session.compat_config:
|
|
|
|
if not dest_dir:
|
|
|
|
if file_exists(drive_path, follow_symlinks=False):
|
|
|
|
os.remove(drive_path)
|
2022-01-06 22:52:13 +01:00
|
|
|
else:
|
2022-03-11 17:10:42 +01:00
|
|
|
if file_exists(drive_path, follow_symlinks=False):
|
|
|
|
cur_tgt = os.readlink(drive_path)
|
|
|
|
if cur_tgt != dest_dir:
|
|
|
|
os.remove(drive_path)
|
|
|
|
os.symlink(dest_dir, drive_path)
|
2022-01-06 22:52:13 +01:00
|
|
|
else:
|
2022-03-11 17:10:42 +01:00
|
|
|
os.symlink(dest_dir, drive_path)
|
|
|
|
elif file_exists(drive_path, follow_symlinks=False):
|
|
|
|
os.remove(drive_path)
|
|
|
|
|
|
|
|
def setup_game_dir_drive():
|
|
|
|
setup_dir_drive("gamedrive", "s:", try_get_game_library_dir())
|
|
|
|
|
|
|
|
def setup_steam_dir_drive():
|
|
|
|
setup_dir_drive("steamdrive", "t:", try_get_steam_dir())
|
2022-01-06 22:52:13 +01:00
|
|
|
|
2021-05-11 06:53:15 +02:00
|
|
|
# Function to find the installed location of DLL files for use by Wine/Proton
|
|
|
|
# from the NVIDIA Linux driver
|
|
|
|
#
|
|
|
|
# See https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/issues/71 for
|
|
|
|
# background on the chosen method of DLL discovery.
|
|
|
|
#
|
|
|
|
# On success, returns a str() of the absolute-path to the directory at which DLL
|
|
|
|
# files are stored
|
|
|
|
#
|
|
|
|
# On failure, returns None
|
|
|
|
def find_nvidia_wine_dll_dir():
|
|
|
|
try:
|
|
|
|
libdl = CDLL("libdl.so.2")
|
|
|
|
except (OSError):
|
|
|
|
return None
|
|
|
|
|
|
|
|
try:
|
|
|
|
libglx_nvidia = CDLL("libGLX_nvidia.so.0")
|
|
|
|
except OSError:
|
|
|
|
return None
|
|
|
|
|
|
|
|
# from dlinfo(3)
|
|
|
|
#
|
|
|
|
# struct link_map {
|
|
|
|
# ElfW(Addr) l_addr; /* Difference between the
|
|
|
|
# address in the ELF file and
|
|
|
|
# the address in memory */
|
|
|
|
# char *l_name; /* Absolute pathname where
|
|
|
|
# object was found */
|
|
|
|
# ElfW(Dyn) *l_ld; /* Dynamic section of the
|
|
|
|
# shared object */
|
|
|
|
# struct link_map *l_next, *l_prev;
|
|
|
|
# /* Chain of loaded objects */
|
|
|
|
#
|
|
|
|
# /* Plus additional fields private to the
|
|
|
|
# implementation */
|
|
|
|
# };
|
|
|
|
RTLD_DI_LINKMAP = 2
|
|
|
|
class link_map(Structure):
|
|
|
|
_fields_ = [("l_addr", c_void_p), ("l_name", c_char_p), ("l_ld", c_void_p)]
|
|
|
|
|
|
|
|
# from dlinfo(3)
|
|
|
|
#
|
|
|
|
# int dlinfo (void *restrict handle, int request, void *restrict info)
|
|
|
|
dlinfo_func = libdl.dlinfo
|
|
|
|
dlinfo_func.argtypes = c_void_p, c_int, c_void_p
|
|
|
|
dlinfo_func.restype = c_int
|
|
|
|
|
|
|
|
# Allocate a link_map object
|
|
|
|
glx_nvidia_info_ptr = POINTER(link_map)()
|
|
|
|
|
|
|
|
# Run dlinfo(3) on the handle to libGLX_nvidia.so.0, storing results at the
|
|
|
|
# address represented by glx_nvidia_info_ptr
|
|
|
|
if dlinfo_func(libglx_nvidia._handle,
|
|
|
|
RTLD_DI_LINKMAP,
|
|
|
|
addressof(glx_nvidia_info_ptr)) != 0:
|
|
|
|
return None
|
|
|
|
|
|
|
|
# Grab the contents our of our pointer
|
|
|
|
glx_nvidia_info = cast(glx_nvidia_info_ptr, POINTER(link_map)).contents
|
|
|
|
|
|
|
|
# Decode the path to our library to a str()
|
|
|
|
if glx_nvidia_info.l_name is None:
|
|
|
|
return None
|
|
|
|
try:
|
|
|
|
libglx_nvidia_path = os.fsdecode(glx_nvidia_info.l_name)
|
|
|
|
except UnicodeDecodeError:
|
|
|
|
return None
|
|
|
|
|
|
|
|
# Follow any symlinks to the actual file
|
|
|
|
libglx_nvidia_realpath = os.path.realpath(libglx_nvidia_path)
|
|
|
|
|
|
|
|
# Go to the relative path ./nvidia/wine from our library
|
|
|
|
nvidia_wine_dir = os.path.join(os.path.dirname(libglx_nvidia_realpath), "nvidia", "wine")
|
|
|
|
|
|
|
|
# Check that nvngx.dll exists here, or fail
|
2022-02-09 16:10:04 +01:00
|
|
|
if file_exists(os.path.join(nvidia_wine_dir, "nvngx.dll"), follow_symlinks=True):
|
2021-05-11 06:53:15 +02:00
|
|
|
return nvidia_wine_dir
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
2019-07-29 19:17:22 +02:00
|
|
|
EXT2_IOC_GETFLAGS = 0x80086601
|
|
|
|
EXT2_IOC_SETFLAGS = 0x40086602
|
|
|
|
|
|
|
|
EXT4_CASEFOLD_FL = 0x40000000
|
|
|
|
|
|
|
|
def set_dir_casefold_bit(dir_path):
|
|
|
|
dr = os.open(dir_path, 0o644)
|
|
|
|
if dr < 0:
|
|
|
|
return
|
|
|
|
try:
|
|
|
|
dat = array.array('I', [0])
|
|
|
|
if fcntl.ioctl(dr, EXT2_IOC_GETFLAGS, dat, True) >= 0:
|
|
|
|
dat[0] = dat[0] | EXT4_CASEFOLD_FL
|
|
|
|
fcntl.ioctl(dr, EXT2_IOC_SETFLAGS, dat, False)
|
2020-10-13 14:46:59 +02:00
|
|
|
except (OSError, IOError):
|
2019-07-29 19:17:22 +02:00
|
|
|
#no problem
|
|
|
|
pass
|
|
|
|
os.close(dr)
|
2018-07-20 15:26:15 +02:00
|
|
|
|
2019-07-29 17:49:26 +02:00
|
|
|
class Proton:
|
|
|
|
def __init__(self, base_dir):
|
|
|
|
self.base_dir = base_dir + "/"
|
2021-05-28 12:04:30 +02:00
|
|
|
self.dist_dir = self.path("files/")
|
|
|
|
self.bin_dir = self.path("files/bin/")
|
|
|
|
self.lib_dir = self.path("files/lib/")
|
|
|
|
self.lib64_dir = self.path("files/lib64/")
|
|
|
|
self.fonts_dir = self.path("files/share/fonts/")
|
|
|
|
self.wine_fonts_dir = self.path("files/share/wine/fonts/")
|
|
|
|
self.wine_inf = self.path("files/share/wine/wine.inf")
|
2019-07-29 17:49:26 +02:00
|
|
|
self.version_file = self.path("version")
|
2021-05-28 12:04:30 +02:00
|
|
|
self.default_pfx_dir = self.path("files/share/default_pfx/")
|
2019-07-29 17:49:26 +02:00
|
|
|
self.user_settings_file = self.path("user_settings.py")
|
|
|
|
self.wine_bin = self.bin_dir + "wine"
|
2021-10-05 14:49:21 +02:00
|
|
|
self.wine64_bin = self.bin_dir + "wine64"
|
2019-07-29 17:49:26 +02:00
|
|
|
self.wineserver_bin = self.bin_dir + "wineserver"
|
|
|
|
self.dist_lock = FileLock(self.path("dist.lock"), timeout=-1)
|
|
|
|
|
|
|
|
def path(self, d):
|
|
|
|
return self.base_dir + d
|
|
|
|
|
2021-05-28 12:04:30 +02:00
|
|
|
def cleanup_legacy_dist(self):
|
|
|
|
old_dist_dir = self.path("dist/")
|
|
|
|
if file_exists(old_dist_dir, follow_symlinks=True):
|
|
|
|
with self.dist_lock:
|
|
|
|
if file_exists(old_dist_dir, follow_symlinks=True):
|
|
|
|
shutil.rmtree(old_dist_dir)
|
2019-07-29 18:13:36 +02:00
|
|
|
|
2021-03-26 22:04:41 +01:00
|
|
|
def do_steampipe_fixups(self):
|
|
|
|
fixups_json = self.path("steampipe_fixups.json")
|
|
|
|
fixups_mtime = self.path("files/steampipe_fixups_mtime")
|
|
|
|
|
|
|
|
if file_exists(fixups_json, follow_symlinks=True):
|
|
|
|
with self.dist_lock:
|
|
|
|
import steampipe_fixups
|
|
|
|
|
|
|
|
current_fixup_mtime = None
|
|
|
|
if file_exists(fixups_mtime, follow_symlinks=True):
|
|
|
|
with open(fixups_mtime, "r") as f:
|
|
|
|
current_fixup_mtime = f.readline().strip()
|
|
|
|
|
|
|
|
new_fixup_mtime = getmtimestr(fixups_json)
|
|
|
|
|
|
|
|
if current_fixup_mtime != new_fixup_mtime:
|
|
|
|
result_code = steampipe_fixups.do_restore(self.base_dir, fixups_json)
|
|
|
|
|
|
|
|
if result_code == 0:
|
|
|
|
with open(fixups_mtime, "w") as f:
|
|
|
|
f.write(new_fixup_mtime + "\n")
|
|
|
|
|
2020-05-12 11:12:38 +02:00
|
|
|
def missing_default_prefix(self):
|
|
|
|
'''Check if the default prefix dir is missing. Returns true if missing, false if present'''
|
|
|
|
return not os.path.isdir(self.default_pfx_dir)
|
|
|
|
|
2019-07-29 20:59:15 +02:00
|
|
|
def make_default_prefix(self):
|
2019-07-29 18:13:36 +02:00
|
|
|
with self.dist_lock:
|
2019-07-29 20:59:15 +02:00
|
|
|
local_env = dict(g_session.env)
|
2020-05-12 11:12:38 +02:00
|
|
|
if self.missing_default_prefix():
|
2019-07-29 18:13:36 +02:00
|
|
|
#make default prefix
|
|
|
|
local_env["WINEPREFIX"] = self.default_pfx_dir
|
2019-07-31 14:59:37 +02:00
|
|
|
local_env["WINEDEBUG"] = "-all"
|
2019-07-29 21:13:28 +02:00
|
|
|
g_session.run_proc([self.wine_bin, "wineboot"], local_env)
|
|
|
|
g_session.run_proc([self.wineserver_bin, "-w"], local_env)
|
2019-07-29 18:13:36 +02:00
|
|
|
|
2019-07-29 18:09:18 +02:00
|
|
|
class CompatData:
|
|
|
|
def __init__(self, compatdata):
|
|
|
|
self.base_dir = compatdata + "/"
|
|
|
|
self.prefix_dir = self.path("pfx/")
|
|
|
|
self.version_file = self.path("version")
|
2020-07-17 05:38:24 +02:00
|
|
|
self.config_info_file = self.path("config_info")
|
2019-07-29 18:09:18 +02:00
|
|
|
self.tracked_files_file = self.path("tracked_files")
|
|
|
|
self.prefix_lock = FileLock(self.path("pfx.lock"), timeout=-1)
|
|
|
|
|
|
|
|
def path(self, d):
|
|
|
|
return self.base_dir + d
|
|
|
|
|
2019-07-29 19:33:18 +02:00
|
|
|
def remove_tracked_files(self):
|
2022-02-09 16:10:04 +01:00
|
|
|
if not file_exists(self.tracked_files_file, follow_symlinks=True):
|
2019-07-29 19:17:22 +02:00
|
|
|
log("Prefix has no tracked_files??")
|
|
|
|
return
|
|
|
|
|
2019-07-29 19:33:18 +02:00
|
|
|
with open(self.tracked_files_file, "r") as tracked_files:
|
2019-07-29 19:17:22 +02:00
|
|
|
dirs = []
|
|
|
|
for f in tracked_files:
|
2019-07-29 19:33:18 +02:00
|
|
|
path = self.prefix_dir + f.strip()
|
2022-02-09 18:11:11 +01:00
|
|
|
if file_exists(path, follow_symlinks=False):
|
2019-07-29 19:17:22 +02:00
|
|
|
if os.path.isfile(path) or os.path.islink(path):
|
|
|
|
os.remove(path)
|
|
|
|
else:
|
|
|
|
dirs.append(path)
|
|
|
|
for d in dirs:
|
|
|
|
try:
|
|
|
|
os.rmdir(d)
|
|
|
|
except OSError:
|
|
|
|
#not empty
|
|
|
|
pass
|
|
|
|
|
2019-07-29 19:33:18 +02:00
|
|
|
os.remove(self.tracked_files_file)
|
|
|
|
os.remove(self.version_file)
|
2019-07-29 19:17:22 +02:00
|
|
|
|
|
|
|
def upgrade_pfx(self, old_ver):
|
|
|
|
if old_ver == CURRENT_PREFIX_VERSION:
|
|
|
|
return
|
|
|
|
|
2019-07-29 19:33:18 +02:00
|
|
|
log("Upgrading prefix from " + str(old_ver) + " to " + CURRENT_PREFIX_VERSION + " (" + self.base_dir + ")")
|
2019-07-29 19:17:22 +02:00
|
|
|
|
|
|
|
if old_ver is None:
|
|
|
|
return
|
|
|
|
|
|
|
|
if not '-' in old_ver:
|
|
|
|
#How can this happen??
|
|
|
|
log("Prefix has an invalid version?! You may want to back up user files and delete this prefix.")
|
|
|
|
#If it does, just let the Wine upgrade happen and hope it works...
|
|
|
|
return
|
|
|
|
|
|
|
|
try:
|
|
|
|
old_proton_ver, old_prefix_ver = old_ver.split('-')
|
|
|
|
old_proton_maj, old_proton_min = old_proton_ver.split('.')
|
|
|
|
new_proton_ver, new_prefix_ver = CURRENT_PREFIX_VERSION.split('-')
|
|
|
|
new_proton_maj, new_proton_min = new_proton_ver.split('.')
|
|
|
|
|
|
|
|
if int(new_proton_maj) < int(old_proton_maj) or \
|
|
|
|
(int(new_proton_maj) == int(old_proton_maj) and \
|
|
|
|
int(new_proton_min) < int(old_proton_min)):
|
|
|
|
log("Removing newer prefix")
|
2022-02-09 16:10:04 +01:00
|
|
|
if old_proton_ver == "3.7" and not file_exists(self.tracked_files_file, follow_symlinks=True):
|
2019-07-29 19:17:22 +02:00
|
|
|
#proton 3.7 did not generate tracked_files, so copy it into place first
|
2019-07-29 19:33:18 +02:00
|
|
|
try_copy(g_proton.path("proton_3.7_tracked_files"), self.tracked_files_file)
|
|
|
|
self.remove_tracked_files()
|
2019-07-29 19:17:22 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
if old_proton_ver == "3.7" and old_prefix_ver == "1":
|
2022-02-09 16:10:04 +01:00
|
|
|
if not file_exists(self.prefix_dir + "/drive_c/windows/syswow64/kernel32.dll", follow_symlinks=True):
|
2019-07-29 19:17:22 +02:00
|
|
|
#shipped a busted 64-bit-only installation on 20180822. detect and wipe clean
|
|
|
|
log("Detected broken 64-bit-only installation, re-creating prefix.")
|
2019-07-29 19:33:18 +02:00
|
|
|
shutil.rmtree(self.prefix_dir)
|
2019-07-29 19:17:22 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
#replace broken .NET installations with wine-mono support
|
2022-02-09 16:10:04 +01:00
|
|
|
if file_exists(self.prefix_dir + "/drive_c/windows/Microsoft.NET/NETFXRepair.exe", follow_symlinks=True) and \
|
2020-07-10 21:41:06 +02:00
|
|
|
file_is_wine_builtin_dll(self.prefix_dir + "/drive_c/windows/system32/mscoree.dll"):
|
2019-07-29 19:17:22 +02:00
|
|
|
log("Broken .NET installation detected, switching to wine-mono.")
|
|
|
|
#deleting this directory allows wine-mono to work
|
2019-07-29 19:33:18 +02:00
|
|
|
shutil.rmtree(self.prefix_dir + "/drive_c/windows/Microsoft.NET")
|
2019-07-29 19:17:22 +02:00
|
|
|
|
2019-08-13 21:56:07 +02:00
|
|
|
#prior to prefix version 4.11-2, all controllers were xbox controllers. wipe out the old registry entries.
|
|
|
|
if (int(old_proton_maj) < 4 or (int(old_proton_maj) == 4 and int(old_proton_min) == 11)) and \
|
|
|
|
int(old_prefix_ver) < 2:
|
|
|
|
log("Removing old xinput registry entries.")
|
|
|
|
with open(self.prefix_dir + "system.reg", "r") as reg_in:
|
|
|
|
with open(self.prefix_dir + "system.reg.new", "w") as reg_out:
|
|
|
|
for line in reg_in:
|
|
|
|
if line[0] == '[' and "CurrentControlSet" in line and "IG_" in line:
|
|
|
|
if "DeviceClasses" in line:
|
|
|
|
reg_out.write(line.replace("DeviceClasses", "DeviceClasses_old"))
|
|
|
|
elif "Enum" in line:
|
|
|
|
reg_out.write(line.replace("Enum", "Enum_old"))
|
|
|
|
else:
|
|
|
|
reg_out.write(line)
|
|
|
|
try:
|
|
|
|
os.rename(self.prefix_dir + "system.reg", self.prefix_dir + "system.reg.old")
|
|
|
|
except OSError:
|
|
|
|
os.remove(self.prefix_dir + "system.reg")
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
|
|
|
os.rename(self.prefix_dir + "system.reg.new", self.prefix_dir + "system.reg")
|
|
|
|
except OSError:
|
|
|
|
log("Unable to write new registry file to " + self.prefix_dir + "system.reg")
|
|
|
|
pass
|
|
|
|
|
2021-05-22 00:10:23 +02:00
|
|
|
# Prior to prefix version 6.3-3, ShellExecute* APIs used DDE.
|
|
|
|
# Wipe out old registry entries.
|
|
|
|
if int(old_proton_maj) < 6 or (int(old_proton_maj) == 6 and int(old_proton_min) < 3) or \
|
|
|
|
(int(old_proton_maj) == 6 and int(old_proton_min) == 3 and int(old_prefix_ver) < 3):
|
|
|
|
delete_keys = {
|
|
|
|
"[Software\\\\Classes\\\\htmlfile\\\\shell\\\\open\\\\ddeexec",
|
|
|
|
"[Software\\\\Classes\\\\pdffile\\\\shell\\\\open\\\\ddeexec",
|
|
|
|
"[Software\\\\Classes\\\\xmlfile\\\\shell\\\\open\\\\ddeexec",
|
|
|
|
"[Software\\\\Classes\\\\ftp\\\\shell\\\\open\\\\ddeexec",
|
|
|
|
"[Software\\\\Classes\\\\http\\\\shell\\\\open\\\\ddeexec",
|
|
|
|
"[Software\\\\Classes\\\\https\\\\shell\\\\open\\\\ddeexec",
|
|
|
|
}
|
|
|
|
dde_wb = '@="\\"C:\\\\windows\\\\system32\\\\winebrowser.exe\\" -nohome"'
|
|
|
|
|
|
|
|
sysreg_fp = self.prefix_dir + "system.reg"
|
|
|
|
new_sysreg_fp = self.prefix_dir + "system.reg.new"
|
|
|
|
|
|
|
|
log("Removing ShellExecute DDE registry entries.")
|
|
|
|
|
|
|
|
with open(sysreg_fp, "r") as reg_in:
|
|
|
|
with open(new_sysreg_fp, "w") as reg_out:
|
|
|
|
for line in reg_in:
|
|
|
|
if line[:line.find("ddeexec")+len("ddeexec")] in delete_keys:
|
|
|
|
reg_out.write(line.replace("ddeexec", "ddeexec_old", 1))
|
|
|
|
elif line.rstrip() == dde_wb:
|
|
|
|
reg_out.write(line.replace("-nohome", "%1"))
|
|
|
|
else:
|
|
|
|
reg_out.write(line)
|
|
|
|
|
|
|
|
# Slightly randomize backup file name to avoid colliding with
|
|
|
|
# other backups.
|
|
|
|
backup_sysreg_fp = "{}system.reg.{:x}.old".format(self.prefix_dir, randrange(16 ** 8))
|
|
|
|
|
|
|
|
try:
|
|
|
|
os.rename(sysreg_fp, backup_sysreg_fp)
|
|
|
|
except OSError:
|
|
|
|
log("Failed to back up old system.reg. Simply deleting it.")
|
|
|
|
os.remove(sysreg_fp)
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
|
|
|
os.rename(new_sysreg_fp, sysreg_fp)
|
|
|
|
except OSError:
|
|
|
|
log("Unable to write new registry file to " + sysreg_fp)
|
|
|
|
pass
|
|
|
|
|
2021-04-22 11:43:54 +02:00
|
|
|
stale_builtins = [self.prefix_dir + "/drive_c/windows/system32/amd_ags_x64.dll",
|
2023-04-28 11:19:30 +02:00
|
|
|
self.prefix_dir + "/drive_c/windows/syswow64/amd_ags_x64.dll",
|
|
|
|
self.prefix_dir + "/drive_c/windows/system32/ir50_32.dll",
|
|
|
|
self.prefix_dir + "/drive_c/windows/syswow64/ir50_32.dll" ]
|
2021-04-22 11:43:54 +02:00
|
|
|
for builtin in stale_builtins:
|
2022-02-09 16:10:04 +01:00
|
|
|
if file_exists(builtin, follow_symlinks=False) and file_is_wine_builtin_dll(builtin):
|
2021-04-22 11:43:54 +02:00
|
|
|
log("Removing stale builtin " + builtin)
|
|
|
|
os.remove(builtin)
|
|
|
|
|
2019-07-29 19:17:22 +02:00
|
|
|
except ValueError:
|
|
|
|
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...
|
|
|
|
return
|
|
|
|
|
2020-07-28 19:30:14 +02:00
|
|
|
def pfx_copy(self, src, dst, dll_copy=False):
|
2020-07-10 21:41:06 +02:00
|
|
|
if os.path.islink(src):
|
|
|
|
contents = os.readlink(src)
|
2021-10-01 17:24:17 +02:00
|
|
|
if os.path.dirname(contents).endswith(('/lib/wine/i386-unix', '/lib/wine/i386-windows', '/lib64/wine/x86_64-unix', '/lib64/wine/x86_64-windows')):
|
2020-07-10 21:41:06 +02:00
|
|
|
# wine builtin dll
|
|
|
|
# make the destination an absolute symlink
|
|
|
|
contents = os.path.normpath(os.path.join(os.path.dirname(src), contents))
|
2020-07-17 05:55:44 +02:00
|
|
|
if dll_copy:
|
2020-07-28 19:30:14 +02:00
|
|
|
try_copyfile(src, dst)
|
2020-07-17 05:55:44 +02:00
|
|
|
else:
|
|
|
|
os.symlink(contents, dst)
|
2020-07-10 21:41:06 +02:00
|
|
|
else:
|
2020-07-28 19:30:14 +02:00
|
|
|
try_copyfile(src, dst)
|
2020-07-10 21:41:06 +02:00
|
|
|
|
2019-07-29 19:33:18 +02:00
|
|
|
def copy_pfx(self):
|
|
|
|
with open(self.tracked_files_file, "w") as tracked_files:
|
|
|
|
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:
|
|
|
|
rel_dir = rel_dir + "/"
|
|
|
|
dst_dir = src_dir.replace(g_proton.default_pfx_dir, self.prefix_dir, 1)
|
2022-02-09 18:11:11 +01:00
|
|
|
if not file_exists(dst_dir, follow_symlinks=True):
|
|
|
|
makedirs(dst_dir)
|
2019-07-29 19:33:18 +02:00
|
|
|
tracked_files.write(rel_dir + "\n")
|
|
|
|
for dir_ in dirs:
|
|
|
|
src_file = os.path.join(src_dir, dir_)
|
|
|
|
dst_file = os.path.join(dst_dir, dir_)
|
2022-02-09 16:10:04 +01:00
|
|
|
if os.path.islink(src_file) and not file_exists(dst_file, follow_symlinks=True):
|
2020-07-28 19:30:14 +02:00
|
|
|
self.pfx_copy(src_file, dst_file)
|
2019-07-29 19:33:18 +02:00
|
|
|
for file_ in files:
|
|
|
|
src_file = os.path.join(src_dir, file_)
|
|
|
|
dst_file = os.path.join(dst_dir, file_)
|
2022-02-09 16:10:04 +01:00
|
|
|
if not file_exists(dst_file, follow_symlinks=True):
|
2020-07-28 19:30:14 +02:00
|
|
|
self.pfx_copy(src_file, dst_file)
|
2019-07-29 19:33:18 +02:00
|
|
|
tracked_files.write(rel_dir + file_ + "\n")
|
2021-12-23 19:45:16 +01:00
|
|
|
# Set .update-timestamp so Wine doesn't try to update the prefix.
|
|
|
|
# This is needed in case the mtime of wine.inf has changed in distribution.
|
|
|
|
with open(os.path.join(self.prefix_dir, '.update-timestamp'), 'w') as update_timestamp:
|
|
|
|
mtime = int(os.stat(g_proton.wine_inf).st_mtime)
|
|
|
|
update_timestamp.write(str(mtime))
|
2019-07-29 19:33:18 +02:00
|
|
|
|
2020-07-17 05:55:44 +02:00
|
|
|
def update_builtin_libs(self, dll_copy_patterns):
|
|
|
|
dll_copy_patterns = dll_copy_patterns.split(',')
|
2020-07-10 21:41:06 +02:00
|
|
|
prev_tracked_files = set()
|
|
|
|
with open(self.tracked_files_file, "r") as tracked_files:
|
|
|
|
for line in tracked_files:
|
|
|
|
prev_tracked_files.add(line.strip())
|
|
|
|
with open(self.tracked_files_file, "a") as tracked_files:
|
|
|
|
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:
|
|
|
|
rel_dir = rel_dir + "/"
|
|
|
|
dst_dir = src_dir.replace(g_proton.default_pfx_dir, self.prefix_dir, 1)
|
2022-02-09 18:11:11 +01:00
|
|
|
if not file_exists(dst_dir, follow_symlinks=True):
|
|
|
|
makedirs(dst_dir)
|
2020-07-10 21:41:06 +02:00
|
|
|
tracked_files.write(rel_dir + "\n")
|
|
|
|
for file_ in files:
|
|
|
|
src_file = os.path.join(src_dir, file_)
|
|
|
|
dst_file = os.path.join(dst_dir, file_)
|
|
|
|
if not file_is_wine_builtin_dll(src_file):
|
|
|
|
# Not a builtin library
|
|
|
|
continue
|
|
|
|
if file_is_wine_builtin_dll(dst_file):
|
|
|
|
os.unlink(dst_file)
|
2022-02-09 16:10:04 +01:00
|
|
|
elif file_exists(dst_file, follow_symlinks=False):
|
2020-07-10 21:41:06 +02:00
|
|
|
# builtin library was replaced
|
|
|
|
continue
|
|
|
|
else:
|
|
|
|
os.makedirs(dst_dir, exist_ok=True)
|
2020-07-17 05:55:44 +02:00
|
|
|
dll_copy = any(fnmatch.fnmatch(file_, pattern) for pattern in dll_copy_patterns)
|
2020-07-28 19:30:14 +02:00
|
|
|
self.pfx_copy(src_file, dst_file, dll_copy)
|
2020-07-10 21:41:06 +02:00
|
|
|
tracked_name = rel_dir + file_
|
|
|
|
if tracked_name not in prev_tracked_files:
|
|
|
|
tracked_files.write(tracked_name + "\n")
|
|
|
|
|
2023-01-24 14:55:03 +01:00
|
|
|
def create_symlink(self, lname, fname):
|
|
|
|
if file_exists(lname, follow_symlinks=False):
|
|
|
|
if os.path.islink(lname):
|
|
|
|
os.remove(lname)
|
|
|
|
os.symlink(fname, lname)
|
|
|
|
else:
|
|
|
|
os.symlink(fname, lname)
|
|
|
|
|
2019-07-29 19:33:18 +02:00
|
|
|
def create_fonts_symlinks(self):
|
2023-01-24 14:55:03 +01:00
|
|
|
ALTERNATIVES = {
|
|
|
|
('1313860', 'arial.ttf'), # FIFA 21
|
|
|
|
('1506830', 'arial.ttf'), # FIFA 22
|
|
|
|
}
|
2019-07-29 19:33:18 +02:00
|
|
|
windowsfonts = self.prefix_dir + "/drive_c/windows/Fonts"
|
2019-07-29 19:17:22 +02:00
|
|
|
makedirs(windowsfonts)
|
2023-01-24 14:55:03 +01:00
|
|
|
sgi = os.environ.get('SteamGameId', '')
|
2023-01-24 12:13:54 +01:00
|
|
|
for fonts_dir in [g_proton.fonts_dir, g_proton.wine_fonts_dir]:
|
|
|
|
for font in os.listdir(fonts_dir):
|
|
|
|
if not font.endswith('.ttf') and not font.endswith('.ttc'):
|
|
|
|
continue
|
|
|
|
lname = os.path.join(windowsfonts, font)
|
|
|
|
fname = os.path.join(fonts_dir, font)
|
2023-01-24 14:55:03 +01:00
|
|
|
if (sgi, font) in ALTERNATIVES:
|
|
|
|
fname = os.path.join(fonts_dir, 'alt', font)
|
|
|
|
self.create_symlink(lname, fname)
|
2019-07-29 19:17:22 +02:00
|
|
|
|
2021-05-27 18:23:08 +02:00
|
|
|
def migrate_user_paths(self):
|
|
|
|
#move winxp-style paths to vista+ paths. we can't do this in
|
|
|
|
#upgrade_pfx because Steam may drop cloud files here at any time.
|
|
|
|
for (old, new, link) in \
|
|
|
|
[
|
2021-08-19 17:12:07 +02:00
|
|
|
("drive_c/users/steamuser/Local Settings/Application Data",
|
2021-05-27 18:23:08 +02:00
|
|
|
self.prefix_dir + "drive_c/users/steamuser/AppData/Local",
|
|
|
|
"../AppData/Local"),
|
2021-08-19 17:12:07 +02:00
|
|
|
("drive_c/users/steamuser/Application Data",
|
2021-05-27 18:23:08 +02:00
|
|
|
self.prefix_dir + "drive_c/users/steamuser/AppData/Roaming",
|
|
|
|
"./AppData/Roaming"),
|
2021-08-19 17:12:07 +02:00
|
|
|
("drive_c/users/steamuser/My Documents",
|
2021-05-27 18:23:08 +02:00
|
|
|
self.prefix_dir + "drive_c/users/steamuser/Documents",
|
|
|
|
"./Documents"),
|
|
|
|
]:
|
2021-08-19 17:12:07 +02:00
|
|
|
|
|
|
|
#running unofficial Proton/Wine builds against a Proton prefix could
|
|
|
|
#create an infinite symlink loop. detect this and clean it up.
|
2022-02-09 16:10:04 +01:00
|
|
|
if file_exists(new, follow_symlinks=False) and os.path.islink(new) and os.readlink(new).endswith(old):
|
2021-08-19 17:12:07 +02:00
|
|
|
os.remove(new)
|
|
|
|
|
|
|
|
old = self.prefix_dir + old
|
|
|
|
|
2022-02-09 16:10:04 +01:00
|
|
|
if file_exists(old, follow_symlinks=False) and not os.path.islink(old):
|
2021-05-27 18:23:08 +02:00
|
|
|
merge_user_dir(src=old, dst=new)
|
|
|
|
os.rename(old, old + " BACKUP")
|
2022-02-09 16:10:04 +01:00
|
|
|
if not file_exists(old, follow_symlinks=False):
|
2021-05-27 18:23:08 +02:00
|
|
|
makedirs(os.path.dirname(old))
|
|
|
|
os.symlink(src=link, dst=old)
|
|
|
|
elif os.path.islink(old) and not (os.readlink(old) == link):
|
|
|
|
os.remove(old)
|
|
|
|
os.symlink(src=link, dst=old)
|
|
|
|
|
2019-07-29 20:06:51 +02:00
|
|
|
def setup_prefix(self):
|
2019-07-29 19:33:18 +02:00
|
|
|
with self.prefix_lock:
|
2022-02-09 16:10:04 +01:00
|
|
|
if file_exists(self.version_file, follow_symlinks=True):
|
2019-07-29 19:33:18 +02:00
|
|
|
with open(self.version_file, "r") as f:
|
2020-07-17 05:38:24 +02:00
|
|
|
old_ver = f.readline().strip()
|
2019-07-29 19:17:22 +02:00
|
|
|
else:
|
2020-07-17 05:38:24 +02:00
|
|
|
old_ver = None
|
|
|
|
|
|
|
|
self.upgrade_pfx(old_ver)
|
2019-07-29 19:17:22 +02:00
|
|
|
|
2022-02-09 16:10:04 +01:00
|
|
|
if not file_exists(self.prefix_dir, follow_symlinks=True):
|
2019-07-29 19:33:18 +02:00
|
|
|
makedirs(self.prefix_dir + "/drive_c")
|
|
|
|
set_dir_casefold_bit(self.prefix_dir + "/drive_c")
|
2019-07-29 19:17:22 +02:00
|
|
|
|
2022-02-09 16:10:04 +01:00
|
|
|
if not file_exists(self.prefix_dir + "/user.reg", follow_symlinks=True):
|
2019-07-29 19:33:18 +02:00
|
|
|
self.copy_pfx()
|
2019-07-29 19:17:22 +02:00
|
|
|
|
2021-05-27 18:23:08 +02:00
|
|
|
self.migrate_user_paths()
|
|
|
|
|
2021-03-26 22:04:41 +01:00
|
|
|
if not file_exists(self.prefix_dir + "/dosdevices/c:", follow_symlinks=False):
|
2021-03-25 19:14:33 +01:00
|
|
|
os.symlink("../drive_c", self.prefix_dir + "/dosdevices/c:")
|
|
|
|
|
2021-03-26 22:04:41 +01:00
|
|
|
if not file_exists(self.prefix_dir + "/dosdevices/z:", follow_symlinks=False):
|
2021-03-25 19:14:33 +01:00
|
|
|
os.symlink("/", self.prefix_dir + "/dosdevices/z:")
|
|
|
|
|
2020-07-17 05:38:24 +02:00
|
|
|
# collect configuration info
|
2021-05-18 15:45:37 +02:00
|
|
|
steamdir = os.environ["STEAM_COMPAT_CLIENT_INSTALL_PATH"]
|
2020-07-17 05:38:24 +02:00
|
|
|
|
|
|
|
use_wined3d = "wined3d" in g_session.compat_config
|
2021-06-02 16:18:43 +02:00
|
|
|
use_dxvk_dxgi = not use_wined3d and \
|
|
|
|
not ("WINEDLLOVERRIDES" in g_session.env and "dxgi=b" in g_session.env["WINEDLLOVERRIDES"])
|
2023-08-25 14:07:17 +02:00
|
|
|
use_nvapi = 'disablenvapi' not in g_session.compat_config or 'forcenvapi' in g_session.compat_config
|
2020-07-17 05:38:24 +02:00
|
|
|
|
2020-07-29 16:11:37 +02:00
|
|
|
builtin_dll_copy = os.environ.get("PROTON_DLL_COPY",
|
|
|
|
#dxsetup redist
|
|
|
|
"d3dcompiler_*.dll," +
|
|
|
|
"d3dcsx*.dll," +
|
|
|
|
"d3dx*.dll," +
|
2023-08-02 15:37:19 +02:00
|
|
|
"dx8vb.dll," +
|
2020-07-29 16:11:37 +02:00
|
|
|
"x3daudio*.dll," +
|
|
|
|
"xactengine*.dll," +
|
|
|
|
"xapofx*.dll," +
|
|
|
|
"xaudio*.dll," +
|
2020-08-06 22:46:17 +02:00
|
|
|
"xinput*.dll," +
|
|
|
|
|
2020-09-10 20:09:03 +02:00
|
|
|
#vcruntime redist
|
2024-01-12 02:11:26 +01:00
|
|
|
"atl*.dll," +
|
|
|
|
"concrt*.dll," +
|
|
|
|
"msvcp*.dll," +
|
|
|
|
"msvcr*.dll," +
|
|
|
|
"msvcm*.dll," +
|
2020-09-10 20:09:03 +02:00
|
|
|
"vcamp1*.dll," +
|
|
|
|
"vcomp1*.dll," +
|
|
|
|
"vccorlib1*.dll," +
|
|
|
|
"vcruntime1*.dll," +
|
|
|
|
|
2020-08-06 22:46:17 +02:00
|
|
|
#some games balk at ntdll symlink(?)
|
|
|
|
"ntdll.dll," +
|
|
|
|
|
|
|
|
#some games require official vulkan loader
|
2023-12-22 22:19:37 +01:00
|
|
|
"vulkan-1.dll," +
|
|
|
|
|
|
|
|
#let the games install native
|
|
|
|
"ir50_32.dll"
|
2020-07-29 16:11:37 +02:00
|
|
|
)
|
2020-07-17 05:55:44 +02:00
|
|
|
|
2020-07-17 05:38:24 +02:00
|
|
|
# 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),
|
2020-07-17 05:55:44 +02:00
|
|
|
builtin_dll_copy,
|
2021-05-10 23:27:49 +02:00
|
|
|
str(use_nvapi),
|
2020-07-17 05:38:24 +02:00
|
|
|
))
|
|
|
|
|
2021-06-16 06:00:22 +02:00
|
|
|
# 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_ver != CURRENT_PREFIX_VERSION or old_prefix_info != prefix_info:
|
|
|
|
# update builtin dll symlinks or copies
|
|
|
|
self.update_builtin_libs(builtin_dll_copy)
|
|
|
|
|
|
|
|
with open(self.config_info_file, "w") as f:
|
|
|
|
f.write(prefix_info)
|
2020-07-17 05:38:24 +02:00
|
|
|
|
2019-07-29 19:33:18 +02:00
|
|
|
with open(self.version_file, "w") as f:
|
2019-07-29 19:17:22 +02:00
|
|
|
f.write(CURRENT_PREFIX_VERSION + "\n")
|
|
|
|
|
|
|
|
#create font files symlinks
|
2019-07-29 19:33:18 +02:00
|
|
|
self.create_fonts_symlinks()
|
2019-07-29 19:17:22 +02:00
|
|
|
|
2020-08-10 21:23:31 +02:00
|
|
|
with open(self.tracked_files_file, "a") as tracked_files:
|
|
|
|
#copy steam files into place
|
|
|
|
steam_dir = "drive_c/Program Files (x86)/Steam/"
|
2021-12-16 11:58:22 +01:00
|
|
|
makedirs(self.prefix_dir + steam_dir)
|
2020-08-10 21:23:31 +02:00
|
|
|
filestocopy = [("steamclient.dll", "steamclient.dll"),
|
|
|
|
("steamclient64.dll", "steamclient64.dll"),
|
|
|
|
("GameOverlayRenderer64.dll", "GameOverlayRenderer64.dll"),
|
|
|
|
("SteamService.exe", "steam.exe"),
|
|
|
|
("Steam.dll", "Steam.dll")]
|
|
|
|
for (src,tgt) in filestocopy:
|
|
|
|
srcfile = steamdir + '/legacycompat/' + src
|
|
|
|
if os.path.isfile(srcfile):
|
2021-12-16 12:03:53 +01:00
|
|
|
try_copy(srcfile, steam_dir + tgt, prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2020-08-10 21:23:31 +02:00
|
|
|
|
|
|
|
filestocopy = [("steamclient64.dll", "steamclient64.dll"),
|
|
|
|
("GameOverlayRenderer.dll", "GameOverlayRenderer.dll"),
|
|
|
|
("GameOverlayRenderer64.dll", "GameOverlayRenderer64.dll")]
|
|
|
|
for (src,tgt) in filestocopy:
|
|
|
|
srcfile = g_proton.path(src)
|
|
|
|
if os.path.isfile(srcfile):
|
2021-12-16 12:03:53 +01:00
|
|
|
try_copy(srcfile, steam_dir + tgt, prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2019-07-29 19:17:22 +02:00
|
|
|
|
2021-12-17 15:59:35 +01:00
|
|
|
#copy openvr files into place
|
|
|
|
makedirs(self.prefix_dir + "/drive_c/vrclient/bin")
|
|
|
|
try_copy(g_proton.lib_dir + "wine/i386-windows/vrclient.dll", "drive_c/vrclient/bin",
|
2021-12-16 12:03:53 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2021-12-17 15:59:35 +01:00
|
|
|
try_copy(g_proton.lib64_dir + "wine/x86_64-windows/vrclient_x64.dll", "drive_c/vrclient/bin",
|
2021-12-16 12:03:53 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2019-10-22 16:42:06 +02:00
|
|
|
|
2021-12-17 15:59:35 +01:00
|
|
|
try_copy(g_proton.lib_dir + "wine/dxvk/openvr_api_dxvk.dll", "drive_c/windows/syswow64",
|
2021-12-16 12:03:53 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2021-12-17 15:59:35 +01:00
|
|
|
try_copy(g_proton.lib64_dir + "wine/dxvk/openvr_api_dxvk.dll", "drive_c/windows/system32",
|
2021-12-16 12:03:53 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2021-12-17 15:59:35 +01:00
|
|
|
|
|
|
|
makedirs(self.prefix_dir + "/drive_c/openxr")
|
|
|
|
try_copy(g_proton.default_pfx_dir + "drive_c/openxr/wineopenxr64.json", "drive_c/openxr",
|
2021-12-16 12:03:53 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2019-07-29 19:17:22 +02:00
|
|
|
|
2021-12-17 15:59:35 +01:00
|
|
|
#copy vkd3d files into place
|
2022-12-19 14:47:25 +01:00
|
|
|
try_copy(g_proton.lib64_dir + "vkd3d/libvkd3d-1.dll", "drive_c/windows/system32",
|
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
|
|
|
try_copy(g_proton.lib_dir + "vkd3d/libvkd3d-1.dll", "drive_c/windows/syswow64",
|
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2021-12-17 15:59:35 +01:00
|
|
|
try_copy(g_proton.lib64_dir + "vkd3d/libvkd3d-shader-1.dll", "drive_c/windows/system32",
|
2021-12-16 12:03:53 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2021-12-17 15:59:35 +01:00
|
|
|
try_copy(g_proton.lib_dir + "vkd3d/libvkd3d-shader-1.dll", "drive_c/windows/syswow64",
|
2021-12-16 12:03:53 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2019-07-29 20:06:51 +02:00
|
|
|
|
2021-12-17 15:59:35 +01:00
|
|
|
if use_wined3d:
|
2022-02-04 17:40:20 +01:00
|
|
|
dxvkfiles = []
|
2022-07-20 17:40:50 +02:00
|
|
|
vkd3d_protonfiles = []
|
|
|
|
wined3dfiles = ["d3d12", "d3d11", "d3d10", "d3d10core", "d3d10_1", "d3d9"]
|
2021-12-17 15:59:35 +01:00
|
|
|
else:
|
2022-02-04 17:40:20 +01:00
|
|
|
dxvkfiles = ["d3d11", "d3d10core", "d3d9"]
|
2023-03-16 11:45:29 +01:00
|
|
|
vkd3d_protonfiles = ["d3d12", "d3d12core"]
|
2021-12-17 15:59:35 +01:00
|
|
|
wined3dfiles = []
|
|
|
|
|
|
|
|
if use_dxvk_dxgi:
|
|
|
|
dxvkfiles.append("dxgi")
|
|
|
|
else:
|
|
|
|
wined3dfiles.append("dxgi")
|
|
|
|
|
|
|
|
for f in wined3dfiles:
|
|
|
|
try_copy(g_proton.default_pfx_dir + "drive_c/windows/system32/" + f + ".dll", "drive_c/windows/system32",
|
2021-12-16 12:03:53 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2021-12-17 15:59:35 +01:00
|
|
|
try_copy(g_proton.default_pfx_dir + "drive_c/windows/syswow64/" + f + ".dll", "drive_c/windows/syswow64",
|
2021-12-16 12:03:53 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2021-12-17 15:59:35 +01:00
|
|
|
|
|
|
|
for f in dxvkfiles:
|
|
|
|
try_copy(g_proton.lib64_dir + "wine/dxvk/" + f + ".dll", "drive_c/windows/system32",
|
2021-12-16 12:03:53 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2021-12-17 15:59:35 +01:00
|
|
|
try_copy(g_proton.lib_dir + "wine/dxvk/" + f + ".dll", "drive_c/windows/syswow64",
|
2021-12-16 12:03:53 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2021-12-17 15:59:35 +01:00
|
|
|
g_session.dlloverrides[f] = "n"
|
|
|
|
|
2022-07-20 17:40:50 +02:00
|
|
|
for f in vkd3d_protonfiles:
|
2023-03-16 11:45:29 +01:00
|
|
|
optional = False
|
|
|
|
if f == "d3d12core":
|
|
|
|
optional = True
|
2022-07-20 17:40:50 +02:00
|
|
|
try_copy(g_proton.lib64_dir + "wine/vkd3d-proton/" + f + ".dll", "drive_c/windows/system32",
|
2023-03-16 11:45:29 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True, optional=optional)
|
2022-07-20 17:40:50 +02:00
|
|
|
try_copy(g_proton.lib_dir + "wine/vkd3d-proton/" + f + ".dll", "drive_c/windows/syswow64",
|
2023-03-16 11:45:29 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True, optional=optional)
|
2022-07-20 17:40:50 +02:00
|
|
|
g_session.dlloverrides[f] = "n"
|
|
|
|
|
2021-12-17 15:59:35 +01:00
|
|
|
# If the user requested the NVAPI be available, copy it into place.
|
|
|
|
# If they didn't, clean up any stray nvapi DLLs.
|
|
|
|
if use_nvapi:
|
|
|
|
try_copy(g_proton.lib64_dir + "wine/nvapi/nvapi64.dll", "drive_c/windows/system32",
|
2021-12-16 12:03:53 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2021-12-17 15:59:35 +01:00
|
|
|
try_copy(g_proton.lib_dir + "wine/nvapi/nvapi.dll", "drive_c/windows/syswow64",
|
2021-12-16 12:03:53 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2021-12-17 15:59:35 +01:00
|
|
|
g_session.dlloverrides["nvapi64"] = "n"
|
|
|
|
g_session.dlloverrides["nvapi"] = "n"
|
|
|
|
g_session.dlloverrides["nvcuda"] = "b"
|
|
|
|
else:
|
|
|
|
nvapi64_dll = self.prefix_dir + "drive_c/windows/system32/nvapi64.dll"
|
|
|
|
nvapi32_dll = self.prefix_dir + "drive_c/windows/syswow64/nvapi.dll"
|
2022-02-09 18:11:11 +01:00
|
|
|
if file_exists(nvapi64_dll, follow_symlinks=False):
|
2021-12-17 15:59:35 +01:00
|
|
|
os.unlink(nvapi64_dll)
|
2022-02-09 18:11:11 +01:00
|
|
|
if file_exists(nvapi64_dll + '.debug', follow_symlinks=False):
|
2021-12-16 12:03:53 +01:00
|
|
|
os.unlink(nvapi64_dll + '.debug')
|
2022-02-09 18:11:11 +01:00
|
|
|
if file_exists(nvapi32_dll, follow_symlinks=False):
|
2021-12-17 15:59:35 +01:00
|
|
|
os.unlink(nvapi32_dll)
|
2022-02-09 18:11:11 +01:00
|
|
|
if file_exists(nvapi32_dll + '.debug', follow_symlinks=False):
|
2021-12-16 12:03:53 +01:00
|
|
|
os.unlink(nvapi32_dll + '.debug')
|
2021-12-17 15:59:35 +01:00
|
|
|
|
|
|
|
# Try to detect known DLLs that ship with the NVIDIA Linux Driver
|
|
|
|
# and add them into the prefix
|
|
|
|
nvidia_wine_dll_dir = find_nvidia_wine_dll_dir()
|
|
|
|
if nvidia_wine_dll_dir:
|
|
|
|
for dll in ["_nvngx.dll", "nvngx.dll"]:
|
|
|
|
try_copy(nvidia_wine_dll_dir + "/" + dll, "drive_c/windows/system32", optional=True,
|
2021-12-16 12:03:53 +01:00
|
|
|
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True)
|
2021-12-17 15:59:35 +01:00
|
|
|
|
2022-01-06 22:52:13 +01:00
|
|
|
setup_game_dir_drive()
|
2022-03-11 17:10:42 +01:00
|
|
|
setup_steam_dir_drive()
|
2020-12-03 20:36:48 +01:00
|
|
|
|
2021-12-20 23:35:06 +01:00
|
|
|
# add Steam ffmpeg libraries to path
|
2022-07-13 12:11:45 +02:00
|
|
|
use_ffmpeg = "PROTON_NO_STEAM_FFMPEG" not in os.environ or not nonzero(os.environ["PROTON_NO_STEAM_FFMPEG"])
|
|
|
|
if use_ffmpeg and 'nosteamffmpeg' not in g_session.compat_config:
|
|
|
|
prepend_to_env_str(g_session.env, ld_path_var, steamdir + "/ubuntu12_64/video/:" + steamdir + "/ubuntu12_32/video/", ":")
|
2021-12-20 23:35:06 +01:00
|
|
|
|
2020-03-18 19:50:34 +01:00
|
|
|
def comma_escaped(s):
|
|
|
|
escaped = False
|
|
|
|
idx = -1
|
|
|
|
while s[idx] == '\\':
|
|
|
|
escaped = not escaped
|
|
|
|
idx = idx - 1
|
|
|
|
return escaped
|
|
|
|
|
2022-02-10 21:14:36 +01:00
|
|
|
#hopefully short-lived, app-specific workarounds for Proton bugs
|
|
|
|
def default_compat_config():
|
|
|
|
ret = set()
|
|
|
|
if "SteamAppId" in os.environ:
|
|
|
|
appid = os.environ["SteamAppId"]
|
2022-04-05 17:07:05 +02:00
|
|
|
if appid in [
|
2022-02-23 16:38:05 +01:00
|
|
|
#affected by CW bug 19126
|
2022-05-09 17:29:46 +02:00
|
|
|
"536280", #Disintegration
|
2022-05-10 23:41:02 +02:00
|
|
|
"707030", #POSTAL 4: No Regerts
|
2022-11-23 18:45:47 +01:00
|
|
|
"1331440", #FUSER
|
|
|
|
"1359980", #POSTAL: Brain Damaged
|
|
|
|
"1766430", #POSTAL Brain Damaged Demo
|
2023-05-16 19:59:32 +02:00
|
|
|
"692890", #Roboquest
|
2022-02-23 16:38:05 +01:00
|
|
|
|
|
|
|
#affected by CW bug 19741
|
|
|
|
"1017900", #Age of Empires: Definitive Edition
|
2024-01-31 08:55:34 +01:00
|
|
|
|
|
|
|
#affected by CW bug 23184
|
|
|
|
"2229490", #Iragon: Prologue
|
2024-02-15 00:39:46 +01:00
|
|
|
"1522260", #Iragon: Prologue 18+
|
2024-02-15 22:19:16 +01:00
|
|
|
"2229300", #Iragon
|
|
|
|
"1097480", #Iragon 18+
|
2022-02-23 16:38:05 +01:00
|
|
|
]:
|
|
|
|
ret.add("nomfdxgiman")
|
2022-06-28 17:20:01 +02:00
|
|
|
|
|
|
|
if appid in [
|
|
|
|
# OPWR may be causing text input delays in login windows in these games on Wayland due to
|
|
|
|
# blit happening before presentation
|
|
|
|
"1172620", #Sea of Thieves
|
|
|
|
"962130", #Grounded
|
|
|
|
"495420", #State of Decay 2: Juggernaut Edition
|
|
|
|
"976730", #Halo: The Master Chief Collection
|
|
|
|
"1017900", #Age of Empires: Definitive Edition
|
|
|
|
"1056090", #Ori and the Will of the Wisps
|
|
|
|
"1293830", #Forza Horizon 4
|
|
|
|
"1551360", #Forza Horizon 5
|
|
|
|
"271590", #Grand Theft Auto V
|
|
|
|
"5699", #Grand Theft Auto V Premium Edition
|
|
|
|
"1174180", #Red Dead Redemption 2
|
|
|
|
"1404210", #Red Dead Online
|
|
|
|
"12210", #Grand Theft Auto IV: Complete Edition
|
|
|
|
"204100", #Max Payne 3
|
|
|
|
"110800", #L.A. Noire
|
|
|
|
"12200", #Bully: Scholarship Edition
|
|
|
|
"12120", #Grand Theft Auto: San Andreas
|
|
|
|
"12110", #Grand Theft Auto: Vice City
|
|
|
|
"12100", #Grand Theft Auto III
|
|
|
|
"722230", #L.A. Noire: The VR Case Files
|
|
|
|
"813780", #Age of Empires II: Definitive Edition
|
|
|
|
"933110", #Age of Empires III: Definitive Edition
|
|
|
|
"1466860", #Age of Empires IV
|
|
|
|
"1097840", #Gears 5
|
|
|
|
"1244950", #Battletoads
|
|
|
|
"1189800", #Bleeding Edge
|
|
|
|
"1184050", #Gears Tactics
|
|
|
|
"1240440", #Halo Infinite
|
|
|
|
"1250410", #Microsoft Flight Simulator
|
|
|
|
"1672970", #Minecraft Dungeons
|
|
|
|
"1180660", #Tell Me Why
|
|
|
|
"1238430", #Tell Me Why Chapter 2
|
|
|
|
"1266670", #Tell Me Why Chapter 3
|
2022-07-08 21:25:14 +02:00
|
|
|
# Other issues arising from OWPR code path in apps, e. g., hitting unimplemented bits in
|
|
|
|
# d3dcompiler.
|
|
|
|
"230410", #Warframe
|
2022-06-28 17:20:01 +02:00
|
|
|
]:
|
|
|
|
ret.add("noopwr")
|
|
|
|
|
2023-11-03 22:22:49 +01:00
|
|
|
if appid in [
|
|
|
|
"1621680",
|
|
|
|
"359870",
|
|
|
|
]:
|
2022-09-14 00:41:57 +02:00
|
|
|
ret.add("noforcelgadd")
|
|
|
|
|
2023-12-14 19:10:40 +01:00
|
|
|
if appid in [
|
|
|
|
"257420", #Serious Sam 4
|
|
|
|
]:
|
|
|
|
ret.add("hidevggpu")
|
|
|
|
|
2022-12-22 19:14:07 +01:00
|
|
|
if appid in [
|
2023-07-11 15:58:44 +02:00
|
|
|
"1341820", #As Dusk falls
|
|
|
|
"280790", #Creativerse
|
|
|
|
"306130", #The Elder Scrolls Online
|
|
|
|
"24010", #Train Simulator
|
|
|
|
"374320", #DARK SOULS III
|
2023-07-14 19:10:13 +02:00
|
|
|
"65500", #Aura: Fate of the Ages
|
2023-07-31 17:25:25 +02:00
|
|
|
"4000", #Garry's Mod
|
2023-09-01 17:36:58 +02:00
|
|
|
"383120", #Empyrion - Galactic Survival
|
2023-09-01 17:39:02 +02:00
|
|
|
"2371630", #Sword Art Online: Integral Factor
|
2024-01-02 20:06:19 +01:00
|
|
|
"460790", #Bayonetta
|
2023-12-21 01:33:26 +01:00
|
|
|
"273590", #Descent 3
|
2022-12-22 19:14:07 +01:00
|
|
|
]:
|
2022-11-02 02:24:45 +01:00
|
|
|
ret.add("gamedrive")
|
|
|
|
|
2022-09-14 01:14:56 +02:00
|
|
|
if appid in [
|
|
|
|
"202990", #Call of Duty: Black Ops II - Multiplayer
|
|
|
|
"212910", #Call of Duty: Black Ops II - Zombies
|
2023-07-11 12:01:49 +02:00
|
|
|
"499100", #Dark Parables: The Exiled Prince Collector's Edition (499100)
|
2023-09-23 02:01:56 +02:00
|
|
|
"1404090", #Trivia Tricks
|
2023-12-19 00:59:38 +01:00
|
|
|
"2052410", #WITCH ON THE HOLY NIGHT
|
2022-09-14 01:14:56 +02:00
|
|
|
]:
|
|
|
|
ret.add("heapdelayfree")
|
|
|
|
|
2023-05-31 05:29:04 +02:00
|
|
|
if appid in [
|
|
|
|
"2630", #Call of Duty 2
|
2024-01-05 17:58:31 +01:00
|
|
|
"1060210", #Disaster Report 4: Summer Memories
|
2023-05-31 05:29:04 +02:00
|
|
|
]:
|
|
|
|
ret.add("nofsync")
|
|
|
|
ret.add("noesync")
|
|
|
|
|
2022-08-26 22:38:28 +02:00
|
|
|
if appid in [
|
2023-12-11 20:58:13 +01:00
|
|
|
# disable dxvknvapi for titles which dislike it
|
|
|
|
"1088850", #Marvel's Guardians of the Galaxy
|
|
|
|
"1418100", #Swords of Legends Online
|
|
|
|
"2080180", #Go Home Annie Demo
|
|
|
|
"1939100", #Go Home Annie
|
2024-03-11 17:40:04 +01:00
|
|
|
"108710", #Alan Wake
|
2024-03-13 19:09:38 +01:00
|
|
|
"435150", #Divinity: Original Sin 2 - Definitive Edition
|
2022-08-26 22:38:28 +02:00
|
|
|
]:
|
2023-12-11 20:58:13 +01:00
|
|
|
ret.add("disablenvapi")
|
2022-08-26 22:38:28 +02:00
|
|
|
|
2023-12-14 05:19:34 +01:00
|
|
|
if appid in [
|
|
|
|
"2395210" #Tony Hawk's Pro Skater 1 + 2
|
|
|
|
]:
|
|
|
|
ret.add("forcenvapi")
|
|
|
|
|
2024-03-04 19:29:32 +01:00
|
|
|
if appid in [
|
|
|
|
"1252330" #Deathloop
|
|
|
|
]:
|
|
|
|
ret.add("hideapu")
|
|
|
|
|
2022-02-10 21:14:36 +01:00
|
|
|
return ret
|
|
|
|
|
2019-07-29 20:06:51 +02:00
|
|
|
class Session:
|
|
|
|
def __init__(self):
|
|
|
|
self.log_file = None
|
|
|
|
self.env = dict(os.environ)
|
|
|
|
self.dlloverrides = {
|
|
|
|
"steam.exe": "b", #always use our special built-in steam.exe
|
2020-10-16 23:40:56 +02:00
|
|
|
"dotnetfx35.exe": "b", #replace the broken installer, as does Windows
|
2022-06-03 20:03:43 +02:00
|
|
|
"dotnetfx35setup.exe": "b",
|
2021-03-24 19:55:33 +01:00
|
|
|
"beclient.dll": "b,n",
|
|
|
|
"beclient_x64.dll": "b,n",
|
2019-07-29 20:06:51 +02:00
|
|
|
}
|
2020-03-18 19:50:34 +01:00
|
|
|
|
2022-12-27 03:36:58 +01:00
|
|
|
# CW Bug 21737. Locoland executable happens to be steam.exe.
|
|
|
|
if os.environ.get("SteamGameId", 0) == "352130":
|
|
|
|
del self.dlloverrides["steam.exe"]
|
|
|
|
|
2022-02-10 21:14:36 +01:00
|
|
|
self.compat_config = default_compat_config()
|
2020-03-18 19:50:34 +01:00
|
|
|
self.cmdlineappend = []
|
|
|
|
|
2019-07-29 20:06:51 +02:00
|
|
|
if "STEAM_COMPAT_CONFIG" in os.environ:
|
2020-03-18 19:50:34 +01:00
|
|
|
config = os.environ["STEAM_COMPAT_CONFIG"]
|
|
|
|
|
|
|
|
while config:
|
|
|
|
(cur, sep, config) = config.partition(',')
|
|
|
|
if cur.startswith("cmdlineappend:"):
|
|
|
|
while comma_escaped(cur):
|
|
|
|
(a, b, c) = config.partition(',')
|
|
|
|
cur = cur[:-1] + ',' + a
|
|
|
|
config = c
|
|
|
|
self.cmdlineappend.append(cur[14:].replace('\\\\','\\'))
|
|
|
|
else:
|
|
|
|
self.compat_config.add(cur)
|
2020-03-05 20:21:29 +01:00
|
|
|
|
|
|
|
#turn forcelgadd on by default unless it is disabled in compat config
|
|
|
|
if not "noforcelgadd" in self.compat_config:
|
|
|
|
self.compat_config.add("forcelgadd")
|
2019-07-29 19:17:22 +02:00
|
|
|
|
2019-07-29 20:41:01 +02:00
|
|
|
def init_wine(self):
|
2019-07-29 20:53:16 +02:00
|
|
|
if "HOST_LC_ALL" in self.env and len(self.env["HOST_LC_ALL"]) > 0:
|
2019-07-29 20:41:01 +02:00
|
|
|
#steam sets LC_ALL=C to help some games, but Wine requires the real value
|
|
|
|
#in order to do path conversion between win32 and host. steam sets
|
|
|
|
#HOST_LC_ALL to allow us to use the real value.
|
2019-07-29 20:53:16 +02:00
|
|
|
self.env["LC_ALL"] = self.env["HOST_LC_ALL"]
|
2019-07-29 20:41:01 +02:00
|
|
|
else:
|
2019-07-29 20:53:16 +02:00
|
|
|
self.env.pop("LC_ALL", "")
|
2019-07-29 19:17:22 +02:00
|
|
|
|
2024-01-23 09:43:02 +01:00
|
|
|
# CW-Bug-Id: #23185 Enable the new SDL 2.30 Steam Input integration.
|
|
|
|
if "SteamVirtualGamepadInfo_Proton" in self.env and "SteamVirtualGamepadInfo" not in self.env:
|
|
|
|
self.env["SteamVirtualGamepadInfo"] = self.env["SteamVirtualGamepadInfo_Proton"]
|
|
|
|
|
2019-07-29 20:53:16 +02:00
|
|
|
self.env.pop("WINEARCH", "")
|
2018-01-18 21:00:48 +01:00
|
|
|
|
2020-04-01 18:49:02 +02:00
|
|
|
if 'ORIG_'+ld_path_var not in os.environ:
|
|
|
|
# Allow wine to restore this when calling an external app.
|
|
|
|
self.env['ORIG_'+ld_path_var] = os.environ.get(ld_path_var, '')
|
|
|
|
|
2020-12-03 17:46:39 +01:00
|
|
|
prepend_to_env_str(self.env, ld_path_var, g_proton.lib64_dir + ":" + g_proton.lib_dir, ":")
|
2018-01-18 21:00:48 +01:00
|
|
|
|
2019-07-29 20:53:16 +02:00
|
|
|
self.env["WINEDLLPATH"] = g_proton.lib64_dir + "/wine:" + g_proton.lib_dir + "/wine"
|
2019-07-29 18:13:36 +02:00
|
|
|
|
2020-01-29 21:43:56 +01:00
|
|
|
self.env["GST_PLUGIN_SYSTEM_PATH_1_0"] = g_proton.lib64_dir + "gstreamer-1.0" + ":" + g_proton.lib_dir + "gstreamer-1.0"
|
|
|
|
self.env["WINE_GST_REGISTRY_DIR"] = g_compatdata.path("gstreamer-1.0/")
|
|
|
|
|
2020-07-28 15:20:33 +02:00
|
|
|
if "STEAM_COMPAT_MEDIA_PATH" in os.environ:
|
2022-01-21 14:39:33 +01:00
|
|
|
old_audiofoz_path = os.environ["STEAM_COMPAT_MEDIA_PATH"] + "/audio.foz"
|
2022-02-09 16:10:04 +01:00
|
|
|
if file_exists(old_audiofoz_path, follow_symlinks=False):
|
2022-01-21 14:39:33 +01:00
|
|
|
os.remove(old_audiofoz_path)
|
|
|
|
self.env["MEDIACONV_AUDIO_DUMP_FILE"] = os.environ["STEAM_COMPAT_MEDIA_PATH"] + "/audiov2.foz"
|
2020-07-28 15:20:33 +02:00
|
|
|
self.env["MEDIACONV_VIDEO_DUMP_FILE"] = os.environ["STEAM_COMPAT_MEDIA_PATH"] + "/video.foz"
|
2020-11-26 05:26:18 +01:00
|
|
|
|
|
|
|
if "STEAM_COMPAT_TRANSCODED_MEDIA_PATH" in os.environ:
|
|
|
|
self.env["MEDIACONV_AUDIO_TRANSCODED_FILE"] = os.environ["STEAM_COMPAT_TRANSCODED_MEDIA_PATH"] + "/transcoded_audio.foz"
|
|
|
|
self.env["MEDIACONV_VIDEO_TRANSCODED_FILE"] = os.environ["STEAM_COMPAT_TRANSCODED_MEDIA_PATH"] + "/transcoded_video.foz"
|
2020-07-28 15:20:33 +02:00
|
|
|
|
2020-12-03 17:46:39 +01:00
|
|
|
prepend_to_env_str(self.env, "PATH", g_proton.bin_dir, ":")
|
2018-01-19 18:03:54 +01:00
|
|
|
|
2019-07-29 20:41:01 +02:00
|
|
|
def check_environment(self, env_name, config_name):
|
2019-07-29 20:53:16 +02:00
|
|
|
if not env_name in self.env:
|
2019-07-29 20:41:01 +02:00
|
|
|
return False
|
2019-07-29 20:53:16 +02:00
|
|
|
if nonzero(self.env[env_name]):
|
|
|
|
self.compat_config.add(config_name)
|
2019-07-29 20:41:01 +02:00
|
|
|
else:
|
2019-07-29 20:53:16 +02:00
|
|
|
self.compat_config.discard(config_name)
|
2019-07-29 20:41:01 +02:00
|
|
|
return True
|
|
|
|
|
2020-10-29 16:56:11 +01:00
|
|
|
def try_log_slr_versions(self):
|
|
|
|
try:
|
|
|
|
if "PRESSURE_VESSEL_RUNTIME_BASE" in self.env:
|
|
|
|
with open(self.env["PRESSURE_VESSEL_RUNTIME_BASE"] + "/VERSIONS.txt", "r") as f:
|
|
|
|
for l in f:
|
|
|
|
l = l.strip()
|
|
|
|
if len(l) > 0 and not l.startswith("#"):
|
|
|
|
cleaned = l.split("#")[0].strip().replace("\t", " ")
|
|
|
|
split = cleaned.split(" ", maxsplit=1)
|
|
|
|
self.log_file.write(split[0] + ": " + split[1] + "\n")
|
|
|
|
except (OSError, IOError, TypeError, KeyError):
|
|
|
|
pass
|
|
|
|
|
2022-02-22 15:28:52 +01:00
|
|
|
def setup_logging(self, *, append_forever):
|
2021-07-09 19:30:55 +02:00
|
|
|
basedir = self.env.get("PROTON_LOG_DIR", os.environ["HOME"])
|
|
|
|
|
|
|
|
if append_forever:
|
|
|
|
#SteamGameId is not always available
|
|
|
|
lfile_path = basedir + "/steam-proton.log"
|
|
|
|
else:
|
|
|
|
if not "SteamGameId" in os.environ:
|
|
|
|
return False
|
|
|
|
|
|
|
|
lfile_path = basedir + "/steam-" + os.environ["SteamGameId"] + ".log"
|
|
|
|
|
2022-02-09 18:11:11 +01:00
|
|
|
if file_exists(lfile_path, follow_symlinks=False):
|
2021-07-09 19:30:55 +02:00
|
|
|
os.remove(lfile_path)
|
|
|
|
|
|
|
|
makedirs(basedir)
|
|
|
|
self.log_file = open(lfile_path, "a")
|
|
|
|
return True
|
|
|
|
|
2021-05-12 00:07:14 +02:00
|
|
|
def init_session(self, update_prefix_files):
|
2019-07-29 20:53:16 +02:00
|
|
|
self.env["WINEPREFIX"] = g_compatdata.prefix_dir
|
2019-07-29 20:41:01 +02:00
|
|
|
|
|
|
|
#load environment overrides
|
2021-04-22 20:30:10 +02:00
|
|
|
used_user_settings = {}
|
2022-02-09 16:10:04 +01:00
|
|
|
if file_exists(g_proton.user_settings_file, follow_symlinks=True):
|
2019-07-29 20:41:01 +02:00
|
|
|
try:
|
|
|
|
import user_settings
|
2019-07-31 14:59:37 +02:00
|
|
|
for key, value in user_settings.user_settings.items():
|
2021-04-22 20:30:10 +02:00
|
|
|
if not key in self.env:
|
|
|
|
self.env[key] = value
|
|
|
|
used_user_settings[key] = value
|
2019-07-29 20:41:01 +02:00
|
|
|
except:
|
|
|
|
log("************************************************")
|
|
|
|
log("THERE IS AN ERROR IN YOUR user_settings.py FILE:")
|
|
|
|
log("%s" % sys.exc_info()[1])
|
|
|
|
log("************************************************")
|
|
|
|
|
2019-07-31 14:59:37 +02:00
|
|
|
if "PROTON_LOG" in self.env and nonzero(self.env["PROTON_LOG"]):
|
2023-04-21 23:07:29 +02:00
|
|
|
self.env.setdefault("WINEDEBUG", "+timestamp,+pid,+tid,+seh,+unwind,+threadname,+debugstr,+loaddll,+mscoree")
|
2019-07-31 14:59:37 +02:00
|
|
|
self.env.setdefault("DXVK_LOG_LEVEL", "info")
|
2019-11-04 16:51:22 +01:00
|
|
|
self.env.setdefault("VKD3D_DEBUG", "warn")
|
2021-11-17 12:11:21 +01:00
|
|
|
self.env.setdefault("VKD3D_SHADER_DEBUG", "fixme")
|
2019-07-31 14:59:37 +02:00
|
|
|
self.env.setdefault("WINE_MONO_TRACE", "E:System.NotImplementedException")
|
|
|
|
|
2022-02-21 16:09:22 +01:00
|
|
|
if self.env["PROTON_LOG"] != "1":
|
|
|
|
append_to_env_str(self.env, "WINEDEBUG", self.env["PROTON_LOG"], ",")
|
|
|
|
|
2019-07-31 14:59:37 +02:00
|
|
|
#for performance, logging is disabled by default; override with user_settings.py
|
|
|
|
self.env.setdefault("WINEDEBUG", "-all")
|
|
|
|
self.env.setdefault("DXVK_LOG_LEVEL", "none")
|
2019-11-04 16:51:22 +01:00
|
|
|
self.env.setdefault("VKD3D_DEBUG", "none")
|
2021-11-17 12:11:21 +01:00
|
|
|
self.env.setdefault("VKD3D_SHADER_DEBUG", "none")
|
2019-07-31 14:59:37 +02:00
|
|
|
|
2021-03-15 17:28:38 +01:00
|
|
|
#disable XIM support until libx11 >= 1.7 is widespread
|
|
|
|
self.env.setdefault("WINE_ALLOW_XIM", "0")
|
|
|
|
|
2019-07-29 20:53:16 +02:00
|
|
|
if "wined3d11" in self.compat_config:
|
|
|
|
self.compat_config.add("wined3d")
|
2019-07-29 20:41:01 +02:00
|
|
|
|
|
|
|
if not self.check_environment("PROTON_USE_WINED3D", "wined3d"):
|
|
|
|
self.check_environment("PROTON_USE_WINED3D11", "wined3d")
|
|
|
|
self.check_environment("PROTON_NO_D3D11", "nod3d11")
|
|
|
|
self.check_environment("PROTON_NO_D3D10", "nod3d10")
|
|
|
|
self.check_environment("PROTON_NO_ESYNC", "noesync")
|
|
|
|
self.check_environment("PROTON_NO_FSYNC", "nofsync")
|
|
|
|
self.check_environment("PROTON_FORCE_LARGE_ADDRESS_AWARE", "forcelgadd")
|
|
|
|
self.check_environment("PROTON_OLD_GL_STRING", "oldglstr")
|
2020-06-01 18:09:41 +02:00
|
|
|
self.check_environment("PROTON_NO_WRITE_WATCH", "nowritewatch")
|
2020-08-11 16:31:52 +02:00
|
|
|
self.check_environment("PROTON_HIDE_NVIDIA_GPU", "hidenvgpu")
|
2023-12-14 19:10:40 +01:00
|
|
|
self.check_environment("PROTON_HIDE_VANGOGH_GPU", "hidevggpu")
|
2020-12-03 20:36:48 +01:00
|
|
|
self.check_environment("PROTON_SET_GAME_DRIVE", "gamedrive")
|
2022-03-11 17:10:42 +01:00
|
|
|
self.check_environment("PROTON_SET_STEAM_DRIVE", "steamdrive")
|
2021-03-15 17:28:38 +01:00
|
|
|
self.check_environment("PROTON_NO_XIM", "noxim")
|
2021-03-15 19:13:36 +01:00
|
|
|
self.check_environment("PROTON_HEAP_DELAY_FREE", "heapdelayfree")
|
2023-12-11 20:58:13 +01:00
|
|
|
self.check_environment("PROTON_DISABLE_NVAPI", "disablenvapi")
|
2023-08-25 14:07:17 +02:00
|
|
|
self.check_environment("PROTON_FORCE_NVAPI", "forcenvapi")
|
2024-03-04 19:29:32 +01:00
|
|
|
self.check_environment("PROTON_HIDE_APU", "hideapu")
|
2019-07-29 20:41:01 +02:00
|
|
|
|
2020-04-27 14:51:44 +02:00
|
|
|
if "noesync" in self.compat_config:
|
|
|
|
self.env.pop("WINEESYNC", "")
|
|
|
|
else:
|
2019-07-29 20:53:16 +02:00
|
|
|
self.env["WINEESYNC"] = "1"
|
2019-07-29 20:41:01 +02:00
|
|
|
|
2021-03-15 17:28:38 +01:00
|
|
|
if not "noxim" in self.compat_config:
|
|
|
|
self.env.pop("WINE_ALLOW_XIM")
|
|
|
|
|
2020-04-27 14:51:44 +02:00
|
|
|
if "nofsync" in self.compat_config:
|
|
|
|
self.env.pop("WINEFSYNC", "")
|
|
|
|
else:
|
2019-07-29 20:53:16 +02:00
|
|
|
self.env["WINEFSYNC"] = "1"
|
2019-07-29 20:41:01 +02:00
|
|
|
|
2020-06-01 18:09:41 +02:00
|
|
|
if "nowritewatch" in self.compat_config:
|
|
|
|
self.env["WINE_DISABLE_WRITE_WATCH"] = "1"
|
|
|
|
|
2019-07-29 20:53:16 +02:00
|
|
|
if "oldglstr" in self.compat_config:
|
2019-07-29 20:41:01 +02:00
|
|
|
#mesa override
|
2019-07-29 20:53:16 +02:00
|
|
|
self.env["MESA_EXTENSION_MAX_YEAR"] = "2003"
|
2019-07-29 20:41:01 +02:00
|
|
|
#nvidia override
|
2019-07-29 20:53:16 +02:00
|
|
|
self.env["__GL_ExtensionStringVersion"] = "17700"
|
2019-07-29 20:41:01 +02:00
|
|
|
|
2019-07-29 20:53:16 +02:00
|
|
|
if "forcelgadd" in self.compat_config:
|
|
|
|
self.env["WINE_LARGE_ADDRESS_AWARE"] = "1"
|
2023-11-03 22:23:49 +01:00
|
|
|
else:
|
|
|
|
if "noforcelgadd" in self.compat_config:
|
|
|
|
self.env["WINE_LARGE_ADDRESS_AWARE"] = "0"
|
2019-07-29 20:41:01 +02:00
|
|
|
|
2021-03-15 19:13:36 +01:00
|
|
|
if "heapdelayfree" in self.compat_config:
|
|
|
|
self.env["WINE_HEAP_DELAY_FREE"] = "1"
|
|
|
|
|
2020-12-03 17:35:34 +01:00
|
|
|
if "vkd3dbindlesstb" in self.compat_config:
|
2020-12-03 17:46:39 +01:00
|
|
|
append_to_env_str(self.env, "VKD3D_CONFIG", "force_bindless_texel_buffer", ",")
|
2020-12-03 17:35:34 +01:00
|
|
|
|
2020-07-15 22:01:55 +02:00
|
|
|
if "vkd3dfl12" in self.compat_config:
|
|
|
|
if not "VKD3D_FEATURE_LEVEL" in self.env:
|
|
|
|
self.env["VKD3D_FEATURE_LEVEL"] = "12_0"
|
|
|
|
|
2023-12-14 19:10:40 +01:00
|
|
|
if "hidevggpu" in self.compat_config:
|
|
|
|
self.env["WINE_HIDE_VANGOGH_GPU"] = "1"
|
|
|
|
|
2023-08-25 14:07:17 +02:00
|
|
|
if "hidenvgpu" in self.compat_config and "forcenvapi" not in self.compat_config:
|
2020-08-11 16:31:52 +02:00
|
|
|
self.env["WINE_HIDE_NVIDIA_GPU"] = "1"
|
|
|
|
|
2024-03-04 19:29:32 +01:00
|
|
|
if "hideapu" in self.compat_config:
|
|
|
|
self.env["WINE_HIDE_APU"] = "1"
|
|
|
|
|
2021-10-05 16:37:22 +02:00
|
|
|
if "usenativexinput13" in self.compat_config:
|
|
|
|
self.dlloverrides["xinput1_3"] = "n"
|
|
|
|
|
2021-10-20 14:17:17 +02:00
|
|
|
if "disablelibglesv2" in self.compat_config:
|
|
|
|
self.dlloverrides["libglesv2"] = "d"
|
|
|
|
|
2022-02-23 16:38:05 +01:00
|
|
|
if "nomfdxgiman" in self.compat_config:
|
|
|
|
self.env["WINE_DO_NOT_CREATE_DXGI_DEVICE_MANAGER"] = "1"
|
|
|
|
|
2022-06-28 17:20:01 +02:00
|
|
|
if "noopwr" in self.compat_config:
|
|
|
|
self.env["WINE_DISABLE_VULKAN_OPWR"] = "1"
|
|
|
|
|
2021-05-18 23:02:44 +02:00
|
|
|
if "PROTON_CRASH_REPORT_DIR" in self.env:
|
|
|
|
self.env["WINE_CRASH_REPORT_DIR"] = self.env["PROTON_CRASH_REPORT_DIR"]
|
|
|
|
|
2023-03-01 18:13:55 +01:00
|
|
|
if "PROTON_LOG" in self.env and nonzero(self.env["PROTON_LOG"]):
|
2021-07-09 19:30:55 +02:00
|
|
|
if self.setup_logging(append_forever=False):
|
2019-07-29 20:53:16 +02:00
|
|
|
self.log_file.write("======================\n")
|
2019-07-29 20:41:01 +02:00
|
|
|
with open(g_proton.version_file, "r") as f:
|
2019-07-29 20:53:16 +02:00
|
|
|
self.log_file.write("Proton: " + f.readline().strip() + "\n")
|
2021-07-09 19:30:55 +02:00
|
|
|
if "SteamGameId" in self.env:
|
|
|
|
self.log_file.write("SteamGameId: " + self.env["SteamGameId"] + "\n")
|
2020-03-18 19:50:34 +01:00
|
|
|
self.log_file.write("Command: " + str(sys.argv[2:] + self.cmdlineappend) + "\n")
|
2019-07-29 20:53:16 +02:00
|
|
|
self.log_file.write("Options: " + str(self.compat_config) + "\n")
|
2021-07-09 19:30:55 +02:00
|
|
|
|
2020-10-29 16:56:11 +01:00
|
|
|
self.try_log_slr_versions()
|
2021-04-22 20:30:10 +02:00
|
|
|
|
2021-10-11 18:26:33 +02:00
|
|
|
try:
|
|
|
|
uname = os.uname()
|
|
|
|
kernel_version = f"{uname.sysname} {uname.release} {uname.version} {uname.machine}"
|
|
|
|
except OSError:
|
|
|
|
kernel_version = "unknown"
|
|
|
|
|
|
|
|
self.log_file.write(f"Kernel: {kernel_version}\n")
|
2023-01-11 12:00:56 +01:00
|
|
|
self.log_file.write("Language: LC_ALL " + str(self.env.get("HOST_LC_ALL", None)) +
|
|
|
|
", LC_MESSAGES " + str(self.env.get("LC_MESSAGES", None)) +
|
|
|
|
", LC_CTYPE " + str(self.env.get("LC_CTYPE", None)) + "\n")
|
2021-10-11 18:26:33 +02:00
|
|
|
|
2021-04-22 20:30:10 +02:00
|
|
|
#dump some important variables into the log header
|
|
|
|
for var in ["WINEDLLOVERRIDES", "WINEDEBUG"]:
|
|
|
|
if var in os.environ:
|
|
|
|
self.log_file.write("System " + var + ": " + os.environ[var] + "\n")
|
|
|
|
if var in used_user_settings:
|
|
|
|
self.log_file.write("User settings " + var + ": " + used_user_settings[var] + "\n")
|
2023-05-17 17:38:47 +02:00
|
|
|
if var in self.env:
|
|
|
|
self.log_file.write("Effective " + var + ": " + self.env[var] + "\n")
|
2021-04-22 20:30:10 +02:00
|
|
|
|
2019-07-29 20:53:16 +02:00
|
|
|
self.log_file.write("======================\n")
|
|
|
|
self.log_file.flush()
|
2021-07-09 19:30:55 +02:00
|
|
|
else:
|
|
|
|
self.env["WINEDEBUG"] = "-all"
|
2018-01-18 21:00:48 +01:00
|
|
|
|
2021-06-24 11:54:08 +02:00
|
|
|
if "PROTON_REMOTE_DEBUG_CMD" in self.env:
|
2021-11-19 21:23:45 +01:00
|
|
|
self.remote_debug_cmd = shlex.split(self.env.get("PROTON_REMOTE_DEBUG_CMD"))
|
2021-06-24 11:54:08 +02:00
|
|
|
else:
|
|
|
|
self.remote_debug_cmd = None
|
|
|
|
|
2021-05-12 00:07:14 +02:00
|
|
|
if update_prefix_files:
|
|
|
|
g_compatdata.setup_prefix()
|
2019-02-05 15:06:03 +01:00
|
|
|
|
2019-07-29 20:53:16 +02:00
|
|
|
if "nod3d11" in self.compat_config:
|
|
|
|
self.dlloverrides["d3d11"] = ""
|
|
|
|
if "dxgi" in self.dlloverrides:
|
|
|
|
del self.dlloverrides["dxgi"]
|
2018-05-11 14:14:04 +02:00
|
|
|
|
2019-07-29 20:53:16 +02:00
|
|
|
if "nod3d10" in self.compat_config:
|
|
|
|
self.dlloverrides["d3d10_1"] = ""
|
|
|
|
self.dlloverrides["d3d10"] = ""
|
|
|
|
self.dlloverrides["dxgi"] = ""
|
2018-02-14 20:59:35 +01:00
|
|
|
|
2021-02-05 15:16:17 +01:00
|
|
|
if "nativevulkanloader" in self.compat_config:
|
|
|
|
self.dlloverrides["vulkan-1"] = "n"
|
|
|
|
|
2023-08-25 14:07:17 +02:00
|
|
|
if "disablenvapi" not in self.compat_config or "forcenvapi" in self.compat_config:
|
2022-03-16 00:38:59 +01:00
|
|
|
self.env["DXVK_ENABLE_NVAPI"] = "1"
|
|
|
|
|
2023-08-25 14:07:17 +02:00
|
|
|
if "forcenvapi" in self.compat_config:
|
|
|
|
self.env["DXVK_NVAPI_ALLOW_OTHER_DRIVERS"] = "1"
|
|
|
|
self.env["DXVK_NVAPI_DRIVER_VERSION"] = "99999"
|
|
|
|
self.env["WINE_HIDE_AMD_GPU"] = "1"
|
|
|
|
|
2019-07-29 20:41:01 +02:00
|
|
|
s = ""
|
2019-07-29 20:53:16 +02:00
|
|
|
for dll in self.dlloverrides:
|
|
|
|
setting = self.dlloverrides[dll]
|
2019-07-29 20:41:01 +02:00
|
|
|
if len(s) > 0:
|
|
|
|
s = s + ";" + dll + "=" + setting
|
|
|
|
else:
|
|
|
|
s = dll + "=" + setting
|
2020-12-03 17:46:39 +01:00
|
|
|
append_to_env_str(self.env, "WINEDLLOVERRIDES", s, ";")
|
2019-07-29 20:41:01 +02:00
|
|
|
|
2019-07-29 20:59:15 +02:00
|
|
|
def run_proc(self, args, local_env=None):
|
2019-07-29 21:13:28 +02:00
|
|
|
if local_env is None:
|
2019-07-29 20:59:15 +02:00
|
|
|
local_env = self.env
|
2021-10-27 16:25:56 +02:00
|
|
|
return subprocess.call(args, env=local_env, stderr=self.log_file, stdout=self.log_file)
|
2018-01-18 21:00:48 +01:00
|
|
|
|
2019-07-29 20:41:01 +02:00
|
|
|
def run(self):
|
proton: Allow forwarding commands into the Proton environment
Recent versions of the Steam Runtime include an IPC server/client pair
which can be used to run commands inside the container environment
(or any other special execution environment), analogous to sshd/ssh or
flatpak-portal/flatpak-spawn. The server runs inside the Steam Runtime
container and accepts commands over D-Bus; the client runs on the host
system, asks the server to run a command, and forwards its stdin, stdout
and stderr back to the host.
https://gitlab.steamos.cloud/steamrt/steamlinuxruntime/-/merge_requests/72
adds support for injecting commands into the SteamLinuxRuntime_soldier
compatibility tool (and any later version, such as sniper). However,
Steam compatibility tools are stackable: in particular, Proton runs in a
soldier container (or presumably sniper in future). If we are debugging
a Proton game, then ideally we will want to inject commands into Proton's
execution environment rather than soldier's, so that they run with the
correct environment variables etc. to communicate with a running Proton
session. In particular, it's important that the `WINEPREFIX` is correct.
The steam-runtime-launcher-interface-0 program implements the
interface for compatibility tools to use to decide where, if anywhere,
to launch the command server.
This commit does not alter the scripts produced by
PROTON_DUMP_DEBUG_COMMANDS. To run those scripts' commands in the
container environment, pass their filenames to
steam-runtime-launch-client.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Link: https://github.com/ValveSoftware/Proton/pull/5891
2022-06-08 19:17:05 +02:00
|
|
|
if shutil.which('steam-runtime-launcher-interface-0') is not None:
|
|
|
|
adverb = ['steam-runtime-launcher-interface-0', 'proton']
|
|
|
|
else:
|
|
|
|
adverb = []
|
|
|
|
|
2021-06-24 11:54:08 +02:00
|
|
|
if self.remote_debug_cmd:
|
2021-11-19 21:23:45 +01:00
|
|
|
remote_debug_cmd = self.remote_debug_cmd
|
|
|
|
if not os.path.isabs(remote_debug_cmd[0]):
|
|
|
|
remote_debug_cmd[0] = g_proton.path(remote_debug_cmd[0])
|
2021-06-24 11:54:08 +02:00
|
|
|
remote_debug_proc = subprocess.Popen([g_proton.wine_bin] + self.remote_debug_cmd,
|
|
|
|
env=self.env, stderr=self.log_file, stdout=self.log_file)
|
|
|
|
else:
|
|
|
|
remote_debug_proc = None
|
|
|
|
|
2022-01-21 21:26:09 +01:00
|
|
|
# CoD: Black Ops 3 workaround
|
|
|
|
if os.environ.get("SteamGameId", 0) == "311210":
|
proton: Allow forwarding commands into the Proton environment
Recent versions of the Steam Runtime include an IPC server/client pair
which can be used to run commands inside the container environment
(or any other special execution environment), analogous to sshd/ssh or
flatpak-portal/flatpak-spawn. The server runs inside the Steam Runtime
container and accepts commands over D-Bus; the client runs on the host
system, asks the server to run a command, and forwards its stdin, stdout
and stderr back to the host.
https://gitlab.steamos.cloud/steamrt/steamlinuxruntime/-/merge_requests/72
adds support for injecting commands into the SteamLinuxRuntime_soldier
compatibility tool (and any later version, such as sniper). However,
Steam compatibility tools are stackable: in particular, Proton runs in a
soldier container (or presumably sniper in future). If we are debugging
a Proton game, then ideally we will want to inject commands into Proton's
execution environment rather than soldier's, so that they run with the
correct environment variables etc. to communicate with a running Proton
session. In particular, it's important that the `WINEPREFIX` is correct.
The steam-runtime-launcher-interface-0 program implements the
interface for compatibility tools to use to decide where, if anywhere,
to launch the command server.
This commit does not alter the scripts produced by
PROTON_DUMP_DEBUG_COMMANDS. To run those scripts' commands in the
container environment, pass their filenames to
steam-runtime-launch-client.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Link: https://github.com/ValveSoftware/Proton/pull/5891
2022-06-08 19:17:05 +02:00
|
|
|
argv = [g_proton.wine_bin, "c:\\Program Files (x86)\\Steam\\steam.exe"]
|
2022-01-21 21:26:09 +01:00
|
|
|
else:
|
proton: Allow forwarding commands into the Proton environment
Recent versions of the Steam Runtime include an IPC server/client pair
which can be used to run commands inside the container environment
(or any other special execution environment), analogous to sshd/ssh or
flatpak-portal/flatpak-spawn. The server runs inside the Steam Runtime
container and accepts commands over D-Bus; the client runs on the host
system, asks the server to run a command, and forwards its stdin, stdout
and stderr back to the host.
https://gitlab.steamos.cloud/steamrt/steamlinuxruntime/-/merge_requests/72
adds support for injecting commands into the SteamLinuxRuntime_soldier
compatibility tool (and any later version, such as sniper). However,
Steam compatibility tools are stackable: in particular, Proton runs in a
soldier container (or presumably sniper in future). If we are debugging
a Proton game, then ideally we will want to inject commands into Proton's
execution environment rather than soldier's, so that they run with the
correct environment variables etc. to communicate with a running Proton
session. In particular, it's important that the `WINEPREFIX` is correct.
The steam-runtime-launcher-interface-0 program implements the
interface for compatibility tools to use to decide where, if anywhere,
to launch the command server.
This commit does not alter the scripts produced by
PROTON_DUMP_DEBUG_COMMANDS. To run those scripts' commands in the
container environment, pass their filenames to
steam-runtime-launch-client.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Link: https://github.com/ValveSoftware/Proton/pull/5891
2022-06-08 19:17:05 +02:00
|
|
|
argv = [g_proton.wine64_bin, "c:\\windows\\system32\\steam.exe"]
|
|
|
|
|
|
|
|
rc = self.run_proc(adverb + argv + sys.argv[2:] + self.cmdlineappend)
|
2018-01-25 20:22:24 +01:00
|
|
|
|
2021-06-24 11:54:08 +02:00
|
|
|
if remote_debug_proc:
|
|
|
|
remote_debug_proc.kill()
|
|
|
|
try:
|
|
|
|
remote_debug_proc.communicate(2)
|
|
|
|
except subprocess.TimeoutExpired as e:
|
|
|
|
log("terminate remote debugger")
|
|
|
|
remote_debug_proc.terminate()
|
|
|
|
remote_debug_proc.communicate()
|
2018-01-18 21:00:48 +01:00
|
|
|
|
2021-10-27 16:25:56 +02:00
|
|
|
return rc
|
|
|
|
|
2019-07-29 21:09:28 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
if not "STEAM_COMPAT_DATA_PATH" in os.environ:
|
|
|
|
log("No compat data path?")
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
g_proton = Proton(os.path.dirname(sys.argv[0]))
|
|
|
|
|
2021-05-28 12:04:30 +02:00
|
|
|
g_proton.cleanup_legacy_dist()
|
2021-03-26 22:04:41 +01:00
|
|
|
g_proton.do_steampipe_fixups()
|
2019-07-29 21:09:28 +02:00
|
|
|
|
|
|
|
g_compatdata = CompatData(os.environ["STEAM_COMPAT_DATA_PATH"])
|
|
|
|
|
|
|
|
g_session = Session()
|
|
|
|
|
|
|
|
g_session.init_wine()
|
|
|
|
|
2020-05-12 11:12:38 +02:00
|
|
|
if g_proton.missing_default_prefix():
|
|
|
|
g_proton.make_default_prefix()
|
2019-07-29 21:09:28 +02:00
|
|
|
|
2021-05-12 00:07:14 +02:00
|
|
|
g_session.init_session(sys.argv[1] != "runinprefix")
|
2019-07-29 21:09:28 +02:00
|
|
|
|
|
|
|
#determine mode
|
2021-10-27 16:25:56 +02:00
|
|
|
rc = 0
|
2019-07-29 21:09:28 +02:00
|
|
|
if sys.argv[1] == "run":
|
|
|
|
#start target app
|
2022-01-06 22:52:13 +01:00
|
|
|
setup_game_dir_drive()
|
2022-03-11 17:10:42 +01:00
|
|
|
setup_steam_dir_drive()
|
2021-10-27 16:25:56 +02:00
|
|
|
rc = g_session.run()
|
2019-07-29 21:09:28 +02:00
|
|
|
elif sys.argv[1] == "waitforexitandrun":
|
|
|
|
#wait for wineserver to shut down
|
|
|
|
g_session.run_proc([g_proton.wineserver_bin, "-w"])
|
|
|
|
#then run
|
2021-10-27 16:25:56 +02:00
|
|
|
rc = g_session.run()
|
2021-05-12 00:07:14 +02:00
|
|
|
elif sys.argv[1] == "runinprefix":
|
2021-10-27 16:25:56 +02:00
|
|
|
rc = g_session.run_proc([g_proton.wine_bin] + sys.argv[2:])
|
2022-01-20 21:36:09 +01:00
|
|
|
elif sys.argv[1] == "destroyprefix":
|
|
|
|
g_compatdata.remove_tracked_files()
|
2019-07-29 21:09:28 +02:00
|
|
|
elif sys.argv[1] == "getcompatpath":
|
|
|
|
#linux -> windows path
|
|
|
|
path = subprocess.check_output([g_proton.wine_bin, "winepath", "-w", sys.argv[2]], env=g_session.env, stderr=g_session.log_file)
|
2020-01-06 15:21:54 +01:00
|
|
|
sys.stdout.buffer.write(path)
|
2019-07-29 21:09:28 +02:00
|
|
|
elif sys.argv[1] == "getnativepath":
|
|
|
|
#windows -> linux path
|
|
|
|
path = subprocess.check_output([g_proton.wine_bin, "winepath", sys.argv[2]], env=g_session.env, stderr=g_session.log_file)
|
2020-01-06 15:21:54 +01:00
|
|
|
sys.stdout.buffer.write(path)
|
2019-07-29 21:09:28 +02:00
|
|
|
else:
|
|
|
|
log("Need a verb.")
|
|
|
|
sys.exit(1)
|
|
|
|
|
2021-10-27 16:25:56 +02:00
|
|
|
sys.exit(rc)
|
2018-08-29 14:45:41 +02:00
|
|
|
|
2019-07-29 21:13:28 +02:00
|
|
|
#pylint --disable=C0301,C0326,C0330,C0111,C0103,R0902,C1801,R0914,R0912,R0915
|
2018-08-29 14:45:41 +02:00
|
|
|
# vim: set syntax=python:
|