From e18366cdbce89a567b6728b95f072c4d3e236e95 Mon Sep 17 00:00:00 2001 From: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:52:41 +1300 Subject: [PATCH] Preserve file permissions in zap_download.py (#30835) --- scripts/tools/zap/zap_download.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/tools/zap/zap_download.py b/scripts/tools/zap/zap_download.py index c2f6f38235fc0c..72dea27048a0c6 100755 --- a/scripts/tools/zap/zap_download.py +++ b/scripts/tools/zap/zap_download.py @@ -126,7 +126,10 @@ def _SetupReleaseZap(install_directory: str, zap_version: str): z = zipfile.ZipFile(io.BytesIO(r.content)) logging.info("Data downloaded, extracting ...") - z.extractall(install_directory) + # extractall() does not preserve permissions (https://github.com/python/cpython/issues/59999) + for entry in z.filelist: + path = z.extract(entry, install_directory) + os.chmod(path, (entry.external_attr >> 16) & 0o777) logging.info("Done extracting.")