[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-06-22 Thread Felix C. Stegerman
Felix C. Stegerman added the comment: https://github.com/obfusk/apksigcopier currently produces reproducible ZIP files identical to those produced by apksigner using this code: DATETIMEZERO = (1980, 0, 0, 0, 0, 0) class ReproducibleZipInfo(zipfile.ZipInfo): """Reproducible ZipInfo

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-24 Thread Hans-Christoph Steiner
Hans-Christoph Steiner added the comment: > - For full reproducible builds you may have to write files to zipfiles in a > well-defined order. That already works fine now, we've been doing that with Python for years. But that leaves it up to the implemented to do. I suppose zipfile could

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-23 Thread Felix C. Stegerman
Felix C. Stegerman added the comment: > The __getattr__ hack is not needed. You can reset the flags in a different, > more straight forward way As mentioned, ZipFile._open_to_write() will modify the ZipInfo's .external_attr when it is set to 0. > I just found another specific example in

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-23 Thread Christian Heimes
Christian Heimes added the comment: The __getattr__ hack is not needed. You can reset the flags in a different, more straight forward way: class ReproducibleZipInfo(ZipInfo): __slots__ = () def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs)

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-22 Thread Felix C. Stegerman
Felix C. Stegerman added the comment: > external_attr == 0 may cause issues with permissions. That may be true in some scenarios, but not being able to set it to 0 means you can't create identical files to those produced by other tools -- like those used to generate APKs -- which do in fact

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-22 Thread Felix C. Stegerman
Change by Felix C. Stegerman : -- type: -> enhancement ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-22 Thread Felix C. Stegerman
Change by Felix C. Stegerman : -- components: +Library (Lib) ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-22 Thread Felix C. Stegerman
Change by Felix C. Stegerman : -- components: -IO, Library (Lib) versions: -Python 3.6, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker ___

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-22 Thread Felix C. Stegerman
Felix C. Stegerman added the comment: I've closed the PR for now. Using a carefully crafted ZipInfo object doesn't work because ZipFile modifies its .external_attr when set to 0. Using something like this quickly hacked together ZipInfo subclass does work: class

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-22 Thread Christian Heimes
Christian Heimes added the comment: zinfo = zipfile.ZipInfo() zinfo.date_time = (1980, 0, 0, 0, 0, 0) zinfo.create_system = 0 external_attr == 0 may cause issues with permissions. I do something like this in my reproducible tarfile code: if zinfo.isdir(): # 0755 + MS-DOS directory flag

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-22 Thread Christian Heimes
Christian Heimes added the comment: Hi, thanks for looking into reproducible builds. I have a few suggestions: - since it's a new feature, it cannot go into older releases. - zeroed is not a self-explanatory term. I suggest to find a term that does describe the result, not the internal

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-22 Thread Felix C. Stegerman
Felix C. Stegerman added the comment: I've created a draft PR; RFC :) Also: * setting the date to (1980,0,0,0,0,0) already works; * the main issue seems to be that external_attr cannot be 0 atm. -- ___ Python tracker

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-22 Thread Felix C. Stegerman
Change by Felix C. Stegerman : -- keywords: +patch pull_requests: +23737 stage: -> patch review pull_request: https://github.com/python/cpython/pull/24979 ___ Python tracker

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-20 Thread Felix C. Stegerman
Change by Felix C. Stegerman : -- nosy: +obfusk ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-20 Thread Robert Pollak
Change by Robert Pollak : -- nosy: +jondo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-18 Thread Hans-Christoph Steiner
Hans-Christoph Steiner added the comment: I just found another specific example in _open_to_write(). 0 is a valid value for zinfo.external_attr. But this code always forces 0 to something else: if not zinfo.external_attr: zinfo.external_attr = 0o600 << 16 #

[issue43547] support ZIP files with zeroed out fields (e.g. for reproducible builds)

2021-03-18 Thread Hans-Christoph Steiner
New submission from Hans-Christoph Steiner : It is now standard for Java JARs and Android APKs (both ZIP files) to zero out lots of the fields in the ZIP header. For example: * each file entry has the date set to zero * the create_system is always set to zero on all platforms zipfile