2016-12-08 20:19:44 +04:00
|
|
|
#!/bin/sh
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2016-12-08 20:19:44 +04:00
|
|
|
if ! [ -f 'src/tezos-deps.opam' ]; then
|
|
|
|
echo
|
|
|
|
echo " Please run from the project's root directory. Aborting."
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-12-08 19:27:28 +04:00
|
|
|
|
2016-12-08 20:19:44 +04:00
|
|
|
ocaml_version=4.03.0
|
|
|
|
if [ "$(ocaml -vnum)" != "$ocaml_version" ]; then
|
|
|
|
echo
|
|
|
|
echo " Unexpected compiler version ($(ocaml -vnum))"
|
|
|
|
echo " You should use ocaml-$ocaml_version."
|
|
|
|
echo
|
|
|
|
exit 1
|
2016-09-08 21:13:10 +04:00
|
|
|
fi
|
|
|
|
|
2016-12-08 20:19:44 +04:00
|
|
|
cmd="$1"
|
|
|
|
if [ -z "$cmd" ]; then cmd=all; fi
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2016-12-08 20:19:44 +04:00
|
|
|
case "$cmd" in
|
2016-09-08 21:13:10 +04:00
|
|
|
pin)
|
2016-12-08 20:19:44 +04:00
|
|
|
pin=yes
|
|
|
|
;;
|
2016-09-08 21:13:10 +04:00
|
|
|
depext)
|
2016-12-08 20:19:44 +04:00
|
|
|
depext=yes
|
|
|
|
;;
|
2016-09-08 21:13:10 +04:00
|
|
|
install)
|
2016-12-08 20:19:44 +04:00
|
|
|
install=yes
|
|
|
|
;;
|
2016-09-08 21:13:10 +04:00
|
|
|
all)
|
2016-12-08 20:19:44 +04:00
|
|
|
pin=yes
|
|
|
|
depext=yes
|
|
|
|
install=yes
|
|
|
|
;;
|
2016-09-08 21:13:10 +04:00
|
|
|
*)
|
2016-12-08 20:19:44 +04:00
|
|
|
echo "Unknown command '$cmd'."
|
|
|
|
echo "Usage: $0 [pin|depext|install|all|]"
|
|
|
|
exit 1
|
2016-09-08 21:13:10 +04:00
|
|
|
esac
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
2016-12-08 20:19:44 +04:00
|
|
|
if ! [ -z "$pin" ]; then
|
2016-09-08 21:13:10 +04:00
|
|
|
opam pin --yes remove --no-action --dev-repo ocplib-resto || true
|
|
|
|
opam pin --yes add --no-action --dev-repo sodium
|
|
|
|
opam pin --yes add --no-action --dev-repo ocp-ocamlres
|
2016-11-09 14:40:01 +04:00
|
|
|
opam pin --yes add --no-action --dev-repo ocplib-json-typed
|
2016-09-08 21:13:10 +04:00
|
|
|
opam pin --yes add --no-action --dev-repo ocplib-resto
|
2016-12-08 19:27:28 +04:00
|
|
|
## Force opam to take account of the new `tezos-deps.opam`
|
|
|
|
opam pin --yes remove tezos-deps
|
2016-09-08 21:13:10 +04:00
|
|
|
opam pin --yes add --no-action tezos-deps src
|
|
|
|
fi
|
|
|
|
|
2016-12-08 20:19:44 +04:00
|
|
|
if ! [ -z "$depext" ]; then
|
2016-12-08 19:27:28 +04:00
|
|
|
## In our CI, this rule is executed as user 'root'
|
|
|
|
## The other rules are executed as user 'opam'.
|
2016-09-08 21:13:10 +04:00
|
|
|
opam list --installed depext || opam install depext
|
2016-12-08 20:19:44 +04:00
|
|
|
opam depext tezos-deps
|
2016-09-08 21:13:10 +04:00
|
|
|
fi
|
|
|
|
|
2016-12-08 20:19:44 +04:00
|
|
|
if ! [ -z "$install" ]; then
|
2016-12-08 19:27:28 +04:00
|
|
|
opam install --build-test tezos-deps
|
2016-09-08 21:13:10 +04:00
|
|
|
fi
|