可复现的 jlink 构建

huangapple go评论79阅读模式
英文:

Reproducible builds with jlink

问题

一个经过jlink创建的精简JDK是我们应用程序的一部分。JDK镜像所需的模块很少更改。不幸的是,使用完全相同的jlink参数生成新的JDK镜像会导致不同的输出,因此在差分升级期间客户端必须一遍又一遍地下载相同的文件,这是不必要的。

以下是一个概念验证(PoC):

$ mkdir jdk-15a jdk-15b
$ tar xzf openjdk-15_linux-x64_bin.tar.gz --directory jdk-15a/
$ tar xzf openjdk-15_linux-x64_bin.tar.gz --directory jdk-15b/
$ jdk-15a/jdk-15/bin/jlink --compress=1 --module-path jdk-15a/jdk-15/jmods --add-modules java.base,jdk.management,jdk.unsupported,jdk.charsets --output output01
$ jdk-15b/jdk-15/bin/jlink --compress=1 --module-path jdk-15b/jdk-15/jmods --add-modules java.base,jdk.management,jdk.unsupported,jdk.charsets --output output02
$ md5sum output*/lib/modules
9ae5ae63df59593a0892c5ed411d7e59  output01/lib/modules
24b4af31553670799ab286ad1186329e  output02/lib/modules

(我正在多个构建服务器上使用类似JDK实例的jdk-15ajdk-15b目录。)

在这种情况下,是否有办法从jlink获得字节到字节相同的输出(可重复构建)

所用的JDK版本:

$ cat jdk-15a/jdk-15/release 
IMPLEMENTOR="Oracle Corporation"
JAVA_VERSION="15"
JAVA_VERSION_DATE="2020-09-15"
...
OS_ARCH="x86_64"
OS_NAME="Linux"
SOURCE=".:hg:e3f940bd3c8f"
英文:

A reduced JDK (created with jlink) is part of our application. The required modules for the JDK image is rarely changed. Unfortunately generating a new JDK image (with the exact same jlink parameters) results different output, so
clients have to download the same file again and again during the differential upgrade, unnecessarily.

Here is a PoC:

$ mkdir jdk-15a jdk-15b
$ tar xzf openjdk-15_linux-x64_bin.tar.gz --directory jdk-15a/
$ tar xzf openjdk-15_linux-x64_bin.tar.gz --directory jdk-15b/
$ jdk-15a/jdk-15/bin/jlink --compress=1 --module-path jdk-15a/jdk-15/jmods --add-modules java.base,jdk.management,jdk.unsupported,jdk.charsets --output output01
$ jdk-15b/jdk-15/bin/jlink --compress=1 --module-path jdk-15b/jdk-15/jmods --add-modules java.base,jdk.management,jdk.unsupported,jdk.charsets --output output02
$ md5sum output*/lib/modules
9ae5ae63df59593a0892c5ed411d7e59  output01/lib/modules
24b4af31553670799ab286ad1186329e  output02/lib/modules

(I'm using the jdk-15a and jdk-15b directories similar to JDK instances on multiple build servers.)

Is there any way to get byte-to-byte identical output (reproducible build) from jlink in this case?

Used JDK version:

$ cat jdk-15a/jdk-15/release 
IMPLEMENTOR="Oracle Corporation"
JAVA_VERSION="15"
JAVA_VERSION_DATE="2020-09-15"
...
OS_ARCH="x86_64"
OS_NAME="Linux"
SOURCE=".:hg:e3f940bd3c8f"

答案1

得分: 1

这是一个JDK的bug,在JDK-8252730中报告。

英文:

It's a JDK bug, reported at JDK-8252730.

huangapple
  • 本文由 发表于 2020年9月2日 16:29:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/63701637.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定