[opam-devel] What context do install an remove run in?

Thomas Gazagnaire thomas at gazagnaire.org
Tue Sep 8 11:07:08 BST 2015


>>> This is unclear to be from the documentation, but what context to the
>>> commands `install` and `remove` sections of an opam file run in?  I
>>> would assume `install` runs in the directory of the built source, but
>>> does `remove` have that same guarantee?  Would that also mean that the
>>> built source is kept around with the package?  I ask because I would
>>> like to simplify my opam files by having a 'make remove' entry.
>> 
>> They run in an unpacked source tree as the pwd.  However, this is not
>> cached across build runs -- instead, the source is freshly unpacked and
>> made available to the remove target.  So you just need to make sure
>> that you run the `configure` script if relevant.
>> 
>> There's a special case for `ocamlfind remove` that doesn't do this;
>> this will likely have to be generalised as OPAM moves the OCaml-specific
>> logic into a separate plugin.
> 
> Can I tell opam to figure this out via ocamlfind on its own or do is the
> special case just checking if the command is "ocamlfind remove ..."?
> Basically, I'm trying to make all of my opam files almost exactly the
> same, except for deps, and push the unique actions into the package
> itself, like install and remove.  The hope is to simplify making opam
> packages of my tools.

The easiest way to handle uninstall is to generate an <pkg.install> file. Otherwise, there is indeed a special syntactic treatment for "ocamlfind remove" commands (where the tarball is not downloaded and extracted again). If you really want to have a "make remove" command, as Anil said you should do "./configure --prefix=... && make remove"

Thomas



More information about the opam-devel mailing list