opam-ci.sh 2.23 KB
Newer Older
1 2
#!/bin/bash
set -e
Ralf Jung's avatar
Ralf Jung committed
3
set -x
Ralf Jung's avatar
Ralf Jung committed
4
## This script installs the build dependencies for CI builds.
5 6 7

# Prepare OPAM configuration
export OPAMROOT="$(pwd)/opamroot"
Ralf Jung's avatar
Ralf Jung committed
8
export OPAMJOBS="$((2*$CPU_CORES))"
9 10
export OPAM_EDITOR="$(which false)"

Ralf Jung's avatar
Ralf Jung committed
11
# Make sure we got a good OPAM.
Ralf Jung's avatar
Ralf Jung committed
12
test -d "$OPAMROOT" || (mkdir "$OPAMROOT" && opam init --no-setup -y)
13
eval `opam conf env`
Ralf Jung's avatar
Ralf Jung committed
14

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

Ralf Jung's avatar
Ralf Jung committed
18
# Update repositories
Ralf Jung's avatar
Ralf Jung committed
19
opam update
20

Ralf Jung's avatar
Ralf Jung committed
21
# Make sure we got the right set of repositories registered
Ralf Jung's avatar
Ralf Jung committed
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.
Ralf Jung's avatar
Ralf Jung committed
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.
Ralf Jung's avatar
Ralf Jung committed
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
Ralf Jung's avatar
Ralf Jung committed
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
echo

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

Ralf Jung's avatar
Ralf Jung committed
38
# Install fixed versions of some dependencies.
39 40 41
echo
while (( "$#" )); do # while there are arguments left
    PACKAGE="$1" ; shift
Ralf Jung's avatar
Ralf Jung committed
42
    KIND="$1" ; shift
43
    VERSION="$1" ; shift
Ralf Jung's avatar
Ralf Jung committed
44

45
    # Check if the pin is already set
Ralf Jung's avatar
Ralf Jung committed
46 47 48
    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"
49
    else
Ralf Jung's avatar
Ralf Jung committed
50
        echo "[opam-ci] $KIND-pinning $PACKAGE to $VERSION"
Ralf Jung's avatar
Ralf Jung committed
51
        opam pin add -y -k "$KIND" "$PACKAGE" "$VERSION"
52 53 54
    fi
done

Ralf Jung's avatar
Ralf Jung committed
55 56 57
# Upgrade cached things.
echo
echo "[opam-ci] Upgrading opam"
58
opam upgrade -y --fixup && opam upgrade -y
Ralf Jung's avatar
Ralf Jung committed
59 60

# Install build-dependencies.
61
echo
Ralf Jung's avatar
Ralf Jung committed
62 63
echo "[opam-ci] Installing build-dependencies"
make build-dep OPAMFLAGS=-y
64 65

# done
Ralf Jung's avatar
Ralf Jung committed
66
set +x
67 68
echo
coqc -v