Reputation: 468
I am developing an opam package which, while in the future hopefully will work on all OSes, currently only builds on Linux. I want to tell a user who tries to install on e.g., MacOS, that the process will not succeed. I've seen things like this in the opam package description:
opam-version: "2.0"
authors: "Person Maintainerson"
maintainer: "Person Maintainerson"
build: [
["./configure"
"amd64-linux" {os = "linux"}
"amd64-macosx" {os = "macos"}
"amd64-cygwin" {os = "cygwin"}]
[make]
]
install: [
[make "install"]
]
synopsis: "A one-line description"
url {
src: "proto://path/to/source.tar.gz"
}
But I don't know how to tell opam to not do something.
In the opam manual there is a description about how to print specific messages for failures, but from the example it is not clear to me what the syntax is for <filter>
.
post-messages: [ <string> { <filter> } ... ]
: allows one to print specific messages to the user after the end of installation. The special boolean variable failure is defined in the scope of the filter, and can be used to print messages in case there was an error (typically, a hint on how it can be resolved, or a link to an open issue). success is also defined as syntactic sugar for !failure.
Upvotes: 0
Views: 70
Reputation: 11607
There is an available:
field which should work for this: http://opam.ocaml.org/doc/Packaging.html#Advanced-usage
OS constraints: The available field is a formula that determines your package's availability based on the operating system or other global opam variables. For example:
available: [ os != "macos" ]
In your case I believe it should be [ os = "linux" ]
.
Btw, if you decide to use the dune-project
file to generate your opam
file, you'll need a template, like this: https://github.com/yawaramin/ocaml-decimal/blob/2907175c02ca1bb117ee9703b8d642b721a3d6e8/decimal.opam.template
This is because dune-project
files don't (yet) support the available:
opam field, so they require this extra template file to pass it in.
Upvotes: 1