From 746cab7813eb1c298fedc6f0f80d86222c6537cf Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Tue, 15 Sep 2020 11:37:32 -0500 Subject: [PATCH] proton: Add write permissions to copied files We copy some read-only files into the prefix, which can cause problems (specifically, downgrading to some earlier Proton versions). --- proton | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/proton b/proton index 0eb28cdd..14edef87 100755 --- a/proton +++ b/proton @@ -10,6 +10,7 @@ import json import os import shutil import errno +import stat import subprocess import sys import tarfile @@ -54,15 +55,23 @@ def makedirs(path): #already exists pass -def try_copy(src, dst): +def try_copy(src, dst, add_write_perm=True): try: if os.path.isdir(dst): dstfile = dst + "/" + os.path.basename(src) if os.path.lexists(dstfile): os.remove(dstfile) - elif os.path.lexists(dst): - os.remove(dst) + else: + dstfile = dst + if os.path.lexists(dst): + os.remove(dst) + shutil.copy(src, dst) + + if add_write_perm: + new_mode = os.lstat(dstfile).st_mode | stat.S_IWUSR | stat.S_IWGRP + os.chmod(dstfile, new_mode) + 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