diff --git a/Makefile b/Makefile index 0cf79a037..52507ce00 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,17 @@ DEV ?= --dev -PACKAGES:=$(patsubst %.opam,%,$(notdir $(shell find . -name *.opam -print))) +PACKAGES:=$(patsubst %.opam,%,$(notdir $(shell find src vendors -name \*.opam -print))) current_ocaml_version := $(shell ocamlc -version) +current_opam_version := $(shell opam --version) include scripts/version.sh ifneq (${current_ocaml_version},${ocaml_version}) $(error Unexpected ocaml version (found: ${current_ocaml_version}, expected: ${ocaml_version})) endif +ifneq (${current_opam_version},${opam_version}) +$(error Unexpected opam version (found: ${current_opam_version}, expected: ${opam_version})) +endif all: @jbuilder build ${DEV} \ @@ -30,15 +34,15 @@ all: all.pkg: @jbuilder build ${DEV} \ - $(patsubst %.opam,%.install, $(shell find . -name \*.opam -print)) + $(patsubst %.opam,%.install, $(shell find src vendors -name \*.opam -print)) $(addsuffix .pkg,${PACKAGES}): %.pkg: @jbuilder build ${DEV} \ - $(patsubst %.opam,%.install, $(shell find . -name $*.opam -print)) + $(patsubst %.opam,%.install, $(shell find src vendors -name $*.opam -print)) $(addsuffix .test,${PACKAGES}): %.test: @jbuilder build ${DEV} \ - @$(patsubst %/$*.opam,%,$(shell find -name $*.opam))/runtest + @$(patsubst %/$*.opam,%,$(shell find src vendors -name $*.opam))/runtest doc-html: all @jbuilder build @doc ${DEV} diff --git a/docs/introduction/howto.rst b/docs/introduction/howto.rst index f848952b8..1c6602f3a 100644 --- a/docs/introduction/howto.rst +++ b/docs/introduction/howto.rst @@ -37,42 +37,16 @@ The simplest way to install all dependencies is by using `OPAM **IMPORTANT**: Please use `version 2 -`_ of OPAM. That +`_ of OPAM. That is what the Tezos Core team uses. Most distribution probably ship **version 1** of OPAM out of the box, but installing version 2 is preferable for many reasons. -Then, you need to create a new switch alias for Tezos. A switch is your -own version of the OPAM configuration, including the OCaml compiler, all -packages, and package manager configuration related to your project. -This is necessary so that the project doesn’t conflict with other OCaml -projects or other versions of Tezos. - -:: - - opam update - opam switch create tezos 4.06.1 - eval $(opam env) - -If you are stuck with OPAM1: - -:: - - opam update - opam switch tezos --alias-of 4.06.1 - eval $(opam config env) - -The last command-line activates the switch. - -Note that if you previously created a switch named ``tezos`` but with -an older OCaml version you need to remove the switch with ``opam -switch remove tezos``. - Install Tezos dependencies with OPAM ------------------------------------ -Install the libraries which Tezos depends on: +Install the OCaml compiler and the libraries which Tezos depends on: :: @@ -107,17 +81,6 @@ Note that, when executing ``make build-deps``, OPAM will detect if required system dependencies are installed. However, it is not able to detect which versions you actually have. -If after a ``git pull``, the build fails (either at ``make -build-deps`` or ``make``), you might try to clean up a little bit the -opam internal state with the following commands: - -:: - - opam update - opam pin list -s | xargs opam pin remove - make build-deps - make - Join the Alphanet! ------------------ diff --git a/scripts/check_opam_test.sh b/scripts/check_opam_test.sh index bd55a8b4c..d4540c3eb 100755 --- a/scripts/check_opam_test.sh +++ b/scripts/check_opam_test.sh @@ -5,7 +5,7 @@ set -e script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")" src_dir="$(dirname "$script_dir")" -opams=$(find "$src_dir" -name \*.opam -print) +opams=$(find "$src_dir/vendors" "$src_dir/src" -name \*.opam -print) yml="${1:-$src_dir/.gitlab-ci.yml}" @@ -21,7 +21,7 @@ done tested=$(grep -e '^opam:..:tezos-.*:$' "$yml" | cut -d: -f3) for package in $tested; do - found=$(find "$src_dir" -name $package.opam | wc -l 2>&1) + found=$(find "$src_dir/src" "$src_dir/vendors" -name $package.opam | wc -l 2>&1) if [ $found != 1 ] ; then missing=yes echo "Test for unknown package '$package'." diff --git a/scripts/install_build_deps.sh b/scripts/install_build_deps.sh index 3c59518be..2039cf1f1 100755 --- a/scripts/install_build_deps.sh +++ b/scripts/install_build_deps.sh @@ -5,12 +5,27 @@ src_dir="$(dirname "$script_dir")" . "$script_dir"/version.sh +if [ "$(opam --version)" != "$opam_version" ] ; then + echo "Unexpected opam version (found: $(opam -version), expected: $opam_version)" + exit 1 +fi + +opam repository set-url tezos --dont-select $opam_repository || \ + opam repository add tezos --dont-select $opam_repository + +if [ ! -d "$src_dir/_opam" ] ; then + opam switch create "$src_dir" --repositories=tezos ocaml-base-compiler.$ocaml_version +fi + +if [ ! -d "$src_dir/_opam" ] ; then + echo "Failed to create the opam switch" + exit 1 +fi + +eval $(opam env) + if [ "$(ocaml -vnum)" != "$ocaml_version" ]; then - echo ; - echo " Unexpected compiler version ($(ocaml -vnum))"; - echo " You should use ocaml-$ocaml_version."; - echo ; - exit 1; + opam install --unlock-base ocaml-base-compiler.$ocaml_version fi "$script_dir"/opam-unpin.sh @@ -19,4 +34,4 @@ fi opam list --installed depext || opam install depext opam depext $packages -opam install $packages --deps-only +opam install $packages --deps-only --with-test diff --git a/scripts/opam-pin.sh b/scripts/opam-pin.sh index a3291b085..b8f21070e 100755 --- a/scripts/opam-pin.sh +++ b/scripts/opam-pin.sh @@ -7,7 +7,7 @@ src_dir="$(dirname "$script_dir")" export OPAMYES=yes -opams=$(find "$src_dir" -name \*.opam -print) +opams=$(find "$src_dir/vendors" "$src_dir/src" -name \*.opam -print) packages= for opam in $opams; do @@ -18,7 +18,7 @@ for opam in $opams; do opam pin add --no-action $package $dir done -packages=$(opam list --short --all --sort $packages) +packages=$(opam list --short --sort --pinned $packages) echo echo "Pinned packages:" diff --git a/scripts/opam-remove.sh b/scripts/opam-remove.sh index 5fb847e5c..0de2cd8f2 100755 --- a/scripts/opam-remove.sh +++ b/scripts/opam-remove.sh @@ -15,6 +15,6 @@ for opam in $opams; do packages="$packages $package" done -installed=$(opam list --short --installed $packages) +installed=$(opam list --short --installed --pinned $packages) opam remove $installed diff --git a/scripts/opam-upgrade.sh b/scripts/opam-upgrade.sh index a2fee61bc..292214d74 100755 --- a/scripts/opam-upgrade.sh +++ b/scripts/opam-upgrade.sh @@ -26,7 +26,7 @@ silent () { echo "Updating package description..." silent . ./scripts/opam-pin.sh -upgradables=$(opam list --short --installed $packages) +upgradables=$(opam list --short --installed --pinned $packages) if [ -z "$upgradables" ]; then echo "No previously installed package. Nothing to do." diff --git a/scripts/version.sh b/scripts/version.sh index 5ef1dcb82..465a29785 100644 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -7,4 +7,7 @@ alpine_version=3.6 ocaml_version=4.06.1 hidapi_version=0.8.0_rc1 opam_version=2.0.0~rc -opam_tag=2.0.0-rc +opam_tag=2.0.0-rc3 +opam_repository_tag=7db0db5dc53de44d1a0190b1310aa225e04df9ef +opam_repository_url=git+https://gitlab.com/tezos/opam-repository +opam_repository=$opam_repository_url\#$opam_repository_tag diff --git a/src/lib_stdlib/tezos-stdlib.opam b/src/lib_stdlib/tezos-stdlib.opam index 277bec2b2..af2711d8d 100644 --- a/src/lib_stdlib/tezos-stdlib.opam +++ b/src/lib_stdlib/tezos-stdlib.opam @@ -16,6 +16,7 @@ depends: [ "lwt" "zarith" "alcotest" { test } + "ocp-indent" { test } ] build: [ [ "jbuilder" "build" "-p" name "-j" jobs ]