Subject: Re: bug#65926: package openjdk 20.0.2 and release-candidate 21+35 and add helpers for that
From: Maxim Cournoyer <[email-masked]>
To: "Dr. Arne Babenhauserheide" <[email-masked]>
Cc: [email-masked]
Date: Sun, 21 Jan 2024 00:34:09 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello!

"Dr. Arne Babenhauserheide" <[email-masked]> writes:

> 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

It seems all of your series got sent as a single diff, instead of
multiple messages.  Apply it with 'git am' only applies the first
commit.  Am I missing something?

> ---
>  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) "+"))

This is probably odd enough to be better defined in java.scm, but see
below.

[...]

> 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

I'm not sure we want this in Guix proper; it'd be good for a bleeding
edge java channel, perhaps?
]
>  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
> +               ...)))))))
> +

Especially since this mostly duplicates the macro from make-openjdk.

> 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")))))))))

I see we already have 20 on master.  We could simply update it to 20.0.2
with its hash.  The two phases above need not be duplicated; they are
attached to the openjdk19 package and inherited.

-- 
Thanks,
Maxim