Commit 75b669ed authored by Nirbheek Chauhan's avatar Nirbheek Chauhan 🐜
Browse files

cerbero/hacks: Ensure that zipfile sets permission on extract

Fix a years-old bug in Python's zipfile module:

Without this, the extracted Android NDK does not have executable
permissions on any binaries and is unusable.
parent 968343ef
......@@ -145,3 +145,24 @@ elif'curl'):
# Fallback. TODO: make this the default and remove curl/wget dependency =
### Python ZipFile module bug ###
# zipfile.ZipFile.extractall() does not preserve permissions
import zipfile
from zipfile import ZipFile as zipfile_ZipFile
class ZipFile(zipfile_ZipFile):
def _extract_member(self, member, targetpath, pwd):
if not isinstance(member, zipfile.ZipInfo):
member = self.getinfo(member)
path = super()._extract_member(member, targetpath, pwd)
attr = member.external_attr >> 16
if attr != 0:
os.chmod(path, attr)
return path
zipfile.ZipFile = ZipFile
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment