Re: opam packaging

"Ashish Agarwal [email protected] [ocaml_beginners]" <[email protected]> Thu, 3 Dec 2015 12:24:48 -0500
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <CAMu2m2+cfO5u3Jj44AwV+YQ+W4zkvt_utYQ7cDVHDvDseUMByA@mail.gmail.com>
On Tue, Dec 1, 2015 at 3:37 PM, Hendrik Boom [email protected]
[ocaml_beginners] <[email protected]> wrote:

> So is the .opam a repository? Or does it contain a repository?
>
Neither. An opam repository is a directory with a particular structure and
files with particular formats. As an example, the main repository is here:

https://github.com/ocaml/opam-repository

It doesn't have to be a git repo. You can make a local directory and tell
opam to use that directory. You'll note that the "default" repo opam
creates actually points to https://opam.ocaml.org, but this is essentially
equivalent to pointing it to the above URL. Don't worry about this for now.
The difference is that you can optimize how the repo is served, which is
important for the default repo since it is heavily used.


> And the various packages that opam will download for me, do they come
> from a net-accessinle repository? Or each from its own?
>
This is specified in the `url` file, see for example:

https://github.com/ocaml/opam-repository/blob/master/packages/core/core.113.00.00/url

The url doesn't have to be an http scheme. You can refer to a local file.
OPAM doesn't inherently require network access. However, I'm starting to
suspect that you're pursuing a line of questions that isn't relevant to
your goal. See below.


> I want to add functionality to an existing package, and/or fix things
> that I consider bugs, whether the original author does or not.
> For that, I suspect I need to modify the source code.
>
This has little to do with OPAM. Say you want to add functionality to some
package, take utop to be concrete. You can fork utop, so now you have your
own copy, either on github or a local directory. Now you can `opam pin` it.
That's it. Now when you do `opam install utop`, your pinned version will be
the one that opam installs. Furthermore, the utop source code also includes
an `opam` file (you could add it to your fork if it didn't), so this is the
file that opam will read. You could also modify this if you need to, but
again I suspect you won't need to for what you're trying to do.

To find the source code, do I have to unpack the tarball under
> .opam/archives? Or is there some way to identify a distributed revision
> management repository it might be better to pull from?
>
Do `opam info foo` for whatever package you're interested in. You'll see
several URLs of relevance. Ideally, there would be a homepage and dev-repo,
but many packages don't provide this. At the least you'll see an
upstream-url, which is where the tarball is, and often a hint about where
the master source code is.