Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve zip file reproducibility #1602

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stevedlawrence
Copy link
Contributor

We currently use the ZipArchiveEntry(File, String) constructor when creating a zip file entry for Universal/packageBin. This constructor reads mtime, atime, and ctime from the File and adds them to the 5455 extended header in the zip file. When we call setTime on the entry, it only changes the mtime field--the atime and ctime are the same values from the file and are likely to be different across builds and break reproducibility.

To fix this, we use the ZipArchiveEntry(String) constructor which does not read any file metadata, and only uses information we directly provided to it. We now provie the source epoch via setLastModifiedTime since that continues to use the 5455 extended header but only for mtime. We also ensure directories have a trailing slash in the entry name, since that was previously done by the other constructor.

With this change, when using SOURCE_DATE_EPOCH, zip files created with Universal/packageBin are now byte-for-byte exactly the same.

We currently use the ZipArchiveEntry(File, String) constructor when
creating a zip file entry for Universal/packageBin. This constructor
reads mtime, atime, and ctime from the File and adds them to the 5455
extended header in the zip file. When we call setTime on the entry, it
only changes the mtime field--the atime and ctime are the same values
from the file and are likely to be different across builds and break
reproducibility.

To fix this, we use the ZipArchiveEntry(String) constructor which does
not read any file metadata, and only uses information we directly
provided to it. We now provie the source epoch via setLastModifiedTime
since that continues to use the 5455 extended header but only for mtime.
We also ensure directories have a trailing slash in the entry name,
since that was previously done by the other constructor.

With this change, when using SOURCE_DATE_EPOCH, zip files created with
Universal/packageBin are now byte-for-byte exactly the same.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant