Subject: [PATCH gnome-team 1/1] gnu: opam: Fix build.

From: Vivien Kraus <[email-masked]>
Date: Sat, 9 Mar 2024 10:46:18 +0100

* gnu/packages/ocaml.scm (ocaml-opam-core) [#:phases]: Add 'always-use-base64-compat-5'.

Change-Id: I8d9aec14ca2af92b9a4ac346ac57c22e6b76c716
---
Sorry, I messed up my cover letter, so it was not delivered to you.

Here it is:

Dear Guix,

For some unknown reason, opam on master decides that the ocaml base64 library
is not installed well enough to use it, but on gnome-team, it seems that it
does.

Opam can adapt to both cases, by using a different compatibility layer in
each.  On master, it uses the compatibility layer version 5, and on
gnome-team, the compatibility layer version 6.

However, the compatibility layer version 6 does not work.  An easy fix is to
force opam to use compatibility layer version 5 every time.

I am not proud of my regular expressions, but I couldn’t find a way to
factorize the optional `i` so that it matches either .ml or .mli.

Best regards,

Vivien

 gnu/packages/ocaml.scm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index 0f4c351141..5051524a53 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -854,6 +854,26 @@ (define ocaml-opam-core
                  #:tests? #f
                  #:phases
                  (modify-phases %standard-phases
+                   (add-after 'unpack 'always-use-base64-compat-5
+                     (lambda _
+                       (call-with-input-file "src/client/dune"
+                         (lambda (port)
+                           (display "ok")
+                           (newline)))
+                       ;; By default, the opamBase64Compat module will be
+                       ;; compatibility version 6, which is just an empty
+                       ;; file.  Opam-client cannot build with an empty file.
+                       (substitute* "src/client/dune"
+                         (("opamBase64Compat\\.ml\\.6")
+                          "opamBase64Compat.ml.5")
+                         (("opamBase64Compat\\.mli\\.6")
+                          "opamBase64Compat.mli.5")
+                         ;; Undo the change in the rule to generate the .6
+                         ;; files
+                         (("with-stdout-to opamBase64Compat\\.ml\\.5")
+                          "with-stdout-to opamBase64Compat.ml.6")
+                         (("with-stdout-to opamBase64Compat\\.mli\\.5")
+                          "with-stdout-to opamBase64Compat.mli.6"))))
                    (add-before 'build 'pre-build
                      (lambda* (#:key inputs make-flags #:allow-other-keys)
                        (let ((bash (assoc-ref inputs "bash"))
-- 
2.41.0