英文:
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-15a
和jdk-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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论