Subject: [PATCH 5/8] gnu: openjdk13: Make reproducible.

From: [email-masked]
Date: Wed, 1 Jun 2022 15:00:08 +0200

From: Danny Milosavljevic <[email-masked]>

* gnu/packages/patches/openjdk-13-classlist-reproducibility.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add patch.
* gnu/packages/java.scm (openjdk13)[source]: Add patch.
[arguments]<#:phases>[remove-timestamping]: Modify phase.
---
 gnu/local.mk                                         |  1 +
 gnu/packages/java.scm                                | 12 ++++++++++++
 .../openjdk-13-classlist-reproducibility.patch       | 11 +++++++++++
 3 files changed, 24 insertions(+)
 create mode 100644 gnu/packages/patches/openjdk-13-classlist-reproducibility.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index eaf0e306fb..aab850b4f7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1583,6 +1583,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/openjdk-10-module3-reproducibility.patch	\
   %D%/packages/patches/openjdk-10-module4-reproducibility.patch	\
   %D%/packages/patches/openjdk-11-classlist-reproducibility.patch	\
+  %D%/packages/patches/openjdk-13-classlist-reproducibility.patch	\
   %D%/packages/patches/openjdk-15-xcursor-no-dynamic.patch	\
   %D%/packages/patches/openmpi-mtl-priorities.patch		\
   %D%/packages/patches/openssh-hurd.patch			\
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 1a872ce786..7bf8527d67 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -2189,11 +2189,23 @@ (define-public openjdk13
               (sha256
                (base32
                 "0wrrr0d7lz1v8qqm752mn4gz5l2vpl2kmx4ac3ysvk4mljc924hp"))
+              (patches
+                (search-patches "openjdk-13-classlist-reproducibility.patch"
+                                "openjdk-10-jtask-reproducibility.patch"))
               (modules '((guix build utils)))
               (snippet
                `(begin
                   (for-each delete-file (find-files "." ".*.(bin|exe|jar)$"))
                   #t))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments openjdk12)
+       ((#:phases phases)
+        `(modify-phases ,phases
+           (replace 'remove-timestamping
+             (lambda _
+               (substitute* "src/hotspot/share/runtime/abstract_vm_version.cpp"
+                (("__DATE__") "")
+                (("__TIME__") ""))))))))
     (inputs
      `(("alsa-lib" ,alsa-lib)
        ("cups" ,cups)
diff --git a/gnu/packages/patches/openjdk-13-classlist-reproducibility.patch b/gnu/packages/patches/openjdk-13-classlist-reproducibility.patch
new file mode 100644
index 0000000000..326f6875ec
--- /dev/null
+++ b/gnu/packages/patches/openjdk-13-classlist-reproducibility.patch
@@ -0,0 +1,11 @@
+--- 6cllxkf0narh0b4wgx8npwjkznd7ifq0-openjdk-13.0.7-checkout/make/GenerateLinkOptData.gmk.orig	2022-04-04 17:20:33.012539984 +0200
++++ 6cllxkf0narh0b4wgx8npwjkznd7ifq0-openjdk-13.0.7-checkout/make/GenerateLinkOptData.gmk	2022-04-04 17:20:51.181032859 +0200
+@@ -78,7 +78,7 @@
+ 	        $(CAT) $(LINK_OPT_DIR)/stderr $(JLI_TRACE_FILE) ; \
+ 	        exit $$exitcode \
+ 	    )
+-	$(GREP) -v HelloClasslist $@.raw > $@
++	$(GREP) -v HelloClasslist $@.raw | sort > $@
+ 
+ # The jli trace is created by the same recipe as classlist. By declaring these
+ # dependencies, make will correctly rebuild both jli trace and classlist
-- 
2.36.1