mirror of
https://github.com/ValveSoftware/Proton.git
synced 2025-01-13 15:18:13 +03:00
proton: Move some logic into Proton class
This commit is contained in:
parent
5c9dd25e81
commit
c8639f6132
43
proton
43
proton
@ -189,6 +189,27 @@ class Proton:
|
|||||||
def path(self, d):
|
def path(self, d):
|
||||||
return self.base_dir + d
|
return self.base_dir + d
|
||||||
|
|
||||||
|
def extract_tarball(self):
|
||||||
|
with self.dist_lock:
|
||||||
|
if not os.path.exists(self.dist_dir) or \
|
||||||
|
not os.path.exists(self.path("dist/version")) or \
|
||||||
|
not filecmp.cmp(self.version_file, self.path("dist/version")):
|
||||||
|
if os.path.exists(self.dist_dir):
|
||||||
|
shutil.rmtree(self.dist_dir)
|
||||||
|
tar = tarfile.open(self.path("proton_dist.tar.gz"), mode="r:gz")
|
||||||
|
tar.extractall(path=self.dist_dir)
|
||||||
|
tar.close()
|
||||||
|
try_copy(self.version_file, self.dist_dir)
|
||||||
|
|
||||||
|
def make_default_prefix(self, env):
|
||||||
|
with self.dist_lock:
|
||||||
|
local_env = dict(env)
|
||||||
|
if not os.path.isdir(self.default_pfx_dir):
|
||||||
|
#make default prefix
|
||||||
|
local_env["WINEPREFIX"] = self.default_pfx_dir
|
||||||
|
run_wine([self.wine, "wineboot"])
|
||||||
|
run_wine([self.wineserver, "-w"])
|
||||||
|
|
||||||
class CompatData:
|
class CompatData:
|
||||||
def __init__(self, compatdata):
|
def __init__(self, compatdata):
|
||||||
self.base_dir = compatdata + "/"
|
self.base_dir = compatdata + "/"
|
||||||
@ -205,19 +226,10 @@ if not "STEAM_COMPAT_DATA_PATH" in os.environ:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
g_proton = Proton(os.path.dirname(sys.argv[0]))
|
g_proton = Proton(os.path.dirname(sys.argv[0]))
|
||||||
g_compatdata = CompatData(os.environ["STEAM_COMPAT_DATA_PATH"])
|
|
||||||
|
|
||||||
#extract if needed
|
g_proton.extract_tarball()
|
||||||
with g_proton.dist_lock:
|
|
||||||
if not os.path.exists(g_proton.dist_dir) or \
|
g_compatdata = CompatData(os.environ["STEAM_COMPAT_DATA_PATH"])
|
||||||
not os.path.exists(g_proton.path("dist/version")) or \
|
|
||||||
not filecmp.cmp(g_proton.version_file, g_proton.path("dist/version")):
|
|
||||||
if os.path.exists(g_proton.dist_dir):
|
|
||||||
shutil.rmtree(g_proton.dist_dir)
|
|
||||||
tar = tarfile.open(g_proton.path("proton_dist.tar.gz"), mode="r:gz")
|
|
||||||
tar.extractall(path=g_proton.dist_dir)
|
|
||||||
tar.close()
|
|
||||||
try_copy(g_proton.version_file, g_proton.dist_dir)
|
|
||||||
|
|
||||||
env = dict(os.environ)
|
env = dict(os.environ)
|
||||||
dlloverrides = {
|
dlloverrides = {
|
||||||
@ -250,12 +262,7 @@ if "PATH" in os.environ:
|
|||||||
else:
|
else:
|
||||||
env["PATH"] = g_proton.bin_dir
|
env["PATH"] = g_proton.bin_dir
|
||||||
|
|
||||||
with g_proton.dist_lock:
|
g_proton.make_default_prefix(env)
|
||||||
if not os.path.isdir(g_proton.default_pfx_dir):
|
|
||||||
#make default prefix
|
|
||||||
env["WINEPREFIX"] = g_proton.default_pfx_dir
|
|
||||||
run_wine([g_proton.wine_bin, "wineboot"])
|
|
||||||
run_wine([g_proton.wineserver_bin, "-w"])
|
|
||||||
|
|
||||||
env["WINEPREFIX"] = g_compatdata.prefix_dir
|
env["WINEPREFIX"] = g_compatdata.prefix_dir
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user