jinterface: Build determenistic OtpErlang.jar#5580
jinterface: Build determenistic OtpErlang.jar#5580avtobiff wants to merge 1 commit intoerlang:maintfrom
Conversation
Handroll lib/jinterface/priv/OtpErlang.jar to support a deterministic build. Method used: Manually craft META-INF/MANIFEST.MF, touch all JAR file contents with the same timestamp across builds, generate a deterministic ZIP file (the JAR file). Deterministic build not support on win32 target for now. See erlang#4417 Signed-off-by: Per Andersson <avtobiff@foo.nu>
a93d9c1 to
fb5644f
Compare
|
With my limited java knowledge, it looks a little bit iffy to create your own jar file like this with a hard coded manifest. Would it not be less hackish to let |
|
Before commenting on the method suggested in this PR, Is this preferable? If so, reproducible builds should probably be [0] https://reproducible-builds.org/docs/source-date-epoch/
The manifest generated by The only additional thing that would be included is A default manifest only includes However, the manifest specification includes a required main-section,
My reasoning was that it was not important information to convey, What do others do?
The method suggested in this PR was inspired by Gary Rowe's blogpost I don't think creating a JAR file with Generating the jar file with zip will not add the JAR file magic (0xCAFE), $ file OtpErlang.jar
OtpErlang.jar: Zip archive data, at least v1.0 to extract, compression method=store
$ file OtpErlang.jar.jar
OtpErlang.jar.jar: Java archive data (JAR)However, this doesn't seem to bother neither $ jar -tf OtpErlang.jar
META-INF/
META-INF/MANIFEST.MF
com/ericsson/otp/erlang/
com/ericsson/otp/erlang/OtpMD5.class
(...)
$ cat Test.javaimport com.ericsson.otp.erlang.*;
public class Test { public static void main(String args[]) { ; } }$ javac -classpath OtpErlang.jar Test.java
$ echo $?
0
$ file Test.class
Test.class: compiled Java class data, version 62.0Trying to use an empty (i.e. corrupted jar) file generates the $ touch Empty.jar
$ javac -classpath Empty.jar Test.java
error: error reading Empty.jar; zip file is emptyAnother option is to use [1] https://docs.oracle.com/en/java/javase/17/docs/specs/jar/jar.html#main-attributes |
|
Ok, I yield about handrolled manifest. However, I discovered a disadvantage with the current use of |
I know it was a handfull, but I had to do all this research myself I would like to keep the jar file magic, not particularly content
I'll investigate if the jar can be assembled so fast incremental builds I would also like to raise that I do not have any possibility to test this on What about the outstanding question about |
|
I'm leaning towards using It could be an optional build dependency; if you want deterministic builds of jinterface, install strip-nondeterminism. |
|
I can redo this PR to use Maybe it should still be configurable to use it or not though? Is it ok to check if strip-nondeterminism --timestamp $SOURCE_DATE_EPOCH OtpErlang.jar |
Why would you want to avoid deterministic build? I don't really see the point with SOURCE_DATE_EPOCH here. Are the file timestamps in the jar file really used for anything? But if you see some use for it, ok. |
|
When i Googled around I saw this
https://bugs.openjdk.java.net/browse/JDK-8276667 which seems to be an
update of the jar command to respect SOURCE_DATE_EPOCH in order to
support reproducible builds of jar archives.
…On Thu, Jan 13, 2022 at 8:53 PM Sverker Eriksson ***@***.***> wrote:
Maybe it should still be configurable to use it or not though?
I have it installed but might not want to uninstall just to skip
building a deterministic build.
Why would you want to avoid deterministic build?
I don't really see the point with SOURCE_DATE_EPOCH here. Are the file
timestamps in the jar file really used for anything? But if you see some
use for it, ok.
—
Reply to this email directly, view it on GitHub
<#5580 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABFWSDDOBKFTDB56MYVZULUV4USFANCNFSM5LIY4GRA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
We could wait for that and this becomes a documentation |
|
It seems like There are more fixes related to [0], e.g. archive file ordering and I'll reiterate this PR to use [0] https://bugs.openjdk.java.net/browse/JDK-8276766 |
This is a simpler alternative to PR erlang#5580 It lets us get closer to reproducible builds for erlang. See https://reproducible-builds.org/ for why this is good. Note: when using options with double-dash, jar does not understand merged options such as -cf anymore so we have to split them up to work again. Closes: erlang#5580
This is a simpler alternative to PR erlang#5580 It lets us get closer to reproducible builds for erlang. See https://reproducible-builds.org/ for why this is good. Note: when using options with double-dash, jar does not understand merged options such as -cf anymore so we have to split them up to work again. Closes erlang#5580
This is a simpler alternative to PR erlang#5580 It lets us get closer to reproducible builds for erlang. See https://reproducible-builds.org/ for why this is good. Note: when using options with double-dash, jar does not understand merged options such as -cf anymore so we have to split them up to work again. Note2: we hardcode the date, because the complexity of converting seconds to a date string to work on all OSes is not worth it. Closes erlang#5580
This is a simpler alternative to PR erlang#5580 It lets us get closer to reproducible builds for erlang. See https://reproducible-builds.org/ for why this is good. Note: when using options with double-dash, jar does not understand merged options such as -cf anymore so we have to split them up to work again. Note2: we hardcode the date, because the complexity of converting seconds to a date string to work on all OSes is not worth it. Closes erlang#5580
This is a simpler alternative to PR erlang#5580 It lets us get closer to reproducible builds for erlang. See https://reproducible-builds.org/ for why this is good. Note: when using options with double-dash, jar does not understand merged options such as -cf anymore so we have to split them up to work again. Note2: we hardcode the date, because the complexity of converting seconds to a date string to work on all OSes is not worth it. Closes erlang#5580
Handroll lib/jinterface/priv/OtpErlang.jar to support a deterministic
build.
Method used: Manually craft META-INF/MANIFEST.MF, touch all JAR file
contents with the same timestamp across builds, generate a deterministic
ZIP file (the JAR file).
Deterministic build not support on win32 target for now.
See #4417
Signed-off-by: Per Andersson avtobiff@foo.nu