I maintain a bunch of OCaml packages for the MacPorts ecosystem. (In fact, I seem to be the only person working on MacPorts who does OCaml ecosystem packaging.) For those that don’t know, MacPorts is a third party package manager for macOS, much like Brew (for those that know that), or like the package managers in various Linux releases (like “dpkg” or “rpm”).
It would be nice to just tell people “go and use OPAM for everything” and not even maintain any OCaml packages for MacPorts, but there are people who want to install end user software constructed with OCaml who don’t even know it’s built with OCaml and don’t want to learn how to use OPAM. It’s also often quite handy to bootstrap your OCaml environment by building a system OCaml binary and opam binary (which is what I do) from whence opam can bootstrap.
So I’m stuck maintaining some set of packages for MacPorts that can build various OCaml libraries and tools, much as someone maintaining such tools for Debian or Ubuntu or Fedora would be. I want to make the process less painful. I’m soliciting ideas.
To explain the overall problem: in MacPorts, each package is defined by a file called a “Portfile”, which is sort of like an opam file (though much richer in some ways and much poorer in others). Each Portfile is written (mostly) by hand, and specifies all the usual things, like how to fetch the sources for a package, what the cryptographic hash of the package tarfile is, how build a package, what other packages this package depends on, etc. (The Portfile syntax has the odd feature that it’s really Tcl, and thus is Turing equivalent, which often comes in handy.)
The MacPorts build system expects to take the information in the Portfile, build a given package, and then install it into a “destroot”, a fake install location, from whence it gets turned into a binary package and then the binary package gets installed for real into the final location for the user to use.
Constructing each and every Portfile for the large number of OCaml libraries and tools is tedious, and figuring out for every package how to build that particular package’s binaries is tedious.
What I’d like, ideally, is a way to leverage the opam ecosystem to minimize the work. The most obvious way would be to get opam to tell me things like “this is the set of dependencies this package has” or “this is the command for building this package” or “this is the command for installing this package”. I can then use those either to manually construct a portfile, or to create some sort of automatic opam file to Portfile tool.
However, opam doesn’t seem to have the right hooks for this. Or if it does, I can’t figure out what they would be.
Anyone have ideas on what I might be able to do here?