opam-ci.sh 2.16 KB
Newer Older
Ralf Jung's avatar
Ralf Jung committed
1 2
#!/bin/bash
set -e
Ralf Jung's avatar
Ralf Jung committed
3
## This script installs the build dependencies for CI builds.
Ralf Jung's avatar
Ralf Jung committed
4 5 6 7
function run_and_print() {
    echo "$ $@"
    "$@"
}
Ralf Jung's avatar
Ralf Jung committed
8 9 10

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

Ralf Jung's avatar
Ralf Jung committed
14 15
# Make sure we got a good OPAM.
test -d "$OPAMROOT" || (mkdir "$OPAMROOT" && run_and_print opam init --no-setup -y)
Ralf Jung's avatar
Ralf Jung committed
16
eval `opam conf env`
Ralf Jung's avatar
Ralf Jung committed
17 18 19 20 21 22 23
# Delete old pins from opam.pins times.
run_and_print opam pin remove coq-stdpp -n
run_and_print opam pin remove coq-iris -n
# Make sure the pin for the builddep package is not stale.
run_and_print make build-dep/opam

# Get us all the latest repositories
Ralf Jung's avatar
Ralf Jung committed
24
if test $(find "$OPAMROOT/repo/package-index" -mtime +0); then
Ralf Jung's avatar
Ralf Jung committed
25
    # last update was more than a day ago
Ralf Jung's avatar
Ralf Jung committed
26
    run_and_print opam update
Ralf Jung's avatar
Ralf Jung committed
27
else
Ralf Jung's avatar
Ralf Jung committed
28
    # only update iris-dev
Ralf Jung's avatar
Ralf Jung committed
29
    if test -d "$OPAMROOT/repo/iris-dev"; then run_and_print opam update iris-dev; fi
Ralf Jung's avatar
Ralf Jung committed
30
fi
Ralf Jung's avatar
Ralf Jung committed
31 32 33 34 35
test -d "$OPAMROOT/repo/coq-extra-dev" && run_and_print opam repo remove coq-extra-dev
test -d "$OPAMROOT/repo/coq-core-dev" || run_and_print opam repo add coq-core-dev https://coq.inria.fr/opam/core-dev -p 5
test -d "$OPAMROOT/repo/coq-released" || run_and_print opam repo add coq-released https://coq.inria.fr/opam/released -p 10
test -d "$OPAMROOT/repo/iris-dev" || run_and_print opam repo add iris-dev https://gitlab.mpi-sws.org/FP/opam-dev.git -p 20
echo
Ralf Jung's avatar
Ralf Jung committed
36

37 38 39 40
# 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
41
echo
42 43 44
while (( "$#" )); do # while there are arguments left
    PACKAGE="$1" ; shift
    VERSION="$1" ; shift
45

46 47 48 49 50
    # Check if the pin is already set
    if opam pin list | fgrep "$PACKAGE.$VERSION " > /dev/null; then
        echo "[opam-ci] $PACKAGE already pinned to $VERSION"
    else
        echo "[opam-ci] Pinning $PACKAGE to $VERSION"
Ralf Jung's avatar
Ralf Jung committed
51
        run_and_print opam pin add "$PACKAGE" "$VERSION" -k version -y
52
    fi
Ralf Jung's avatar
Ralf Jung committed
53 54
done

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

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

Ralf Jung's avatar
Ralf Jung committed
65 66 67
# done
echo
coqc -v