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

Reproducible ZIP timestamps are dependent on machine timezone #926

Closed
LostLuma opened this issue Jul 6, 2023 · 5 comments · Fixed by #952
Closed

Reproducible ZIP timestamps are dependent on machine timezone #926

LostLuma opened this issue Jul 6, 2023 · 5 comments · Fixed by #952

Comments

@LostLuma
Copy link

LostLuma commented Jul 6, 2023

Currently when building with reproducibility enabled the timestamps inside the archive are dependent on the timezone of the machine building the mod. This diverges from the way Gradle itself handles this, as it always outputs a consistent timestamp of 1980-02-01 00:00, regardless of build environment (at least from my testing).

A few examples obtained using unzip -v modid-1.0.0.jar on the example mod built in different environments:

Built via GHA, where I assume the machine time zone is UTC:

Archive:  modid-1.0.0-actions-build.jar
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
     208  Defl:N      148  29% 1980-02-01 01:00 ba7d7dad  modid.mixins.json

And from building the exact same commit on my local machine (currently CEST?):

 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
     208  Defl:N      148  29% 1980-02-01 00:00 ba7d7dad  modid.mixins.json

I assume this is a difference in how timestamps are handled by Java's built in ZIP-related library and the apache compress library which is used by Gradle instead, since the constant timestamp used is exactly the same.

@LostLuma
Copy link
Author

LostLuma commented Jul 18, 2023

The timestamp that piece of code generates is identical, however Gradle uses the apache-commons-compress library to construct the archive (and it also sets the exact same file flags regardless of operating system!) while Loom uses java's built-in zip library. The resulting timestamp in the archive is thus different with Loom (as well as the file flags if built on a different operating system).

@modmuss50
Copy link
Member

Ah, I see thats a little bit silly how they differ. I will have to take a deeper dive into Java's zip library to see if there is a way around this, id prefer not to use a 3rd party lib if we can help it.

@LostLuma
Copy link
Author

Good luck! I tried around with that a bit because I wanted to submit a PR to fix this originally but didn't end up anywhere sadly, and was unsure whether introducing another dependency would be wanted.

@modmuss50
Copy link
Member

Another option might be to look into seeing if its possible to use the gradle API to do this. Worse case we can add another dependency, it just seems a bit silly to need it for this.

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 a pull request may close this issue.

2 participants