diff --git a/package_control/package_manager.py b/package_control/package_manager.py index 9c68a405..51b3c2c7 100644 --- a/package_control/package_manager.py +++ b/package_control/package_manager.py @@ -11,6 +11,7 @@ from concurrent import futures from io import BytesIO +from stat import S_IXUSR from threading import RLock from urllib.parse import urlencode @@ -54,6 +55,8 @@ 'https://sublime.wbond.net/repositories.json' ]) +ZIP_UNIX_SYSTEM = 3 + class PackageManager: @@ -1053,8 +1056,10 @@ def _extract_zip(self, name, zf, src_dir, dest_dir, extracted_files=None): with zf.open(info) as fsrc, open(dest, 'wb') as fdst: shutil.copyfileobj(fsrc, fdst) - # restore file mode - os.chmod(dest, info.external_attr >> 16) + # Restore executable permissions + if (info.create_system == ZIP_UNIX_SYSTEM + and (info.external_attr >> 16) & S_IXUSR): + os.chmod(dest, os.stat(dest).st_mode | S_IXUSR) except OSError as e: if e.errno == 5 or e.errno == 13: # permission denied