Subject: bug#65926: package openjdk 20.0.2 and release-candidate 21+35 and add helpers for that

From: "Dr. Arne Babenhauserheide" <[email-masked]>
Date: Wed, 13 Sep 2023 22:04:37 +0200

Hi,

attached are patches to add helpers and package openjdk 20.0.2 and
21+35.

The 21+35 package skips the validation of the runpath, because that
fails. I don’t know why.

From e72a8ec42a4d4a199711c0abf7960f8caeab5c1e Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
From: Arne Babenhauserheide <[email-masked]>
Date: Wed, 13 Sep 2023 21:59:25 +0200
Subject: [PATCH 1/4] Add version-prefix-+ for versions with + as separator of
 the build

* guix/utils.scm (version-prefix-+): new procedure
---
 guix/utils.scm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/guix/utils.scm b/guix/utils.scm
index e9af33bdeb..2993b31a5c 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -116,6 +116,7 @@ (define-module (guix utils)
             version>?
             version>=?
             version-prefix
+            version-prefix-+
             version-major+minor+point
             version-major+minor
             version-major
@@ -822,6 +823,11 @@ (define (version-major version-string)
   "Return the major version number as string from the version-string."
   (version-prefix version-string 1))
 
+(define (version-prefix-+ version-string)
+  "Truncate version-string to leave out a suffix appended with +.
+For example, (version-prefix-+ \"21+35\" returns \"21\""
+  (string-join (take (string-split version-string #\+) 1) "+"))
+
 (define (version-unique-prefix version versions)
   "Return the shortest version prefix to unambiguously identify VERSION among
 VERSIONS.  For example:

base-commit: e2a7c227dea5b361e2ebdbba24b923d1922a79d0
prerequisite-patch-id: e26acb8280f31db9b663b6fc444a2229fc5b588e
prerequisite-patch-id: db5cc62f7d04f3ed3014ae984fe732f3b6db8d17
prerequisite-patch-id: 3a0bf9ef6f27f1d92537c5e9ee5c38c7d6ced99e
prerequisite-patch-id: 088a72da8c11e5d1c7087b4a5e8bb9c4a3b9b2af
prerequisite-patch-id: 1b4787e17ec6ab62978615e1d3804a1024c5e1a0
prerequisite-patch-id: f814d9756faa5d91a68b81654606c66b4cf389e5
prerequisite-patch-id: f2dbed3e6da49472bd141c9fa40de2d2208130fb
prerequisite-patch-id: 2dbf557994da4a264566b67294f7f3f8e2931f5f
prerequisite-patch-id: 912a76fac540b98d5683ba1886a7d62f0963cd9f
prerequisite-patch-id: f6a9bfd16b8952c73b7a6d97be70013a290815d7
prerequisite-patch-id: e50c1aaa1d401bba32a49d2e1fb1661746543d09
prerequisite-patch-id: 1f63cb516bc5c9772ae808371528006fca20dcad
prerequisite-patch-id: 1ac04f0120fb6c4f106d05bee88103debb815b41
prerequisite-patch-id: eeff242fb5e41c8c83b3daadd0965e58eb6670ba
prerequisite-patch-id: 3812c9ac1252d9d20e8485462be155156f302a54
prerequisite-patch-id: 9d3dd155c91ab334999c03fefab04f361ea4d8b5
prerequisite-patch-id: f5b09b934b65fe45bdfd1273baa3bb949ed52cca
prerequisite-patch-id: 61a9b3943bdbe5cb6a4aa978888ceb64088f9a14
prerequisite-patch-id: 3f9d50361fb537607c33d09115366aec05160688
prerequisite-patch-id: 765c77b7c31f24491149665a066d2906f8da8d33
prerequisite-patch-id: 2b92c37e3aa74152a7aa226e1fbd5f2735037dc0
prerequisite-patch-id: 2a3123ab0786108f26e25c45fc4c545b99b6dd27
prerequisite-patch-id: 891a2458a90ea90113c576df5029514f5143366e
prerequisite-patch-id: 1a08957a2fd3e3637ed7f3cf3f44c9f8194d6668
prerequisite-patch-id: d382210c915c0a809cb709cba45a4542d60c4d20
prerequisite-patch-id: d424ad2c4c4bf14becb025c67757f48d4a6ae6b5
prerequisite-patch-id: 07e1c90231819e0b963645b041522e53891fd344
prerequisite-patch-id: 124009dec6dad63add19bf258f71bdb127078ecb
prerequisite-patch-id: 0afa33c8e0e2aca07da2782e04d259d3f8c498c5
prerequisite-patch-id: 205bb6c05a145eb9137e8623687418089351e73e
prerequisite-patch-id: 7138f72403701b9749a0a587f1807030d730c00d
prerequisite-patch-id: 39bd665160a5e62aaa4ea94ad2e3ca30f31e2127
-- 
2.41.0

From 42b2dbb2d09ab5706523f25951f51289e3ad6181 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
In-Reply-To: <[email-masked]>
References: <[email-masked]>
From: Arne Babenhauserheide <[email-masked]>
Date: Wed, 13 Sep 2023 22:00:55 +0200
Subject: [PATCH 2/4] Add syntax make-openjdk-release-candidate for versions
 like 21+35

* gnu/packages/java.scm (make-openjdk-release-candidate): new procedure
---
 gnu/packages/java.scm | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index f7464e2168..0c22f4def9 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -1431,6 +1431,45 @@ (define-syntax make-openjdk
                field
                ...)))))))
 
+(define-syntax make-openjdk-release-candidate
+  ;; Return an OpenJDK package at VERSION with checksum HASH, using BOOTSTRAP,
+  ;; the bootstrap package.  One or more FIELD can be provided to further
+  ;; refine the package definition; for convenience, the BASE, NAME and
+  ;; VERSION are defined in their scope.
+  (lambda (x)
+    (syntax-case x ()
+      ((_ bootstrap version* hash field ...)
+       (with-syntax ((base (datum->syntax x 'base))
+                     (name (datum->syntax x 'name))
+                     (version (datum->syntax x 'version)))
+         #'(let ((base (package
+                         (inherit bootstrap)
+                         (name "openjdk")
+                         (version version*)
+                         (source
+                          (origin
+                            (inherit (package-source bootstrap))
+                            (method git-fetch)
+                            (uri (git-reference
+                                  (url (format
+                                        #f "https://github.com/openjdk/jdk~au"
+                                        (version-prefix-+ version*)))
+                                  (commit (string-append "jdk-" version*))))
+                            (file-name (git-file-name name version))
+                            (sha256 (base32 hash))))
+                         (native-inputs
+                          (modify-inputs (package-native-inputs bootstrap)
+                            (replace "openjdk" bootstrap)))
+                         (home-page (string-append
+                                     "https://openjdk.java.net/projects/jdk/"
+                                     (version-major version)))))
+                 (name "openjdk")
+                 (version version*))
+             (package
+               (inherit base)
+               field
+               ...)))))))
+
 (define-public openjdk12
   (make-openjdk
    openjdk11 "12.33" "0mbhdrk12b6878kby0flnbak7444dlpm0ihlmf92vk59y1c02bc2"
-- 
2.41.0

From 823bf15aed65b6abe48ad28fb6bb94d7e9bc5db2 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
In-Reply-To: <[email-masked]>
References: <[email-masked]>
From: Arne Babenhauserheide <[email-masked]>
Date: Wed, 13 Sep 2023 22:02:13 +0200
Subject: [PATCH 3/4] Add openjdk 20.0.2

* gnu/packages/java.scm (openjdk20): new package
---
 gnu/packages/java.scm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 0c22f4def9..d541242b73 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -1590,6 +1590,22 @@ (define-public openjdk19
 ;;; Convenience alias to point to the latest version of OpenJDK.
 (define-public openjdk openjdk19)

+(define-public openjdk20
+  (make-openjdk openjdk19 "20.0.2"
+                "1af1v2c3d8x4c6shzl6cv9qwq7a4hn5map5pjh9vjcky0hkzd489"
+   (arguments
+    (substitute-keyword-arguments (package-arguments openjdk19)
+      ((#:phases phases)
+       #~(modify-phases #$phases
+           (replace 'fix-java-shebangs
+             (lambda _
+               ;; Update file path.
+               (substitute* "src/java.base/share/data/blockedcertsconverter/blocked.certs.pem"
+                 (("^#!.*") "#! java BlockedCertsConverter SHA-256\n"))))
+           (add-before 'configure 'define-java-environment-variables
+             (lambda* (#:key inputs #:allow-other-keys)
+               ;; Fix for "valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z".
+               (setenv "SOURCE_DATE_EPOCH" "1234567890")))))))))
 
 ;; This version of JBR is here in order to be able to build custom
 ;; IntelliJ plugins.  Those usually need both jbr11 and jbr17 for
--
2.41.0

From cfcb798398c0cec64a6fa2bfaf2a0ad50612da21 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
In-Reply-To: <[email-masked]>
References: <[email-masked]>
From: Arne Babenhauserheide <[email-masked]>
Date: Wed, 13 Sep 2023 22:02:36 +0200
Subject: [PATCH 4/4] Add openjdk release-candidate 21+35

* gnu/packages/java.scm (openjdk21): new package
---
 gnu/packages/java.scm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index d541242b73..0c0e6a717c 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -1606,6 +1606,26 @@ (define-public openjdk20
              (lambda* (#:key inputs #:allow-other-keys)
                ;; Fix for "valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z".
                (setenv "SOURCE_DATE_EPOCH" "1234567890")))))))))
+
+(define-public openjdk21
+  (make-openjdk-release-candidate openjdk20 "21+35"
+                "06wjfwrkqykjdkis2s1nh91cy8vwincnmc699cxvyk3fc12jf3vw"
+   (arguments
+    (substitute-keyword-arguments (package-arguments openjdk19)
+      ((#:phases phases)
+       #~(modify-phases #$phases
+           (replace 'fix-java-shebangs
+             (lambda _
+               ;; Update file path.
+               (substitute* "src/java.base/share/data/blockedcertsconverter/blocked.certs.pem"
+                 (("^#!.*") "#! java BlockedCertsConverter SHA-256\n"))))
+           (replace 'validate-runpath
+             (lambda _ #t)) ;; just do nothing because this validation fails on libjava.so missing which is part of openjdk itself
+           (add-before 'configure 'define-java-environment-variables
+             (lambda* (#:key inputs #:allow-other-keys)
+               ;; Fix for "valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z".
+               (setenv "SOURCE_DATE_EPOCH" "1234567890")))))))))
+
 
 ;; This version of JBR is here in order to be able to build custom
 ;; IntelliJ plugins.  Those usually need both jbr11 and jbr17 for
--
2.41.0

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de