how to use opam for package builds?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

how to use opam for package builds?

Andrew Schulman
orpie recently changed to an opam-based build system. So I want to use opam
to update it for Cygwin, but I've never used opam before and I have some
questions about how to use it.

The orpie build instructions say just to run "opam install orpie". When I
do that, opam complains that I haven't set it up yet:

    $ opam install orpie
    [ERROR] No OPAM root found at /home/andrew/.opam.
            Please run 'opam init' to initialize the state of OPAM, or
specify '--root'.
            See 'opam init --help' for details.

Now for packaging, what's the right thing to do here? For example I could
create the following install function for Cygport:

src_install()
{
    opam init
    opam install orpie
}

But this has two problems:

(1) I can't get "opam init" to complete. It hangs after "synchronized from
https://opam.ocaml.org", until I interrupt it:

    $ opam init
    Checking for available remotes: rsync and local, git, mercurial.
      - you won't be able to use darcs repositories unless you install the
darcs command on your system.
   
    [WARNING] Recommended external solver aspcud not found.

    =-=- Fetching repository information
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    [default] synchronized from https://opam.ocaml.org
    ### hangs here until I hit ctrl-C: ###
    [ERROR] Initialisation failed
    User interruption
   
    # opam-version    1.2.2
    # os              cygwin
    Cannot remove /home/andrew/.opam (error 255).

(2) Even if I get this to work, I don't think it's the right thing to do
because it's setting up persistent opam configuration in my home directory,
which I don't think is the right place for packaging. Should there be some
global opam configuration, that all packaging scripts that rely on opam
would use? If so, where should that go?

Tnanks,
Andrew

Reply | Threaded
Open this post in threaded view
|

Re: how to use opam for package builds?

Andy Li
Hi,

On Wed, Aug 29, 2018 at 11:47 PM Andrew Schulman <[hidden email]>
wrote:

> (1) I can't get "opam init" to complete. It hangs after "synchronized from
> https://opam.ocaml.org", until I interrupt it:
>

It should work, just wait a little longer. For me, it took a bit more than
three minutes to complete.
I'm not sure why it is that slow though.


> (2) Even if I get this to work, I don't think it's the right thing to do
> because it's setting up persistent opam configuration in my home directory,
> which I don't think is the right place for packaging. Should there be some
> global opam configuration, that all packaging scripts that rely on opam
> would use? If so, where should that go?


Indeed the proper way is to package each ocaml library as cygwin packages
and then the orpie package just build depends on them instead of calling
opam.
There are several already packaged ocaml libraries. You may study their
cygport files in
https://github.com/cygwinports?utf8=%E2%9C%93&q=ocaml&type=&language=

Hope it helps.

Best,
Andy