OCamlPro/opam — pull request #519 by gasche (2013-03-09 20:33:26+00:00)
Title: do not delete .opam/$SWITCH when installing 'opam switch install $SWITCH' and 'preinstalled' is true

This commit reverts some defensive logic introduced in commit
> commit 720daaf4e14983cec1138ad9f9c06c548208ded9
> Author: Thomas Gazagnaire
> Date: Thu Nov 15 13:17:41 2012 +0100
>
> Be more robust when a switch 's' does not appear in ~/.opam/aliases
> but there is a ~/.opam/s directory. This is the sign that something
> bad happened.

in the case where 'preinstalled' is set.

The rationale is to enable new use-cases for 'preinstalled' (that is
currently only used to describe the system compiler), more precisely
the fact of exposing development builds of OCaml as opam compilers:
configure the OCaml trunk with --prefix=~/.opam/foo, create a config
file for compiler 'foo' with 'preinstalled: true', then install the
OCaml distribution (make install) and finally 'opam switch foo'.

The current clean-up logic makes the last step remove the OCaml
binaries that have been installed in ~/.opam/foo/bin by OCaml's
installation step.

There is a compromise between "safety" (the current behavior that is
resilient to install failures) and this new, advanced
use-case. I think it is okay to say that people installing compilers
with 'preinstalled: true' (currently nobody, I believe) are in expert
situations, and let them clean ~/.opam/foo by hand if something goes
wrong.

(There is in fact a work-around to support this advanced use-case
without applying this patch: you could run "opam switch install foo"
*before* OCaml's "make install". But this exposes 'foo' as an existing
OPAM compiler before it actually makes sense to do so, as no compiler
is installed yet. I believe fixing this behavior is a better way to go
forward with interesting uses of 'preinstalled'.)