From de5935228fb212f1d93275aa4928b6150c540a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Wed, 6 Dec 2017 19:52:00 +0100 Subject: [PATCH] Opam: remove `tezos-deps.opam` All dependencies are now inlined in the various opam packages. --- README.md | 2 +- scripts/Dockerfile.build_deps.in | 3 +-- scripts/create_docker_image.build_deps.sh | 10 ++++++- scripts/install_build_deps.sh | 23 ++++------------ scripts/opam-pin.sh | 11 +++++--- scripts/opam-unpin.sh | 2 +- test/lib/node_helpers.ml | 9 ++++++- test/proto_alpha/jbuild | 20 ++++++-------- test/tezos-test.opam | 21 +++++++++++++++ tezos-deps.opam | 33 ----------------------- 10 files changed, 61 insertions(+), 73 deletions(-) create mode 100644 test/tezos-test.opam delete mode 100644 tezos-deps.opam diff --git a/README.md b/README.md index 4f7a3fb30..daa165e5c 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Build instructions ------------------ To compile Tezos, you need an OCaml compiler (version 4.04.2) and all the -libraries listed in `src/tezos-deps.opam`. +libraries listed in the various `tezos-*.opam` files. The best way to install all dependencies is by first installing [OPAM](https://opam.ocaml.org/), the OCaml package manager. diff --git a/scripts/Dockerfile.build_deps.in b/scripts/Dockerfile.build_deps.in index 1e7a9bf2d..39da49d9d 100644 --- a/scripts/Dockerfile.build_deps.in +++ b/scripts/Dockerfile.build_deps.in @@ -6,8 +6,7 @@ FROM $base_image ## /!\ 'COPY'edfiles. ## /!\ /!\ /!\ /!\/!\ /!\ /!\ -COPY scripts/install_build_deps.sh scripts/version.sh tezos/scripts/ -COPY tezos-deps.opam tezos/ +$copy_files RUN sudo apk update && \ opam config exec -- ./tezos/scripts/install_build_deps.sh && \ diff --git a/scripts/create_docker_image.build_deps.sh b/scripts/create_docker_image.build_deps.sh index 534386068..8352a7b41 100755 --- a/scripts/create_docker_image.build_deps.sh +++ b/scripts/create_docker_image.build_deps.sh @@ -23,12 +23,20 @@ cleanup () { } trap cleanup EXIT INT +opam_files=$(find -name \*.opam | sort) +dependencies="$opam_files scripts/install_build_deps.sh scripts/version.sh scripts/opam-pin.sh scripts/opam-unpin.sh scripts/opam-remove.sh Dockerfile" + +for file in $dependencies; do + if [ "$file" = Dockerfile ]; then continue; fi + copy_files="$copy_files\nCOPY $file ./tezos/$file" +done + sed -e 's|$base_image|'"$base_image"'|g' \ -e 's|$ocaml_version|'"$ocaml_version"'|g' \ + -e 's|$copy_files|'"$copy_files"'|g' \ scripts/Dockerfile.build_deps.in > Dockerfile ## Lookup for for prebuilt dependencies... -dependencies="scripts/install_build_deps.sh scripts/version.sh tezos-deps.opam Dockerfile" dependencies_sha1=$(docker inspect --format="{{ .RootFS.Layers }}" --type=image $base_image | sha1sum - $dependencies | sha1sum | tr -d ' -') if [ ! -z "$cached_image" ]; then echo diff --git a/scripts/install_build_deps.sh b/scripts/install_build_deps.sh index 267c268af..3c59518be 100755 --- a/scripts/install_build_deps.sh +++ b/scripts/install_build_deps.sh @@ -3,7 +3,7 @@ script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")" src_dir="$(dirname "$script_dir")" -. "$script_dir/version.sh" +. "$script_dir"/version.sh if [ "$(ocaml -vnum)" != "$ocaml_version" ]; then echo ; @@ -13,23 +13,10 @@ if [ "$(ocaml -vnum)" != "$ocaml_version" ]; then exit 1; fi -set -e -set -x - -### Temporary HACK - -## Should be in sync with `opam-pin.sh` and `opam-unpin.sh` -opam pin --yes add --no-action --dev-repo sodium -opam pin --yes add --no-action --dev-repo ocp-ocamlres -opam pin --yes add --no-action --dev-repo ocplib-json-typed - -### End of temporary HACK - -## Force opam to take account of the new `tezos-deps.opam` -opam pin --yes remove tezos-deps -opam pin --yes add --no-action tezos-deps $src_dir +"$script_dir"/opam-unpin.sh +. "$script_dir"/opam-pin.sh opam list --installed depext || opam install depext -opam depext tezos-deps +opam depext $packages -opam install tezos-deps --deps-only +opam install $packages --deps-only diff --git a/scripts/opam-pin.sh b/scripts/opam-pin.sh index 315a5e1e0..15f0badf9 100755 --- a/scripts/opam-pin.sh +++ b/scripts/opam-pin.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 tezos-deps.opam -prune -or -name \*.opam -print) +opams=$(find "$src_dir" -name \*.opam -print) export OPAMYES=yes @@ -22,11 +22,14 @@ packages=$(opam list --short --all --sort $packages) ### Temporary HACK -## Should be in sync with `install-build-deps.sh` and `opam-unpin.sh` +## Should be in sync with `opam-unpin.sh` opam pin add --no-action --dev-repo sodium opam pin add --no-action --dev-repo ocp-ocamlres opam pin add --no-action --dev-repo ocplib-json-typed -opam remove tezos-deps || true - ### End of temporary HACK + +echo +echo "Pinned packages:" +echo "$packages" | sed 's/^/ /' +echo diff --git a/scripts/opam-unpin.sh b/scripts/opam-unpin.sh index a6ef9db3f..ab2c6af92 100755 --- a/scripts/opam-unpin.sh +++ b/scripts/opam-unpin.sh @@ -11,7 +11,7 @@ opam pin remove $packages ### Temporary HACK -## Should be in sync with `install-build-deps.sh` and `opam-pin.sh` +## Should be in sync with `opam-pin.sh` opam pin remove --no-action sodium opam pin remove --no-action ocp-ocamlres opam pin remove --no-action ocplib-json-typed diff --git a/test/lib/node_helpers.ml b/test/lib/node_helpers.ml index 9b06b9d3c..2008e63f4 100644 --- a/test/lib/node_helpers.ml +++ b/test/lib/node_helpers.ml @@ -38,7 +38,14 @@ let fork_node ?(timeout = 4) ?(port = 18732) ?sandbox () = let null_fd = Unix.(openfile "/dev/null" [O_RDONLY] 0o644) in let exe = let (//) = Filename.concat in - Sys.getcwd () // ".." // "bin_node" // "main.exe" in + try + let path = Sys.argv.(1) in + if Filename.is_relative path then + Sys.getcwd () // ".." // path + else + path + with _ -> Sys.getcwd () // ".." // "bin_node" // "main.exe" in + Format.eprintf "EXE %s@." exe ; let pid = Unix.create_process exe [| "tezos-node" ; diff --git a/test/proto_alpha/jbuild b/test/proto_alpha/jbuild index 5daacb3a1..831bb0587 100644 --- a/test/proto_alpha/jbuild +++ b/test/proto_alpha/jbuild @@ -30,31 +30,27 @@ (alias ((name runtest_endorsement) - (deps (../../bin_node/main.exe - sandbox.json)) + (deps (sandbox.json)) (locks (/tcp-port/18100)) - (action (run ${exe:test_endorsement.exe})))) + (action (chdir ${ROOT} (run ${exe:test_endorsement.exe} ${bin:tezos-node}))))) (alias ((name runtest_origination) - (deps (../../bin_node/main.exe - sandbox.json)) + (deps (sandbox.json)) (locks (/tcp-port/18200)) - (action (run ${exe:test_origination.exe})))) + (action (chdir ${ROOT} (run ${exe:test_origination.exe} ${bin:tezos-node}))))) (alias ((name runtest_transaction) - (deps (../../bin_node/main.exe - sandbox.json)) + (deps (sandbox.json)) (locks (/tcp-port/18300)) - (action (run ${exe:test_transaction.exe})))) + (action (chdir ${ROOT} (run ${exe:test_transaction.exe} ${bin:tezos-node}))))) (alias ((name runtest_vote) - (deps (../../bin_node/main.exe - sandbox-vote.json)) + (deps (sandbox-vote.json)) (locks (/tcp-port/18400)) - (action (run ${exe:test_vote.exe})))) + (action (chdir ${ROOT} (run ${exe:test_vote.exe} ${bin:tezos-node}))))) (alias ((name runtest) diff --git a/test/tezos-test.opam b/test/tezos-test.opam new file mode 100644 index 000000000..a4fb9684a --- /dev/null +++ b/test/tezos-test.opam @@ -0,0 +1,21 @@ +opam-version: "1.2" +version: "dev" +maintainer: "contact@tezos.com" +authors: [ "Tezos devteam" ] +homepage: "https://www.tezos.com/" +bug-reports: "https://gitlab.com/tezos/tezos/issues" +dev-repo: "https://gitlab.com/tezos/tezos.git" +license: "unreleased" +depends: [ + "ocamlfind" { build } + "jbuilder" { build & >= "1.0+beta15" } + "tezos-node" + "tezos-client" + "kaputt" +] +build: [ + [ "jbuilder" "build" "-p" name "-j" jobs "@buildtest" ] +] +build-test: [ + [ "jbuilder" "runtest" "-p" name "-j" jobs ] +] diff --git a/tezos-deps.opam b/tezos-deps.opam deleted file mode 100644 index 689af690e..000000000 --- a/tezos-deps.opam +++ /dev/null @@ -1,33 +0,0 @@ -opam-version: "1.2" -version: "dev" -maintainer: "contact@tezos.com" -authors: [ "Tezos devteam" ] -homepage: "https://www.tezos.com/" -bug-reports: "https://gitlab.com/tezos/tezos/issues" -dev-repo: "https://gitlab.com/tezos/tezos.git" -license: "unreleased" -depends: [ - "ocamlfind" { build } - "jbuilder" { build & >= "1.0+beta15" } - "base-bigarray" - "base-threads" - "conf-libev" - "calendar" - "cohttp" { >= "1.0.0" } - "conduit" - "ezjsonm" { >= "0.5.0" } - "irmin" { >= "1.3" } - "lwt" { >= "3.0.0" } - "lwt_ssl" - "menhir" - "mtime" { >= "1.0.0" } - "ocp-ocamlres" { >= "dev" } - "ocplib-endian" - "ocplib-json-typed" - "reactiveData" - "sodium" { >= "0.3.0" } - "magic-mime" - "leveldb" { >= "1.1.2" } - "kaputt" # { test } - "bisect_ppx" # { test } -]