2018-02-07 22:56:06 +03:00
|
|
|
#!/usr/bin/python2.7
|
2018-01-18 23:00:48 +03:00
|
|
|
|
|
|
|
#script to launch Wine with the correct environment
|
|
|
|
|
2018-01-19 20:03:54 +03:00
|
|
|
import filecmp
|
2018-01-18 23:00:48 +03:00
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2018-01-19 20:03:54 +03:00
|
|
|
import tarfile
|
2018-01-18 23:00:48 +03:00
|
|
|
|
|
|
|
PFX="Proton: "
|
|
|
|
|
|
|
|
def log(msg):
|
|
|
|
sys.stdout.write(PFX + msg + os.linesep)
|
|
|
|
|
2018-01-19 22:03:51 +03:00
|
|
|
def run_wine(args):
|
|
|
|
if lfile == None:
|
|
|
|
subprocess.call(args, env=env)
|
|
|
|
else:
|
|
|
|
subprocess.call(args, env=env, stdout=lfile, stderr=subprocess.STDOUT)
|
|
|
|
|
2018-01-23 17:03:43 +03:00
|
|
|
def makedirs(path):
|
|
|
|
try:
|
|
|
|
os.makedirs(path)
|
|
|
|
except:
|
|
|
|
#already exists
|
|
|
|
pass
|
|
|
|
|
2018-01-18 23:00:48 +03:00
|
|
|
if not ("STEAM_COMPAT_DATA_PATH" in os.environ):
|
|
|
|
log("No compat data path?")
|
|
|
|
sys.exit(1)
|
|
|
|
|
2018-01-25 22:22:24 +03:00
|
|
|
if "STEAM_COMPAT_CONFIG" in os.environ:
|
2018-02-09 20:03:59 +03:00
|
|
|
config_opts = os.environ["STEAM_COMPAT_CONFIG"].split(",")
|
|
|
|
else:
|
|
|
|
config_opts = []
|
|
|
|
|
|
|
|
if "PROTON_USE_DXVK" in os.environ:
|
|
|
|
config_opts.append("dxvk")
|
2018-01-25 22:22:24 +03:00
|
|
|
|
2018-01-19 20:03:54 +03:00
|
|
|
basedir = os.path.dirname(sys.argv[0])
|
|
|
|
bindir = basedir + "/dist/bin/"
|
2018-02-14 22:59:35 +03:00
|
|
|
libdir = basedir + "/dist/lib"
|
|
|
|
lib64dir = basedir + "/dist/lib64"
|
2018-01-18 23:00:48 +03:00
|
|
|
wine_path = bindir + "/wine64"
|
|
|
|
|
2018-01-19 20:03:54 +03:00
|
|
|
#extract if needed
|
|
|
|
if not os.path.exists(basedir + "/dist") or \
|
|
|
|
not os.path.exists(basedir + "/dist/version") or \
|
|
|
|
not filecmp.cmp(basedir + "/version", basedir + "/dist/version"):
|
|
|
|
if os.path.exists(basedir + "/dist"):
|
|
|
|
shutil.rmtree(basedir + "/dist")
|
|
|
|
tar = tarfile.open(basedir + "/proton_dist.tar.gz", mode="r:gz")
|
|
|
|
tar.extractall(path=basedir + "/dist")
|
|
|
|
tar.close()
|
|
|
|
shutil.copy(basedir + "/version", basedir + "/dist/")
|
|
|
|
|
2018-01-18 23:00:48 +03:00
|
|
|
env = dict(os.environ)
|
|
|
|
|
|
|
|
env["WINEDEBUG"] = "-all"
|
2018-01-19 22:03:51 +03:00
|
|
|
lfile_path = None
|
2018-01-18 23:00:48 +03:00
|
|
|
|
2018-02-13 17:41:54 +03:00
|
|
|
#env["WINEDEBUG"] = "+timestamp,+tid,+seh"
|
2018-01-19 22:03:51 +03:00
|
|
|
#lfile_path = env["HOME"] + "/steam-" + env["SteamGameId"] + ".log"
|
|
|
|
|
2018-02-08 18:20:38 +03:00
|
|
|
if lfile_path is None:
|
|
|
|
lfile = open("/dev/null", "w")
|
|
|
|
else:
|
2018-01-19 22:03:51 +03:00
|
|
|
if os.path.exists(lfile_path):
|
|
|
|
os.remove(lfile_path)
|
|
|
|
lfile = open(lfile_path, "w")
|
2018-01-18 23:00:48 +03:00
|
|
|
|
|
|
|
if "LD_LIBRARY_PATH" in os.environ:
|
2018-02-14 22:59:35 +03:00
|
|
|
env["LD_LIBRARY_PATH"] = lib64dir + ":" + libdir + ":" + env["LD_LIBRARY_PATH"]
|
2018-01-18 23:00:48 +03:00
|
|
|
else:
|
2018-02-14 22:59:35 +03:00
|
|
|
env["LD_LIBRARY_PATH"] = lib64dir + ":" + libdir
|
|
|
|
|
|
|
|
env["WINEDLLPATH"] = lib64dir + "/wine:" + libdir + "/wine"
|
|
|
|
|
|
|
|
if "PATH" in os.environ:
|
|
|
|
env["PATH"] = bindir + ":" + env["PATH"]
|
|
|
|
else:
|
|
|
|
env["PATH"] = bindir
|
2018-01-18 23:00:48 +03:00
|
|
|
|
2018-01-25 22:22:24 +03:00
|
|
|
if not os.path.isdir(basedir + "/dist/share/default_pfx"):
|
|
|
|
#make default prefix
|
|
|
|
env["WINEPREFIX"] = basedir + "/dist/share/default_pfx"
|
|
|
|
run_wine([wine_path, "wineboot"])
|
|
|
|
run_wine([bindir + "/wineserver", "-w"])
|
|
|
|
|
|
|
|
prefix = os.environ["STEAM_COMPAT_DATA_PATH"] + "/pfx/"
|
|
|
|
env["WINEPREFIX"] = prefix
|
2018-01-18 23:00:48 +03:00
|
|
|
|
2018-01-22 22:59:42 +03:00
|
|
|
if not os.path.isdir(prefix):
|
|
|
|
#copy default prefix into place
|
|
|
|
shutil.copytree(basedir + "/dist/share/default_pfx", prefix, symlinks=True)
|
2018-01-18 23:00:48 +03:00
|
|
|
|
2018-01-22 22:59:42 +03:00
|
|
|
#copy steam files into place
|
|
|
|
steamdir = env["HOME"] + "/.steam/steam/legacycompat/"
|
|
|
|
dst = prefix + "/drive_c/Program Files (x86)/"
|
2018-01-23 17:03:43 +03:00
|
|
|
makedirs(dst + "Steam")
|
2018-01-22 22:59:42 +03:00
|
|
|
filestocopy = ["steamclient.dll",
|
|
|
|
"steamclient64.dll",
|
|
|
|
"Steam.dll"]
|
|
|
|
for f in filestocopy:
|
|
|
|
if os.path.isfile(steamdir + f):
|
|
|
|
shutil.copy(steamdir + f, dst + "Steam/" + f)
|
|
|
|
|
|
|
|
#copy openvr files into place
|
|
|
|
dst = prefix + "/drive_c/vrclient/bin/"
|
2018-01-23 17:03:43 +03:00
|
|
|
makedirs(dst)
|
2018-01-22 22:59:42 +03:00
|
|
|
shutil.copy(basedir + "/dist/lib/wine/fakedlls/vrclient.dll", dst)
|
|
|
|
shutil.copy(basedir + "/dist/lib64/wine/fakedlls/vrclient_x64.dll", dst)
|
2018-01-18 23:00:48 +03:00
|
|
|
|
|
|
|
#parse linux openvr config and present it in win32 format to the app.
|
|
|
|
#logic from openvr's CVRPathRegistry_Public::GetPaths
|
|
|
|
|
|
|
|
#check environment for overrides
|
|
|
|
vr_runtime = None
|
|
|
|
if "VR_OVERRIDE" in env:
|
|
|
|
vr_runtime = env["VR_OVERRIDE"]
|
|
|
|
env.pop("VR_OVERRIDE")
|
|
|
|
|
|
|
|
vr_config = None
|
|
|
|
if "VR_CONFIG_PATH" in env:
|
|
|
|
vr_config = env["VR_CONFIG_PATH"]
|
|
|
|
env.pop("VR_CONFIG_PATH")
|
|
|
|
|
|
|
|
vr_log = None
|
|
|
|
if "VR_LOG_PATH" in env:
|
|
|
|
vr_log = env["VR_LOG_PATH"]
|
|
|
|
env.pop("VR_LOG_PATH")
|
|
|
|
|
|
|
|
#load from json if needed
|
|
|
|
if vr_runtime is None or \
|
|
|
|
vr_config is None or \
|
|
|
|
vr_log is None:
|
|
|
|
try:
|
|
|
|
if "XDG_CONFIG_HOME" in env:
|
|
|
|
path = env["XDG_CONFIG_HOME"]
|
|
|
|
else:
|
|
|
|
path = env["HOME"] + "/.config"
|
|
|
|
path = path + "/openvr/openvrpaths.vrpath"
|
|
|
|
|
|
|
|
j = json.load(open(path, "r"))
|
|
|
|
|
|
|
|
if vr_runtime is None:
|
|
|
|
vr_runtime = j["runtime"][0]
|
|
|
|
|
|
|
|
if vr_config is None:
|
|
|
|
vr_config = j["config"][0]
|
|
|
|
|
|
|
|
if vr_log is None:
|
|
|
|
vr_log = j["log"][0]
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2018-01-23 17:03:43 +03:00
|
|
|
makedirs(prefix + "/drive_c/users/steamuser/Local Settings/Application Data/openvr")
|
2018-01-19 23:01:37 +03:00
|
|
|
|
2018-01-18 23:00:48 +03:00
|
|
|
#remove existing file
|
2018-01-19 23:01:37 +03:00
|
|
|
vrpaths_name = prefix + "/drive_c/users/steamuser/Local Settings/Application Data/openvr/openvrpaths.vrpath"
|
2018-01-18 23:00:48 +03:00
|
|
|
if os.path.exists(vrpaths_name):
|
|
|
|
os.remove(vrpaths_name)
|
|
|
|
|
|
|
|
#dump new file
|
|
|
|
if not vr_runtime is None:
|
|
|
|
try:
|
|
|
|
env["PROTON_VR_RUNTIME"] = vr_runtime
|
|
|
|
|
|
|
|
j = { "runtime": [ "C:\\vrclient\\", "C:\\vrclient" ] }
|
|
|
|
|
|
|
|
if not vr_config is None:
|
2018-01-19 22:03:51 +03:00
|
|
|
win_vr_config = subprocess.check_output([wine_path, "winepath", "-w", vr_config], env=env, stderr=open("/dev/null", "w"))
|
2018-01-18 23:00:48 +03:00
|
|
|
j["config"] = [ win_vr_config.strip() ]
|
|
|
|
|
|
|
|
if not vr_log is None:
|
2018-01-19 22:03:51 +03:00
|
|
|
win_vr_log = subprocess.check_output([wine_path, "winepath", "-w", vr_log], env=env, stderr=open("/dev/null", "w"))
|
2018-01-18 23:00:48 +03:00
|
|
|
j["log"] = [ win_vr_log.strip() ]
|
|
|
|
|
|
|
|
j["version"] = 1
|
|
|
|
j["jsonid"] = "vrpathreg"
|
|
|
|
|
|
|
|
json.dump(j, open(vrpaths_name, "w"), indent=2)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2018-02-09 20:03:59 +03:00
|
|
|
def make_dxvk_links(dll_dir, link_dir):
|
|
|
|
if os.path.lexists(link_dir + "/d3d11.dll"):
|
|
|
|
os.remove(link_dir + "/d3d11.dll")
|
|
|
|
if os.path.lexists(link_dir + "/dxgi.dll"):
|
|
|
|
os.remove(link_dir + "/dxgi.dll")
|
|
|
|
os.symlink(dll_dir + "/d3d11.dll", link_dir + "/d3d11.dll")
|
|
|
|
os.symlink(dll_dir + "/dxgi.dll", link_dir + "/dxgi.dll")
|
|
|
|
|
|
|
|
if "dxvk" in config_opts:
|
|
|
|
make_dxvk_links(basedir + "/dist/lib64/wine/dxvk/",
|
|
|
|
prefix + "drive_c/windows/system32")
|
|
|
|
make_dxvk_links(basedir + "/dist/lib/wine/dxvk/",
|
|
|
|
prefix + "drive_c/windows/syswow64")
|
|
|
|
env["WINEDLLOVERRIDES"] = "dxgi,d3d11=n"
|
|
|
|
else:
|
|
|
|
make_dxvk_links(basedir + "/dist/lib64/wine/",
|
|
|
|
prefix + "drive_c/windows/system32")
|
|
|
|
make_dxvk_links(basedir + "/dist/lib/wine/",
|
|
|
|
prefix + "drive_c/windows/syswow64")
|
|
|
|
|
2018-02-02 23:21:35 +03:00
|
|
|
#determine mode
|
|
|
|
if sys.argv[1] == "run":
|
|
|
|
#start target app
|
|
|
|
run_wine([wine_path] + sys.argv[2:])
|
|
|
|
elif sys.argv[1] == "translatepath":
|
|
|
|
#get windows path equivalent
|
|
|
|
path = subprocess.check_output([wine_path, "winepath", "-w", sys.argv[2]], env=env, stderr=open("/dev/null", "w"))
|
|
|
|
stdout.write(path)
|
|
|
|
else:
|
2018-02-08 23:13:05 +03:00
|
|
|
stdout.write("Need a verb.")
|
2018-02-02 23:21:35 +03:00
|
|
|
sys.exit(1)
|
2018-01-18 23:00:48 +03:00
|
|
|
|
|
|
|
sys.exit(0)
|