prepare-opam.sh 2.51 KB
Newer Older
1 2 3 4 5 6 7 8
## This script installs the build dependencies for CI builds.

# Prepare OPAM configuration
export OPAMROOT="$(pwd)/opamroot"
export OPAMJOBS="$((2*$CPU_CORES))"
export OPAM_EDITOR="$(which false)"

# Make sure we got a good OPAM.
Ralf Jung's avatar
Ralf Jung committed
9
if test -d "$OPAMROOT"; then
Ralf Jung's avatar
Ralf Jung committed
10
    echo_color "$BOLDGREEN" "[prepare-opam] Re-using cached opam root"
Ralf Jung's avatar
Ralf Jung committed
11
else
Ralf Jung's avatar
Ralf Jung committed
12
    echo_color "$BOLDYELLOW" "[prepare-opam] Creating new opam root"
Ralf Jung's avatar
Ralf Jung committed
13 14 15
    mkdir "$OPAMROOT"
    opam init --no-setup -y
fi
16 17
eval `opam conf env`

Ralf Jung's avatar
Ralf Jung committed
18
# Make sure the pin for the builddep package exists and is up-to-date
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
make build-dep/opam

# Update repositories
opam update

# Make sure we got the right set of repositories registered
if echo "$@" | fgrep "dev" > /dev/null; then
    # We are compiling against a dev version of something.  Get ourselves the dev repositories.
    test -d "$OPAMROOT/repo/coq-extra-dev" || opam repo add coq-extra-dev https://coq.inria.fr/opam/extra-dev -p 0
    test -d "$OPAMROOT/repo/coq-core-dev" || opam repo add coq-core-dev https://coq.inria.fr/opam/core-dev -p 5
else
    # No dev version, make sure we do not have the dev repositories.
    test -d "$OPAMROOT/repo/coq-extra-dev" && opam repo remove coq-extra-dev
    test -d "$OPAMROOT/repo/coq-core-dev" && opam repo remove coq-core-dev
fi
test -d "$OPAMROOT/repo/coq-released" || opam repo add coq-released https://coq.inria.fr/opam/released -p 10
test -d "$OPAMROOT/repo/iris-dev" || opam repo add iris-dev https://gitlab.mpi-sws.org/FP/opam-dev.git -p 20
echo

# We really want to run all of the following in one opam transaction, but due to opam limitations,
# that is not currently possible.

# Install fixed versions of some dependencies.
Ralf Jung's avatar
Ralf Jung committed
42
echo_color "$BOLDGREEN" "[prepare-opam] Processing pins"
43 44 45 46 47 48 49 50
while (( "$#" )); do # while there are arguments left
    PACKAGE="$1" ; shift
    KIND="$1" ; shift
    VERSION="$1" ; shift

    # Check if the pin is already set
    read -a PIN <<< $(opam pin list | (egrep "^$PACKAGE[. ]"))
    if [[ "${PIN[1]}" == "$KIND" && "${PIN[2]}" == "$VERSION" ]]; then
Ralf Jung's avatar
Ralf Jung committed
51
        echo_color "$BOLDGREEN" "[prepare-opam] $PACKAGE already $KIND-pinned to $VERSION"
52
    else
Ralf Jung's avatar
Ralf Jung committed
53
        echo_color "$BOLDYELLOW" "[prepare-opam] $KIND-pinning $PACKAGE to $VERSION"
54 55 56
        opam pin add -y -k "$KIND" "$PACKAGE" "$VERSION"
    fi
done
Ralf Jung's avatar
Ralf Jung committed
57
echo
58 59

# Upgrade cached things.
Ralf Jung's avatar
wording  
Ralf Jung committed
60
echo_color "$BOLDGREEN" "[prepare-opam] Upgrading packages"
61
opam upgrade -y --fixup && opam upgrade -y
Ralf Jung's avatar
Ralf Jung committed
62
echo
63 64

# Install build-dependencies.
Ralf Jung's avatar
Ralf Jung committed
65
echo_color "$BOLDGREEN" "[prepare-opam] Installing build-dependencies"
66
make build-dep OPAMFLAGS=-y
Ralf Jung's avatar
Ralf Jung committed
67
echo
68 69 70 71

# done
echo
coqc -v