Sync versions of several packages coming from a single repo

Hi,

Let’s suppose I have a repository compiled with jbuilder and released with topkg that generates two opam packages x and a dependent package x-y. In x-y.opam, I have the dependency:

depends: [
  "x"
  ...
]

However, this is a problem because x-y version σ depends on the same version of x (for security because it uses internal APIs which may evolve more quickly than the external one). Is there a way to automatically have

depends: [
  "x" {= "σ"}
  ...
]

when submitting the package? I tried "x" {= "%%VERSION%%"} but it does not work and would be problematic with pinned packages anyway. What is the recommended way of doing this with topkg?

Best,
C.

With opam v2 you can access the name and version of the current package via _:name and _:version variables but I highly suspect you are not allowed to use these in version constraints.

opam2 has computed dependencies which do this: please see http://opam.ocaml.org/blog/opam-extended-dependencies/#Computedversions

2 Likes

Yes, opam 2 supports this case: see https://opam.ocaml.org/blog/opam-extended-dependencies

Note that I actually looked for this in opam v2’s documentation and found nothing. It would be nice to have it there rather than in a blog post.

It’s probably not explicit enough, but the documentation is actually up-to-date: https://opam.ocaml.org/doc/2.0/Manual.html#Filteredpackageformulas

1 Like

Sorry my bad, I was looking at https://opam.ocaml.org/doc/2.0/Manual.html#PackageFormulas where this should probably be mentioned/linked from.