[Debian-med-packaging] [covid-19] Help for ocaml package needed

Pierre Boutillier pierre.boutillier at laposte.net
Sun May 24 16:11:59 BST 2020


Hi Andreas,

(Someone NOT involved in debian (beyond following debian-ocaml-maint 
list) speaking here. I want for years taking the time to become involved 
but never did and won't in the near future :-/).

As Ralf told you, your first problem is that the software you're trying 
to package is using an old version of `ocamlbuild`. A quick and awful 
fix is (The correct thing would be to give the "origin" of the thing 
you're lexing instead of `"foobar"`):

```

diff --git a/myocamlbuild.ml b/myocamlbuild.ml
index fd877a9..cf75d2c 100644
--- a/myocamlbuild.ml
+++ b/myocamlbuild.ml
@@ -14,7 +14,7 @@ open Ocamlbuild_plugin

  let run_and_read      = Ocamlbuild_pack.My_unix.run_and_read

-let blank_sep_strings = Ocamlbuild_pack.Lexers.blank_sep_strings
+let blank_sep_strings = Ocamlbuild_pack.Lexers.blank_sep_strings "foobar"

  module OCamlFind =
  struct
```

but I fear you will still be very far from home with only this. You'll 
then run into the failure:

```
File "pplacer_src/guppy_mcl.ml", line 23, characters 2-9:
Error: Unbound module Mcl
```

I see you're the uploader of `mcl` in debian but what is needed here is 
not mcl binaries but "OCaml bindings to the mcl C functions" which looks 
to me not available in debian. Google found them at 
https://github.com/fhcrc/mcl. As you can see, it is a "fork" of mcl so 
it duplicates all its code which, if I'm correct, forbids to easily make 
a package out of it as duplication of code is forbidden in debian!

 From the other end, the situation is not better as, if I'm correct, mcl 
as packaged provides binaries but no C libraries you can link to. That 
means that it is not easy to take the `caml` folder of fhcrc/mcl and 
"simply" tweak the build system so that it finds the C functions in a 
"libmcs shared library" instead of in the C files it duplicated from mcl...

Maybe, the """easiest""" path is to replace mcl pristine tarball by one 
from https://github.com/fhcrc/mcl (if only it is upto date...) so that 
mcl source package provides at the same time the binaries and an ocaml 
library...

Anyway, once the puzzle of packaging mcl OCaml bindings is solved, 
`make` in pplacer finally worked for me.

For the record, here is how I managed to compile mcl OCaml bindings from 
https://github.com/fhcrc/mcl (in stable, Sorry I realize only now I 
should retry in sid...) :

- I had to apply the following patch (because OCaml headers are not 
compatible with c89 anymore)

```
diff --git a/_oasis b/_oasis
index 22e106a..c0c93c3 100644
--- a/_oasis
+++ b/_oasis
@@ -13,5 +13,5 @@ Library mcl
    Path: caml
    BuildTools: ocamlbuild
    CSources: caml_mcl.c
-  CCOpt: -fPIC -std=c89
+  CCOpt: -fPIC -std=c99
    Modules: Mcl
diff --git a/caml/caml_mcl.c b/caml/caml_mcl.c
index 37bd0d6..d5f92e0 100644
--- a/caml/caml_mcl.c
+++ b/caml/caml_mcl.c
@@ -17,7 +17,7 @@ void caml_mcl_initialize(void)
      if (caml_mcl_initialized)
          return;

-    srandom(mcxSeed(315));
+    srand(mcxSeed(315));
      mclx_app_init(NULL);
      caml_mcl_initialized = 1;
  }
diff --git a/myocamlbuild.ml b/myocamlbuild.ml
index 2ff1223..e24475a 100644
--- a/myocamlbuild.ml
+++ b/myocamlbuild.ml
@@ -602,7 +602,7 @@ let package_default =
            (["oasis_library_mcl_ccopt"; "compile"],
              [
                 (OASISExpr.EBool true,
-                 S [A "-ccopt"; A "-fPIC"; A "-ccopt"; A "-std=c89"])
+                 S [A "-ccopt"; A "-fPIC"; A "-ccopt"; A "-std=c99"])
              ])
         ];
       includes = []
diff --git a/setup.ml b/setup.ml
index 2743646..28d9025 100644
--- a/setup.ml
+++ b/setup.ml
@@ -6714,7 +6714,7 @@ let setup_t =
                        bs_c_sources = ["caml_mcl.c"];
                        bs_data_files = [];
                        bs_ccopt =
-                        [(OASISExpr.EBool true, ["-fPIC"; "-std=c89"])];
+                        [(OASISExpr.EBool true, ["-fPIC"; "-std=c99"])];
                        bs_cclib = [(OASISExpr.EBool true, [])];
                        bs_dlllib = [(OASISExpr.EBool true, [])];
                        bs_dllpath = [(OASISExpr.EBool true, [])];
```

- Then I build by `ocaml setup.ml -all` and installed by hand with 
`ocaml setup.ml -install` (which simply runs `ocamlfind' install mcl 
caml/META _build/caml/mcl.cmx _build/caml/mcl.cmi _build/caml/mcl.cmxs 
_build/caml/mcl.a _build/caml/mcl.cmxa _build/caml/mcl.cma 
_build/caml/dllmcl_stubs.so _build/caml/libmcl_stubs.a caml/mcl.ml`)

- To build debian packages instead, here comes the part where I 
humiliate myself because I've never managed to learn Ocaml packaging in 
debian so I know dh-ocaml provides all the automation necessary for 
these files put in their correct places to be spilt in a `libmcl-ocaml` 
and a `libmcl-ocaml-dev` but I can't spell it...

Best,
Pierre B.

Le 23/05/2020 à 15:09, Andreas Tille a écrit :
> Hi,
>
> in the Debian Med Covid-19 sprint we have a set of packages that can be
> used to help researching the disease.  To this set of packages belongs
> pplacer which I injected into Salsa[1].  I admit I never packaged
> software written in ocaml and my initial attempt was probably weak.  It
> ends with:
>
>
> ...
> make[2]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
> ocamlbuild pplacer.native
> /usr/bin/ocamlopt.opt unix.cmxa -I /usr/lib/ocaml/ocamlbuild /usr/lib/ocaml/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /usr/lib/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
> + /usr/bin/ocamlopt.opt unix.cmxa -I /usr/lib/ocaml/ocamlbuild /usr/lib/ocaml/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /usr/lib/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
> File "myocamlbuild.ml", line 24, characters 6-78:
> 24 | ......Lexing.from_string &
> 25 |       run_and_read "ocamlfind list | cut -d' ' -f1"
> Error: This expression has type Lexing.lexbuf
>         but an expression was expected of type
>           Ocamlbuild_pack.Loc.source = string
> Command exited with code 2.
> make[2]: *** [Makefile:21: pplacer.native] Error 10
> ...
>
>
> Any hint what to do next and to fix this bug?
>
> Thanks for any help
>
>        Andreas.
>
>
> [1] https://salsa.debian.org/med-team/pplacer
>



More information about the Debian-med-packaging mailing list