mirror of
https://github.com/ValveSoftware/Proton.git
synced 2025-03-14 14:30:24 +03:00
proton: Track prefix files
This commit is contained in:
parent
77ddc97f5e
commit
dff92b79a6
@ -673,6 +673,7 @@ if [ "$PACKAGE" = true ]; then
|
||||
cp -a toolmanifest.vdf dist/
|
||||
cp -a filelock.py dist/
|
||||
cp -a user_settings.sample.py dist/
|
||||
cp -a proton_3.7_tracked_files dist/
|
||||
if [ "$PLATFORM" == "Darwin" ]; then
|
||||
cp -a dist.LICENSE.osx dist/LICENSE
|
||||
sed -e 's/@PYTHON_NAME@/python/' proton.in > dist/proton
|
||||
|
43
proton.in
43
proton.in
@ -31,6 +31,30 @@ def log(msg):
|
||||
sys.stderr.write(PFX + msg + os.linesep)
|
||||
sys.stderr.flush()
|
||||
|
||||
def remove_tracked_files(prefix):
|
||||
if not os.path.exists(prefix + "/tracked_files"):
|
||||
log("Prefix has no tracked_files??")
|
||||
return
|
||||
|
||||
with open(prefix + "/tracked_files", "r") as tracked_files:
|
||||
dirs = []
|
||||
for f in tracked_files:
|
||||
path = prefix + "/pfx/" + f.strip()
|
||||
if os.path.exists(path):
|
||||
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
|
||||
|
||||
os.remove(prefix + "/tracked_files")
|
||||
os.remove(prefix + "/version")
|
||||
|
||||
def upgrade_pfx(old_ver):
|
||||
if old_ver == CURRENT_PREFIX_VERSION:
|
||||
return
|
||||
@ -41,6 +65,15 @@ def upgrade_pfx(old_ver):
|
||||
return
|
||||
|
||||
old_proton_ver, old_prefix_ver = old_ver.split('-')
|
||||
new_proton_ver, new_prefix_ver = CURRENT_PREFIX_VERSION.split('-')
|
||||
|
||||
if old_proton_ver != new_proton_ver:
|
||||
log("Removing old prefix")
|
||||
if old_proton_ver == "3.7" and not os.path.exists(os.environ["STEAM_COMPAT_DATA_PATH"] + "/tracked_files"):
|
||||
#proton 3.7 did not generate tracked_files, so copy it into place first
|
||||
shutil.copy(basedir + "/proton_3.7_tracked_files", os.environ["STEAM_COMPAT_DATA_PATH"] + "/tracked_files")
|
||||
remove_tracked_files(os.environ["STEAM_COMPAT_DATA_PATH"])
|
||||
return
|
||||
|
||||
if old_proton_ver == "3.7" and old_prefix_ver == "1":
|
||||
if not os.path.exists(prefix + "/drive_c/windows/syswow64/kernel32.dll"):
|
||||
@ -64,11 +97,15 @@ def real_copy(src, dst):
|
||||
else:
|
||||
shutil.copy(src,dst)
|
||||
|
||||
def mergedirs(src, dst):
|
||||
def mergedirs(src, dst, tracked_files):
|
||||
for src_dir, dirs, files in os.walk(src):
|
||||
rel_dir = src_dir.replace(src, "", 1).lstrip('/')
|
||||
if len(rel_dir) > 0:
|
||||
rel_dir = rel_dir + "/"
|
||||
dst_dir = src_dir.replace(src, dst, 1)
|
||||
if not os.path.exists(dst_dir):
|
||||
os.makedirs(dst_dir)
|
||||
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_)
|
||||
@ -79,6 +116,7 @@ def mergedirs(src, dst):
|
||||
dst_file = os.path.join(dst_dir, file_)
|
||||
if not os.path.exists(dst_file):
|
||||
real_copy(src_file, dst_file)
|
||||
tracked_files.write(rel_dir + file_ + "\n")
|
||||
|
||||
if not ("STEAM_COMPAT_DATA_PATH" in os.environ):
|
||||
log("No compat data path?")
|
||||
@ -188,7 +226,8 @@ with prefix_lock:
|
||||
|
||||
if not os.path.exists(prefix + "/user.reg"):
|
||||
#copy default prefix into place
|
||||
mergedirs(basedir + "/dist/share/default_pfx", prefix)
|
||||
mergedirs(basedir + "/dist/share/default_pfx", prefix,
|
||||
open(os.environ["STEAM_COMPAT_DATA_PATH"] + "/tracked_files", "w"))
|
||||
|
||||
with open(version_file, "w") as f:
|
||||
f.write(CURRENT_PREFIX_VERSION + "\n")
|
||||
|
1888
proton_3.7_tracked_files
Normal file
1888
proton_3.7_tracked_files
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user