guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#49950] [PATCH] Update opam and dune


From: Xinglu Chen
Subject: [bug#49950] [PATCH] Update opam and dune
Date: Mon, 09 Aug 2021 12:15:56 +0200

On Mon, Aug 09 2021, Julien Lepiller wrote:

> Hi Guix!
>
> This small series updates opam and dune. Opam was surprisingly
> difficult to update, after the switch to dune, but I had to update it
> because the previous version we had doesn't build with the new dune.
>
> The most difficult part was making the tests pass, as they require
> network access. For some of them, I was able to download the files in
> advance (see opam-repo in the inputs), and change the tests to use
> that, fix shebangs, ... I still had to disable three tests: one that
> runs opam and let it clone a git repository, one that fails only
> because of a difference in text formating (it's expected to be on one
> line, but actually is nicely formated), and one that compares a
> generated dune file with the one that was just modified.
>
> also ocaml-markup fails with the new dune, so I updated it to the
> latest version.
> From 8b17bf14e9892b26b049c530365c6a41b1231838 Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <julien@lepiller.eu>
> Date: Mon, 9 Aug 2021 03:57:38 +0200
> Subject: [PATCH 1/4] gnu: ocaml-markup: Update to 1.0.2.
>
> * gnu/packages/ocaml.scm (ocaml-markup): Update to 1.0.2.
> ---
>  gnu/packages/ocaml.scm | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
> index 112751ddec..923d7b1704 100644
> --- a/gnu/packages/ocaml.scm
> +++ b/gnu/packages/ocaml.scm
> @@ -6432,7 +6432,7 @@ the full Core is not available, such as in Javascript.")
>  (define-public ocaml-markup
>    (package
>      (name "ocaml-markup")
> -    (version "1.0.0")
> +    (version "1.0.2")
>      (home-page "https://github.com/aantron/markup.ml";)
>      (source
>       (origin
> @@ -6443,7 +6443,7 @@ the full Core is not available, such as in Javascript.")
>         (file-name (git-file-name name version))
>         (sha256
>          (base32
> -         "09hkrf9pw6hpb9j06p5bddklpnjwdjpqza3bx2179l970yl67an9"))))
> +         "1kvqwrrcrys5d0kzdwxcj66jpi6sdhfas4pcg02pixx92q87vhqm"))))
>      (build-system dune-build-system)
>      (arguments
>       `(#:package "markup"))
> -- 
> 2.32.0
>
> From d76314465a79fe531c05f3849f5e609c175362aa Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <julien@lepiller.eu>
> Date: Mon, 9 Aug 2021 03:24:08 +0200
> Subject: [PATCH 2/4] gnu: ocaml-opam-file-format: Update to 2.1.3.
>
> * gnu/packages/ocaml.scm (ocaml-opam-file-format): Update to 2.1.3.
> ---
>  gnu/packages/ocaml.scm | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
> index 923d7b1704..11f7eff267 100644
> --- a/gnu/packages/ocaml.scm
> +++ b/gnu/packages/ocaml.scm
> @@ -747,7 +747,7 @@ let () = String.split_on_char ':' (Sys.getenv 
> \"OCAMLPATH\")
>  (define-public ocaml-opam-file-format
>    (package
>      (name "ocaml-opam-file-format")
> -    (version "2.0.0")
> +    (version "2.1.3")
>      (source (origin
>                (method git-fetch)
>                (uri (git-reference
> @@ -756,7 +756,7 @@ let () = String.split_on_char ':' (Sys.getenv 
> \"OCAMLPATH\")
>                (file-name (git-file-name name version))
>                (sha256
>                 (base32
> -                "0fqb99asnair0043hhc8r158d6krv5nzvymd0xwycr5y72yrp0hv"))))
> +                "1fxhppdmrysr2nb5z3c448h17np48f3ga9jih33acj78r4rdblcs"))))
>      (build-system ocaml-build-system)
>      (arguments
>       `(#:tests? #f; No tests
> -- 
> 2.32.0
>
> From 66cc97fb59324387a3d829e1dbe7382e5511fe6a Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <julien@lepiller.eu>
> Date: Mon, 9 Aug 2021 03:20:06 +0200
> Subject: [PATCH 3/4] gnu: opam: Update to 2.1.0.
>
> * gnu/packages/ocaml.scm (opam): Update to 2.1.0.
> ---
>  gnu/packages/ocaml.scm | 158 +++++++++++++++++++++++------------------
>  1 file changed, 89 insertions(+), 69 deletions(-)
>
> diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
> index 11f7eff267..230d9d1e03 100644
> --- a/gnu/packages/ocaml.scm
> +++ b/gnu/packages/ocaml.scm
> @@ -77,6 +77,7 @@
>    #:use-module (gnu packages texinfo)
>    #:use-module (gnu packages time)
>    #:use-module (gnu packages tls)
> +  #:use-module (gnu packages version-control)
>    #:use-module (gnu packages virtualization)
>    #:use-module (gnu packages web)
>    #:use-module (gnu packages web-browsers)
> @@ -775,7 +776,7 @@ the opam file format.")
>  (define-public opam
>    (package
>      (name "opam")
> -    (version "2.0.8")
> +    (version "2.1.0")
>      (source (origin
>                (method git-fetch)
>                (uri (git-reference
> @@ -784,78 +785,97 @@ the opam file format.")
>                (file-name (git-file-name name version))
>                (sha256
>                 (base32
> -                "1z0ls6xxa4ws5xw0am5gxmh5apnmyhgkcphrncp53w34j8sfydsj"))))
> -    (build-system ocaml-build-system)
> +                "12l7l4pbzy71k1yc7ym5aczajszvc9bqkdnfg8xhqc8ch8j1h1lj"))))
> +    (build-system dune-build-system)
>      (arguments
> -     `(#:configure-flags
> -       (list (string-append "SHELL="
> -                            (assoc-ref %build-inputs "bash")
> -                            "/bin/sh"))
> +     `(#:test-target "."
> +       #:phases
> +       (modify-phases %standard-phases
> +         (add-before 'build 'pre-build
> +           (lambda* (#:key inputs make-flags #:allow-other-keys)
> +             (let ((bash (assoc-ref inputs "bash"))
> +                   (bwrap (string-append (assoc-ref inputs "bubblewrap")
> +                                         "/bin/bwrap")))
> +               (substitute* "src/core/opamSystem.ml"
> +                 (("\"/bin/sh\"")
> +                  (string-append "\"" bash "/bin/sh\""))
> +                 (("getconf")
> +                  (which "getconf")))
> +               ;; Use bwrap from the store directly.
> +               (substitute* "src/state/shellscripts/bwrap.sh"
> +                 (("-v bwrap") (string-append "-v " bwrap))
> +                 (("exec bwrap") (string-append "exec " bwrap))
> +                 ;; Mount /gnu and /run/current-system in the
> +                 ;; isolated environment when building with opam.
> +                 ;; This is necessary for packages to find external
> +                 ;; dependencies, such as a C compiler, make, etc...
> +                 (("^add_sys_mounts /usr")
> +                  "add_sys_mounts /gnu /run/current-system /usr"))

/gnu should be replaced by (%store-directory) (from (gnu build utils)), in
case the store isn’t mounted at /gnu/store.  :-)

> +               (substitute* "src/client/opamInitDefaults.ml"
> +                 (("\"bwrap\"") (string-append "\"" bwrap "\""))))))
> +         (add-before 'check 'prepare-checks
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             ;; Opam tests need to run an isolated environment from a 
> writable
> +             ;; home directory.
> +             (mkdir-p "test-home")
> +             (setenv "HOME" (string-append (getcwd) "/test-home"))
>  
> -       ;; For some reason, 'ocp-build' needs $TERM to be set.
> -       #:make-flags
> -       (list "TERM=screen"
> -             (string-append "SHELL="
> -                            (assoc-ref %build-inputs "bash")
> -                            "/bin/sh"))
> -
> -       #:test-target "tests"
> -
> -       #:phases (modify-phases %standard-phases
> -                 (add-before 'build 'pre-build
> -                   (lambda* (#:key inputs make-flags #:allow-other-keys)
> -                     (let ((bash (assoc-ref inputs "bash"))
> -                           (bwrap (string-append (assoc-ref inputs 
> "bubblewrap")
> -                                                 "/bin/bwrap")))
> -                       (substitute* "src/core/opamSystem.ml"
> -                         (("\"/bin/sh\"")
> -                          (string-append "\"" bash "/bin/sh\""))
> -                         (("getconf")
> -                          (which "getconf")))
> -                       ;; Use bwrap from the store directly.
> -                       (substitute* "src/state/shellscripts/bwrap.sh"
> -                         (("-v bwrap") (string-append "-v " bwrap))
> -                         (("exec bwrap") (string-append "exec " bwrap))
> -                         ;; Mount /gnu and /run/current-system in the
> -                         ;; isolated environment when building with opam.
> -                         ;; This is necessary for packages to find external
> -                         ;; dependencies, such as a C compiler, make, etc...
> -                         (("^add_sys_mounts /usr")
> -                          "add_sys_mounts /gnu /run/current-system /usr"))
> -                       (substitute* "src/client/opamInitDefaults.ml"
> -                         (("\"bwrap\"") (string-append "\"" bwrap "\"")))
> -                       ;; Generating the documentation needs write access
> -                       (for-each
> -                         (lambda (f) (chmod f #o644))
> -                         (find-files "doc" "."))
> -                       #t)))
> -                 (add-before 'check 'pre-check
> -                   (lambda _
> -                     ;; The "repo" test attempts to open some of these files 
> O_WRONLY
> -                     ;; and fails with a bogus "OpamSystem.File_not_found" 
> otherwise.
> -                     (for-each
> -                      (lambda (f) (chmod f #o644))
> -                      (find-files "tests/packages" "\\.opam$"))
> -
> -                     (substitute* "tests/Makefile"
> -                       (("/usr/bin/printf")
> -                        (which "printf"))
> -                       ;; By default tests run twice: once with a "local" 
> repository
> -                       ;; and once with a git repository: disable the git 
> tests to
> -                       ;; avoid the dependency.
> -                       (("all: local git")
> -                        "all: local"))
> -                     #t)))))
> +             ;; Opam tests require data from opam-repository. Instead of
> +             ;; downloading them with wget from the guix environment, copy 
> the
> +             ;; content to the expected directory.
> +             (substitute* "tests/reftests/dune.inc"
> +               (("tar -C.*opam-archive-([0-9a-f]*)[^)]*" _ commit)
> +                (string-append "rmdir %{targets}) (run cp -r "
> +                               (assoc-ref inputs (string-append "opam-repo-" 
> commit))
> +                               "/ %{targets}) (run chmod +w -R %{targets}"))
> +               (("wget[^)]*") "touch %{targets}")
> +               ;; Disable a failing test because of different line wrapping
> +               (("diff cli-versioning.test cli-versioning.out") "run true")
> +               ;; Disable a failing test because it tries to clone a git
> +               ;; repository from inside bwrap
> +               (("diff upgrade-format.test upgrade-format.out") "run true"))
> +             (substitute* "tests/reftests/dune"
> +               ;; Because of our changes to the previous file, we cannot 
> check
> +               ;; it can be regenerated
> +               (("diff dune.inc dune.inc.gen") "run true"))
> +             ;; Ensure we can run the generated build.sh (no /bin/sh)
> +             (substitute* '("tests/reftests/legacy-local.test"
> +                            "tests/reftests/legacy-git.test")
> +               (("#! ?/bin/sh") (string-append "#!" (assoc-ref inputs "bash")
> +                                               "/bin/sh")))
> +             (substitute* "tests/reftests/testing-env"
> +               (("OPAMSTRICT=1")
> +                (string-append "OPAMSTRICT=1\nLIBRARY_PATH="
> +                               (assoc-ref inputs "libc") "/lib"))))))))
>      (native-inputs
> -     `(("dune" ,dune)
> -       ("ocaml-cppo" ,ocaml-cppo)
> +      (let ((opam-repo (lambda (commit hash)
> +                         (origin
> +                           (method git-fetch)
> +                           (uri (git-reference
> +                                  (url 
> "https://github.com/ocaml/opam-repository";)
> +                                  (commit commit)))
> +                           (file-name (git-file-name "opam-repo" commit))
> +                           (sha256 (base32 hash))))))
> +       `(("dune" ,dune)
> +         ("ocaml-cppo" ,ocaml-cppo)
>  
> -       ;; For tests.
> -       ("openssl" ,openssl)
> -       ("python" ,python-wrapper)
> -       ("rsync" ,rsync)
> -       ("unzip" ,unzip)
> -       ("which" ,which)))
> +         ;; For tests.
> +         ("git" ,git)

Maybe ‘git-minimal’ would be enough.

The rest LGTM, I am not super familiar with Opam, though.

Thank you for working on this!

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]