Opam: use opam2, a local switch, and a fixed remote.

This commit is contained in:
Grégoire Henry 2018-05-25 09:56:14 +02:00
parent cf7de5cc75
commit a7022b2ef0
9 changed files with 42 additions and 56 deletions

View File

@ -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}

View File

@ -37,42 +37,16 @@ The simplest way to install all dependencies is by using `OPAM
**IMPORTANT**: Please use `version 2
<https://opam.ocaml.org/blog/opam-2-0-0-rc2/>`_ of OPAM. That
<https://opam.ocaml.org/blog/opam-2-0-0-rc3/>`_ 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 doesnt 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!
------------------

View File

@ -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'."

View File

@ -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

View File

@ -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:"

View File

@ -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

View File

@ -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."

View File

@ -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

View File

@ -16,6 +16,7 @@ depends: [
"lwt"
"zarith"
"alcotest" { test }
"ocp-indent" { test }
]
build: [
[ "jbuilder" "build" "-p" name "-j" jobs ]