Commit b82f6295 authored by Ralf Jung's avatar Ralf Jung

We should be able to pin a directory, with opam 2

parent 90ad6c48
......@@ -19,7 +19,7 @@ fi
# Make sure we got a good OPAM.
if test -d "$OPAMROOT"; then
echo_color "$BOLDGREEN" "[prepare-opam] Re-using cached opam root"
echo_color "$BOLDGREEN" "[prepare-opam] Refreshing cached opam root"
else
echo_color "$BOLDYELLOW" "[prepare-opam] Creating new opam root (compiler: $OCAML)"
mkdir "$OPAMROOT"
......@@ -28,22 +28,6 @@ else
fi
eval `opam conf env`
# Print some version numbers
opam config report
git --version
echo -n "OCaml version " && ocaml -vnum
echo -n "OCamlc version (/usr/bin) " && /usr/bin/ocamlc -vnum
# Update old opam, if we got a cache.
if [[ -z "$FRESH_OPAM" ]]; then # skip if this is a fresh opam root
# Make sure the pin for the builddep package exists and is up-to-date.
# This avoids opam complaining about pins pointing to a non-existing file.
make build-dep/opam
# Update repositories
opam update
fi
# Make sure we got the right set of repositories registered
if echo "$@" | egrep "(dev|beta)" > /dev/null; then
# We are compiling against a dev version of something. Get ourselves the dev repositories.
......@@ -58,6 +42,23 @@ test -d "$OPAMROOT/repo/coq-released" || opam repo add coq-released https://coq.
test -d "$OPAMROOT/repo/iris-dev" || opam repo add iris-dev https://gitlab.mpi-sws.org/FP/opam-dev.git --rank 20
echo
# Make sure the the builddep package exists and is up-to-date.
make build-dep/opam
# Update old opam, if we got a cache.
if [[ -z "$FRESH_OPAM" ]]; then # skip if this is a fresh opam root
# Update repositories. build-dep/opam must exist here because it might be installed,
# and opam would complain if it had went missing.
opam update
fi
# Print some version numbers
echo_color "$BOLDGREEN" "[prepare-opam] Version report"
opam config report
git --version
echo -n "OCaml version " && ocaml -vnum
echo -n "OCamlc version (/usr/bin) " && /usr/bin/ocamlc -vnum
# We really want to run all of the following in one opam transaction, but due to opam limitations,
# that is not currently possible. Once we use opam 2 for CI, we can first do all the pinning (with `-n`)
# followed by `opam upgrade --all build-dep/` (and hope this will also --fixup).
......@@ -72,24 +73,19 @@ while (( "$#" )); do # while there are arguments left
read -a PIN <<< $(opam pin list | (egrep "^$PACKAGE[. ]"))
echo_color "$BOLDGREEN" "[prepare-opam] $KIND-pinning $PACKAGE to $VERSION"
# We try twice, because opam...
opam pin add -y -n -k "$KIND" "$PACKAGE" "$VERSION" || opam pin add -vv -y -n -k "$KIND" "$PACKAGE" "$VERSION"
opam pin add -y -n -k "$KIND" "$PACKAGE" "$VERSION" || opam pin add -y -n -k "$KIND" "$PACKAGE" "$VERSION" -vv --debug
done
echo
# Pin build-dependencies.
echo_color "$BOLDGREEN" "[prepare-opam] Pinning build-dependencies"
make build-dep OPAMFLAGS="-yn"
echo
# Install everything
BUILD_DEP_PACKAGE="$(egrep "^name:" build-dep/opam | sed 's/^name: *"\(.*\)" */\1/')"
echo_color "$BOLDYELLOW" "[prepare-opam] Installing $BUILD_DEP_PACKAGE and upgrading everything"
if ! opam upgrade -y -a "$BUILD_DEP_PACKAGE"; then
# Pin build-dep and install everything
echo_color "$BOLDYELLOW" "[prepare-opam] Pinning and installing build-dep and upgrading everything"
opam pin add -y -n build-dep/ # we have to do this first, or `opam upgrade` cannot pick it up
if ! opam upgrade -y --all build-dep/; then
# Something went wrong. Try again with more debugging, but then fail anyway.
echo_color "$BOLDRED" "[prepare-opam] Installation failed! Let's try again, sometimes this helps... but more verbose this time"
set -x
opam config list -vv
opam upgrade -yvv -a "$BUILD_DEP_PACKAGE" --debug
opam upgrade -y --all build-dep/ -vv --debug
set +x
fi
echo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment