diff --git a/build-infer.sh b/build-infer.sh index 72b4649f5..54649bab1 100755 --- a/build-infer.sh +++ b/build-infer.sh @@ -17,6 +17,8 @@ INFER_DEPS_DIR="$INFER_ROOT/dependencies/infer-deps" PLATFORM="$(uname)" NCPU="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)" OCAML_VERSION="4.04.0" +OPAM_LOCK_URL=${OPAM_LOCK_URL:-"https://github.com/rgrinberg/opam-lock"} + INFER_OPAM_SWITCH_DEFAULT=infer-"$OCAML_VERSION" function usage() { @@ -31,6 +33,7 @@ function usage() { echo " -h,--help show this message" echo " --only-install-opam install the opam dependencies of infer and exists" echo " --opam-switch specify the opam switch where to install infer (default: $INFER_OPAM_SWITCH_DEFAULT)" + echo " --no-opam-lock do not use the opam.lock file and let opam resolve dependencies" echo " -y,--yes automatically agree to everything" echo echo " examples:" @@ -45,6 +48,7 @@ BUILD_JAVA=${BUILD_JAVA:-no} INTERACTIVE=${INTERACTIVE:-yes} ONLY_SETUP_OPAM=${ONLY_SETUP_OPAM:-no} INFER_OPAM_SWITCH=${INFER_OPAM_SWITCH:-$INFER_OPAM_SWITCH_DEFAULT} +USE_OPAM_LOCK=${USE_OPAM_LOCK:-yes} ORIG_ARGS="$*" while [[ $# > 0 ]]; do @@ -70,6 +74,11 @@ while [[ $# > 0 ]]; do usage exit 0 ;; + --no-opam-lock) + USE_OPAM_LOCK=no + shift + continue + ;; --opam-switch) shift [[ $# > 0 ]] || (usage; exit 1) @@ -121,20 +130,10 @@ setup_opam () { opam switch set -j $NCPU $INFER_OPAM_SWITCH --alias-of $OCAML_VERSION } -add_opam_git_pin () { - PACKAGE_NAME=$1 - REPO_URL=$2 - PIN_HASH=$3 - - if [ "$(opam show -f pinned "$PACKAGE_NAME")" != "git ($PIN_HASH)" ]; then - opam pin add --no-action "$PACKAGE_NAME" "$REPO_URL" - fi -} - # Install and record the infer dependencies in opam. The main trick is to install the # $INFER_DEPS_DIR directory instead of the much larger infer repository. That directory contains # just enough to pretend it installs infer. -install_opam_deps () { +install_infer-deps () { # remove previous infer-deps pin, which might have conflicting dependencies opam pin remove infer-deps --no-action INFER_TMP_DEPS_DIR=$(mktemp -d "$INFER_ROOT"/dependencies/infer-deps-XXXX) @@ -150,6 +149,23 @@ install_opam_deps () { opam pin add infer-deps "$INFER_DEPS_DIR" } +install_locked_deps() { + if ! opam lock 2> /dev/null; then + echo "opam-lock not found in the current switch, installing from '$OPAM_LOCK_URL'..." + opam pin add -k git lock "$OPAM_LOCK_URL" + fi + opam lock --install < "$INFER_ROOT"/opam.lock +} + +install_opam_deps() { + if [ "$USE_OPAM_LOCK" = yes ]; then + install_locked_deps + else + install_infer-deps + fi +} + + echo "initializing opam... " check_installed opam if [ "$INFER_OPAM_SWITCH" = "$INFER_OPAM_SWITCH_DEFAULT" ]; then @@ -159,7 +175,8 @@ else opam switch set -j $NCPU $INFER_OPAM_SWITCH fi eval $(SHELL=bash opam config env --switch=$INFER_OPAM_SWITCH) -echo "installing infer dependencies... " +echo +echo "installing infer dependencies; this can take up to 30 minutes... " install_opam_deps || ( \ echo; \ echo '*** Failed to install opam dependencies'; \ diff --git a/opam.lock b/opam.lock new file mode 100644 index 000000000..3c6cda43b --- /dev/null +++ b/opam.lock @@ -0,0 +1,69 @@ +ANSITerminal = 0.7 +atd = 1.2.0 +atdgen = 1.10.0 +bin_prot = 113.33.00+4.03 +biniou = 1.0.12 +camlp4 = 4.04+1 +camlzip = 1.07 +camomile = 0.8.5 +conf-autoconf = 0.1 +conf-m4 = 1 +conf-pkg-config = 1.0 +conf-which = 1 +core = 113.33.02+4.03 +core_kernel = 113.33.02+4.03 +cppo = 1.4.1 +ctypes = 0.11.3 +easy-format = 1.2.0 +extlib-compat = 1.7.0 +fieldslib = 113.24.00 +javalib = 2.3.3 +jbuilder = 1.0+beta6 +lambda-term = 1.10.1 +lwt = 2.7.1 +menhir = 20170101 +merlin-extend = 0.3 +ocaml-migrate-parsetree = 0.7 +ocamlbuild = 0.11.0 +ocamlfind = 1.7.1 +ounit = 2.0.0 +ppx_assert = 113.33.00 +ppx_bench = 113.33.00+4.03 +ppx_bin_prot = 113.33.00+4.03 +ppx_compare = 113.33.00+4.03 +ppx_core = 113.33.01+4.03 +ppx_custom_printf = 113.33.00+4.03 +ppx_deriving = 4.1 +ppx_driver = 113.33.02+4.03 +ppx_enumerate = 113.33.00+4.03 +ppx_expect = 113.33.01+4.03 +ppx_fail = 113.33.00+4.03 +ppx_fields_conv = 113.33.00+4.03 +ppx_here = 113.33.00 +ppx_inline_test = 113.33.00+4.03 +ppx_jane = 113.33.00 +ppx_let = 113.33.00+4.03 +ppx_optcomp = 113.33.01+4.03 +ppx_pipebang = 113.33.00+4.03 +ppx_sexp_conv = 113.33.01+4.03 +ppx_sexp_message = 113.33.00+4.03 +ppx_sexp_value = 113.33.00+4.03 +ppx_tools = 5.0 +ppx_tools_versioned = 5.0alpha +ppx_type_conv = 113.33.02+4.03 +ppx_typerep_conv = 113.33.00+4.03 +ppx_variants_conv = 113.33.00+4.03 +re = 1.7.1 +react = 1.2.0 +reason = 1.13.4 +reason-parser = 1.13.4 +result = 1.2 +sawja = 1.5.2 +sexplib = 113.33.00+4.03 +topkg = 0.8.1 +typerep = 113.24.00 +utop = 1.19.3 +variantslib = 113.24.00 +xmlm = 1.2.0 +yojson = 1.3.3 +zed = 1.4