opam-ci.sh 2.2 KB
Newer Older
Ralf Jung's avatar
Ralf Jung committed
1 2
#!/bin/bash
set -e
3
set -x
Ralf Jung's avatar
Ralf Jung committed
4 5 6 7 8 9 10 11
## 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.
12
test -d "$OPAMROOT" || (mkdir "$OPAMROOT" && opam init --no-setup -y)
Ralf Jung's avatar
Ralf Jung committed
13 14 15
eval `opam conf env`

# Make sure the pin for the builddep package is not stale.
16
make build-dep/opam
Ralf Jung's avatar
Ralf Jung committed
17 18

# Update repositories
19 20
opam update

Ralf Jung's avatar
Ralf Jung committed
21
# Make sure we got the right set of repositories registered
22
if echo "$@" | fgrep "dev" > /dev/null; then
Ralf Jung's avatar
Ralf Jung committed
23
    # We are compiling against a dev version of something.  Get ourselves the dev repositories.
24 25
    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
Ralf Jung's avatar
Ralf Jung committed
26 27
else
    # No dev version, make sure we do not have the dev repositories.
28 29
    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
Ralf Jung's avatar
Ralf Jung committed
30
fi
31 32
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
Ralf Jung's avatar
Ralf Jung committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
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.
echo
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
        echo "[opam-ci] $PACKAGE already $KIND-pinned to $VERSION"
    else
        echo "[opam-ci] $KIND-pinning $PACKAGE to $VERSION"
51
        opam pin add -y -k "$KIND" "$PACKAGE" "$VERSION"
Ralf Jung's avatar
Ralf Jung committed
52 53 54 55 56 57
    fi
done

# Upgrade cached things.
echo
echo "[opam-ci] Upgrading opam"
58
opam upgrade -y --fixup
Ralf Jung's avatar
Ralf Jung committed
59 60 61 62 63 64 65 66 67

# Install build-dependencies.
echo
echo "[opam-ci] Installing build-dependencies"
make build-dep OPAMFLAGS=-y

# done
echo
coqc -v