Bug 1752630 - Use UNIX permissions in packaged omnijars and XPIs. r=glandium

This unifies the ZIP permissions in omnijars and internal XPIs
produced by the packager directly and those repacked by l10n
single-repacks.

Differential Revision: https://phabricator.services.mozilla.com/D137340
This commit is contained in:
Nick Alexander 2022-03-04 16:52:45 +00:00
Родитель c539f17573
Коммит 77ecd3dc6b
1 изменённых файлов: 13 добавлений и 7 удалений

Просмотреть файл

@ -611,8 +611,9 @@ class JarWriter(object):
respectively, to JAR_DEFLATE and JAR_STORED.
When the data should be compressed, it is only really compressed if
the compressed size is smaller than the uncompressed size.
The mode option gives the unix permissions that should be stored
for the jar entry.
The mode option gives the unix permissions that should be stored for the
jar entry, which defaults to 0o100644 (regular file, u+rw, g+r, o+r) if
not specified.
If a duplicated member is found skip_duplicates will prevent raising
an exception if set to True.
The given data may be a buffer, a file-like instance, a Deflater or a
@ -646,11 +647,16 @@ class JarWriter(object):
# Fill a central directory entry for this new member.
entry = JarCdirEntry()
entry["creator_version"] = 20
if mode is not None:
# Set creator host system (upper byte of creator_version)
# to 3 (Unix) so mode is honored when there is one.
entry["creator_version"] |= 3 << 8
entry["external_attr"] = (mode & 0xFFFF) << 16
if mode is None:
# If no mode is given, default to u+rw, g+r, o+r.
mode = 0o000644
if not mode & 0o777000:
# If no file type is given, default to regular file.
mode |= 0o100000
# Set creator host system (upper byte of creator_version) to 3 (Unix) so
# mode is honored when there is one.
entry["creator_version"] |= 3 << 8
entry["external_attr"] = (mode & 0xFFFF) << 16
if deflater.compressed:
entry["min_version"] = 20 # Version 2.0 supports deflated streams
entry["general_flag"] = 2 # Max compression