Toggle diff (348 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 155b9e7740..791e5a85aa 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1664,7 +1664,15 @@ dist_patch_DATA = \
%D%/packages/patches/openjdk-9-module-reproducibility.patch \
%D%/packages/patches/openjdk-9-module2-reproducibility.patch \
%D%/packages/patches/openjdk-9-module3-reproducibility.patch \
+ %D%/packages/patches/openjdk-10-char-reproducibility.patch \
+ %D%/packages/patches/openjdk-10-classlist-reproducibility.patch \
+ %D%/packages/patches/openjdk-10-corba-reproducibility.patch \
%D%/packages/patches/openjdk-10-idlj-reproducibility.patch \
+ %D%/packages/patches/openjdk-10-jar-reproducibility.patch \
+ %D%/packages/patches/openjdk-10-jtask-reproducibility.patch \
+ %D%/packages/patches/openjdk-10-module-reproducibility.patch \
+ %D%/packages/patches/openjdk-10-module3-reproducibility.patch \
+ %D%/packages/patches/openjdk-10-module4-reproducibility.patch \
%D%/packages/patches/openjdk-10-pointer-comparison.patch \
%D%/packages/patches/openjdk-10-setsignalhandler.patch \
%D%/packages/patches/openjdk-15-xcursor-no-dynamic.patch \
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index ad2af44229..14e9b1f653 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -1098,7 +1098,15 @@ (define-public openjdk10
(base32
"0i47ar8lxzjrkkiwbzybfxs473390h4jq9ahm3xqdvy5zpchxy3y"))
(patches (search-patches
+ "openjdk-10-char-reproducibility.patch"
+ "openjdk-10-classlist-reproducibility.patch"
+ "openjdk-10-corba-reproducibility.patch"
"openjdk-10-idlj-reproducibility.patch"
+ "openjdk-10-module-reproducibility.patch"
+ "openjdk-10-module3-reproducibility.patch"
+ "openjdk-10-module4-reproducibility.patch"
+ "openjdk-10-jar-reproducibility.patch"
+ "openjdk-10-jtask-reproducibility.patch"
"openjdk-10-pointer-comparison.patch"
"openjdk-10-setsignalhandler.patch"))))
(arguments
@@ -1112,6 +1120,11 @@ (define-public openjdk10
(substitute* "make/data/blacklistedcertsconverter/blacklisted.certs.pem"
(("^#!.*") "#! java BlacklistedCertsConverter SHA-256\n"))
#t))
+ (add-after 'unpack 'remove-timestamping
+ (lambda _
+ (substitute* "./src/hotspot/share/runtime/vm_version.cpp"
+ (("__DATE__") "")
+ (("__TIME__") ""))))
(replace 'configure
(lambda* (#:key inputs outputs #:allow-other-keys)
(invoke "bash" "./configure"
diff --git a/gnu/packages/patches/openjdk-10-char-reproducibility.patch b/gnu/packages/patches/openjdk-10-char-reproducibility.patch
new file mode 100644
index 0000000000..a7932678af
--- /dev/null
+++ b/gnu/packages/patches/openjdk-10-char-reproducibility.patch
@@ -0,0 +1,12 @@
+Danny
+--- orig/jdk-6fa770f9f8ab/make/jdk/src/classes/build/tools/generatecharacter/GenerateCharacter.java 2022-04-13 19:24:10.211683257 +0200
++++ jdk-6fa770f9f8ab/make/jdk/src/classes/build/tools/generatecharacter/GenerateCharacter.java 2022-04-13 22:51:50.680487330 +0200
+@@ -693,7 +693,7 @@
+ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(theOutputFileName)));
+ out.println(commentStart +
+ " This file was generated AUTOMATICALLY from a template file " +
+- new java.util.Date() + commentEnd);
++ (System.getenv("SOURCE_DATE_EPOCH") == null ? new java.util.Date() : new java.util.Date(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")))) + commentEnd);
+ int marklen = commandMarker.length();
+ LOOP: while(true) {
+ try {
diff --git a/gnu/packages/patches/openjdk-10-classlist-reproducibility.patch b/gnu/packages/patches/openjdk-10-classlist-reproducibility.patch
new file mode 100644
index 0000000000..e1292ba82d
--- /dev/null
+++ b/gnu/packages/patches/openjdk-10-classlist-reproducibility.patch
@@ -0,0 +1,27 @@
+--- orig/jdk-6fa770f9f8ab/make/GenerateLinkOptData.gmk 2022-04-04 17:16:29.365930149 +0200
++++ jdk-6fa770f9f8ab/make/GenerateLinkOptData.gmk 2022-04-04 17:16:54.954624358 +0200
+@@ -61,11 +61,12 @@
+ $(call MakeDir, $(LINK_OPT_DIR))
+ $(call LogInfo, Generating $(patsubst $(OUTPUTDIR)/%, %, $@))
+ $(call LogInfo, Generating $(patsubst $(OUTPUTDIR)/%, %, $(JLI_TRACE_FILE)))
+- $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@ \
++ $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@.tmp \
+ -Djava.lang.invoke.MethodHandle.TRACE_RESOLVE=true \
+ -cp $(SUPPORT_OUTPUTDIR)/classlist.jar \
+ build.tools.classlist.HelloClasslist \
+ $(LOG_DEBUG) 2>&1 > $(JLI_TRACE_FILE)
++ sort $@.tmp > $@
+
+ # The jli trace is created by the same recipe as classlist. By declaring these
+ # dependencies, make will correctly rebuild both jli trace and classlist
+--- orig/jdk-6fa770f9f8ab/make/gendata/Gendata-jdk.compiler.gmk 2022-04-13 19:24:10.191682716 +0200
++++ jdk-6fa770f9f8ab/make/gendata/Gendata-jdk.compiler.gmk 2022-04-13 20:58:57.891368216 +0200
+@@ -83,6 +83,8 @@
+ $(CT_MODULESOURCEPATH) \
+ $(CT_MODULES) \
+ >$(@D)/A/system-modules
++ # Make files reproducible
++ find $(@D) -exec $(TOUCH) -h -c -t 197001010000.01 {} \;
+ $(TOUCH) $@
+
+ # Can't generate ct.sym directly into modules libs as the SetupJarArchive macro
diff --git a/gnu/packages/patches/openjdk-10-corba-reproducibility.patch b/gnu/packages/patches/openjdk-10-corba-reproducibility.patch
new file mode 100644
index 0000000000..bd5ce1fd2b
--- /dev/null
+++ b/gnu/packages/patches/openjdk-10-corba-reproducibility.patch
@@ -0,0 +1,12 @@
+Danny
+--- orig/jdk-6fa770f9f8ab/make/corba/src/classes/build/tools/logutil/MC.java 2022-04-13 19:24:10.111680549 +0200
++++ jdk-6fa770f9f8ab/make/corba/src/classes/build/tools/logutil/MC.java 2022-04-13 22:51:13.399462259 +0200
+@@ -154,7 +154,7 @@
+ groupName);
+ pw.println("//");
+ pw.printMsg("// Generated by MC.java version @, DO NOT EDIT BY HAND!", VERSION);
+- pw.printMsg("// Generated from input file @ on @", inFile, new Date());
++ pw.printMsg("// Generated from input file @ on @", inFile, System.getenv("SOURCE_DATE_EPOCH") == null ? new Date() : new Date(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH"))));
+ pw.println();
+ }
+
diff --git a/gnu/packages/patches/openjdk-10-jar-reproducibility.patch b/gnu/packages/patches/openjdk-10-jar-reproducibility.patch
new file mode 100644
index 0000000000..176eedfce6
--- /dev/null
+++ b/gnu/packages/patches/openjdk-10-jar-reproducibility.patch
@@ -0,0 +1,103 @@
+diff -ru orig/jdk-6fa770f9f8ab/make/common/JarArchive.gmk jdk-6fa770f9f8ab/make/common/JarArchive.gmk
+--- orig/jdk-6fa770f9f8ab/make/common/JarArchive.gmk 2022-04-13 19:24:10.107680441 +0200
++++ jdk-6fa770f9f8ab/make/common/JarArchive.gmk 2022-04-13 19:31:18.031271019 +0200
+@@ -251,12 +251,14 @@
+ $(ECHO) "Main-Class: $$(strip $$($1_JARMAIN))" >> $$($1_MANIFEST_FILE) $$(NEWLINE)) \
+ $$(if $$($1_EXTRA_MANIFEST_ATTR), \
+ $(PRINTF) "$$($1_EXTRA_MANIFEST_ATTR)\n" >> $$($1_MANIFEST_FILE) $$(NEWLINE)) \
++ $(TOUCH) -h -c -t 197001010000.00 $$($1_MANIFEST_FILE) $$(NEWLINE) \
+ $(ECHO) Creating $$($1_NAME) $$(NEWLINE) \
+ $$($1_JAR_CMD) $$($1_JAR_CREATE_OPTIONS) $$@ $$($1_MANIFEST_FILE) $$(NEWLINE) \
+ $$($1_SCAPTURE_CONTENTS) \
+ $$($1_SCAPTURE_METAINF) \
+ $$($1_SUPDATE_CONTENTS) \
+- $$($1_JARINDEX) && true \
++ $$($1_JARINDEX) && true $$(NEWLINE) \
++ d="`mktemp -d`" && $(CP) -f $$@ "$$$$d/a.jar" && (cd "$$$$d" && unzip a.jar META-INF/MANIFEST.MF && $(TOUCH) -h -c -t 197001010000.00 META-INF && $(TOUCH) -h -c -t 197001010000.00 META-INF/MANIFEST.MF && (zip --symlinks -0 -X a.jar META-INF META-INF/MANIFEST.MF; zip --symlinks -0 -X a.jar META-INF META-INF/MANIFEST.MF)) && $(CP) -f "$$$$d/a.jar" $$@ \
+ , \
+ $(ECHO) Modifying $$($1_NAME) $$(NEWLINE) \
+ $$($1_CAPTURE_CONTENTS) \
+diff -ru orig/jdk-6fa770f9f8ab/make/JrtfsJar.gmk jdk-6fa770f9f8ab/make/JrtfsJar.gmk
+--- orig/jdk-6fa770f9f8ab/make/JrtfsJar.gmk 2022-04-13 19:24:10.091680007 +0200
++++ jdk-6fa770f9f8ab/make/JrtfsJar.gmk 2022-04-13 19:29:30.044346222 +0200
+@@ -57,13 +57,18 @@
+ # file will not be copied unless META-INF/services would also be added to the INCLUDES.
+ # Adding META-INF/services would include all files in that directory when only the one
+ # is needed, which is why this explicit copy is defined instead.
+-$(eval $(call SetupCopyFiles, COPY_JIMAGE_SERVICE_PROVIDER, \
++$(eval $(call SetupCopyFiles, COPY_JIMAGE_SERVICE_PROVIDER, \
+ SRC := $(TOPDIR)/src/java.base/share/classes, \
+ DEST := $(SUPPORT_OUTPUTDIR)/jrtfs_classes, \
+ FILES := META-INF/services/java.nio.file.spi.FileSystemProvider))
+
++.PHONY: $(COPY_JIMAGE_SERVICE_PROVIDER)_fix
++$(COPY_JIMAGE_SERVICE_PROVIDER)_fix: $(COPY_JIMAGE_SERVICE_PROVIDER)
++ find $(SUPPORT_OUTPUTDIR)/jrtfs_classes -exec $(TOUCH) -h -c -t 197001010000.00 {} \;
++ $(TOUCH) -h -c -t 197001010000.00 $(SUPPORT_OUTPUTDIR)/java-main-manifest.mf
++
+ $(eval $(call SetupJarArchive,BUILD_JRTFS_JAR, \
+- DEPENDENCIES := $(BUILD_JRTFS) $(COPY_JIMAGE_SERVICE_PROVIDER), \
++ DEPENDENCIES := $(BUILD_JRTFS) $(COPY_JIMAGE_SERVICE_PROVIDER)_fix, \
+ SRCS := $(SUPPORT_OUTPUTDIR)/jrtfs_classes, \
+ JAR := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jrt-fs.jar, \
+ MANIFEST := $(SUPPORT_OUTPUTDIR)/java-main-manifest.mf, \
+diff -ru orig/jdk-6fa770f9f8ab/src/jdk.jartool/share/classes/sun/tools/jar/Main.java jdk-6fa770f9f8ab/src/jdk.jartool/share/classes/sun/tools/jar/Main.java
+--- orig/jdk-6fa770f9f8ab/src/jdk.jartool/share/classes/sun/tools/jar/Main.java 2022-04-13 19:24:12.555746751 +0200
++++ jdk-6fa770f9f8ab/src/jdk.jartool/share/classes/sun/tools/jar/Main.java 2022-04-13 19:25:34.117955999 +0200
+@@ -849,12 +849,18 @@
+ output(getMsg("out.added.manifest"));
+ }
+ ZipEntry e = new ZipEntry(MANIFEST_DIR);
+- e.setTime(System.currentTimeMillis());
++ if (System.getenv("SOURCE_DATE_EPOCH") != null)
++ e.setTime(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")));
++ else
++ e.setTime(System.currentTimeMillis());
+ e.setSize(0);
+ e.setCrc(0);
+ zos.putNextEntry(e);
+ e = new ZipEntry(MANIFEST_NAME);
+- e.setTime(System.currentTimeMillis());
++ if (System.getenv("SOURCE_DATE_EPOCH") != null)
++ e.setTime(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")));
++ else
++ e.setTime(System.currentTimeMillis());
+ if (flag0) {
+ crc32Manifest(e, manifest);
+ }
+@@ -1021,7 +1027,10 @@
+ throws IOException
+ {
+ ZipEntry e = new ZipEntry(INDEX_NAME);
+- e.setTime(System.currentTimeMillis());
++ if (System.getenv("SOURCE_DATE_EPOCH") != null)
++ e.setTime(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")));
++ else
++ e.setTime(System.currentTimeMillis());
+ if (flag0) {
+ CRC32OutputStream os = new CRC32OutputStream();
+ index.write(os);
+@@ -1040,7 +1049,10 @@
+ String name = mi.getKey();
+ byte[] bytes = mi.getValue();
+ ZipEntry e = new ZipEntry(name);
+- e.setTime(System.currentTimeMillis());
++ if (System.getenv("SOURCE_DATE_EPOCH") != null)
++ e.setTime(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")));
++ else
++ e.setTime(System.currentTimeMillis());
+ if (flag0) {
+ crc32ModuleInfo(e, bytes);
+ }
+@@ -1065,7 +1077,10 @@
+ addMultiRelease(m);
+ }
+ ZipEntry e = new ZipEntry(MANIFEST_NAME);
+- e.setTime(System.currentTimeMillis());
++ if (System.getenv("SOURCE_DATE_EPOCH") != null)
++ e.setTime(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")));
++ else
++ e.setTime(System.currentTimeMillis());
+ if (flag0) {
+ crc32Manifest(e, m);
+ }
diff --git a/gnu/packages/patches/openjdk-10-jtask-reproducibility.patch b/gnu/packages/patches/openjdk-10-jtask-reproducibility.patch
new file mode 100644
index 0000000000..3411ca12ae
--- /dev/null
+++ b/gnu/packages/patches/openjdk-10-jtask-reproducibility.patch
@@ -0,0 +1,53 @@
+--- jdk-10/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java.orig 2022-04-04 11:18:52.760626467 +0200
++++ jdk-10/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java 2022-04-04 12:03:40.645325687 +0200
+@@ -105,6 +105,7 @@
+ import jdk.internal.module.ModuleTarget;
+ import jdk.internal.module.Resources;
+ import jdk.tools.jlink.internal.Utils;
++import java.util.TreeSet;
+
+ import static java.util.stream.Collectors.joining;
+
+@@ -768,6 +769,7 @@
+ void processSection(JmodOutputStream out, Section section, Path path)
+ throws IOException
+ {
++ TreeSet<Path> paths = new TreeSet<>();
+ Files.walkFileTree(path, Set.of(FileVisitOption.FOLLOW_LINKS),
+ Integer.MAX_VALUE, new SimpleFileVisitor<Path>() {
+ @Override
+@@ -781,20 +783,24 @@
+
+ if (!relPath.toString().equals(MODULE_INFO)
+ && !matches(relPath, excludes)) {
+- try (InputStream in = Files.newInputStream(file)) {
+- out.writeEntry(in, section, relPath.toString());
+- } catch (IOException x) {
+- if (x.getMessage().contains("duplicate entry")) {
+- warning("warn.ignore.duplicate.entry",
+- relPath.toString(), section);
+- return FileVisitResult.CONTINUE;
+- }
+- throw x;
+- }
++ paths.add(file);
+ }
+ return FileVisitResult.CONTINUE;
+ }
+ });
++ for (Path file : paths) {
++ Path relPath = path.relativize(file);
++ try (InputStream in = Files.newInputStream(file)) {
++ out.writeEntry(in, section, relPath.toString());
++ } catch (IOException x) {
++ if (x.getMessage().contains("duplicate entry")) {
++ warning("warn.ignore.duplicate.entry",
++ relPath.toString(), section);
++ continue;
++ }
++ throw x;
++ }
++ }
+ }
+
+ boolean matches(Path path, List<PathMatcher> matchers) {
diff --git a/gnu/packages/patches/openjdk-10-module-reproducibility.patch b/gnu/packages/patches/openjdk-10-module-reproducibility.patch
new file mode 100644
index 0000000000..165edd3b4a
--- /dev/null
+++ b/gnu/packages/patches/openjdk-10-module-reproducibility.patch
@@ -0,0 +1,305 @@
+From a52c4ef44c0553a399a8a47e528db92e3bf51c6c Mon Sep 17 00:00:00 2001
+From: Alan Bateman <alanb@openjdk.org>
+Date: Wed, 29 Apr 2020 08:38:28 +0100
+Subject: [PATCH] 8243666: ModuleHashes attribute generated for JMOD and JAR
+ files depends on timestamps
+
+Reviewed-by: mchung
+---
+
+--- orig/jdk-3cc80be736f2/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java 2022-04-13 19:24:10.655695284 +0200
++++ jdk-3cc80be736f2/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java 2022-04-14 02:43:48.610326492 +0200
+@@ -27,9 +27,8 @@
+
+ import java.io.PrintStream;
+ import java.lang.module.Configuration;
++import java.lang.module.ModuleReference;
+ import java.lang.module.ResolvedModule;
+-import java.net.URI;
+-import java.nio.file.Path;
+ import java.nio.file.Paths;
+ import java.util.ArrayDeque;
+ import java.util.Collections;
+@@ -39,8 +38,8 @@
+ import java.util.LinkedList;
+ import java.util.Map;
+ import java.util.Set;
++import java.util.TreeMap;
+ import java.util.function.Consumer;
+-import java.util.function.Function;
+ import java.util.stream.Stream;
+ import static java.util.stream.Collectors.*;
+
+@@ -101,7 +100,7 @@
+ // the modules to record the hashes - it is the first matching
+ // module and has not been hashed during the traversal.
+ Set<String> mods = new HashSet<>();
+- Map<String, ModuleHashes> hashes = new HashMap<>();
++ Map<String, ModuleHashes> hashes = new TreeMap<>();
+ builder.build()
+ .orderedNodes()
+ .filter(mn -> roots.contains(mn) && !mods.contains(mn))
+@@ -116,27 +115,17 @@
+ mods.addAll(ns);
+
+ if (!ns.isEmpty()) {
+- Map<String, Path> moduleToPath = ns.stream()
+- .collect(toMap(Function.identity(), this::moduleToPath));
+- hashes.put(mn, ModuleHashes.generate(moduleToPath, "SHA-256"));
++ Set<ModuleReference> mrefs = ns.stream()
++ .map(name -> configuration.findModule(name)
++ .orElseThrow(InternalError::new))
++ .map(ResolvedModule::reference)
++ .collect(toSet())