diff --git a/scripts/ci/create_binary.opam.sh b/scripts/ci/create_binary.opam.sh index 4c8262e53..953b8e1c3 100755 --- a/scripts/ci/create_binary.opam.sh +++ b/scripts/ci/create_binary.opam.sh @@ -45,7 +45,7 @@ echo cp -a "$build_dir"/opam-$opam_tag.tgz "$tmp_dir" cat < "$tmp_dir"/Dockerfile -FROM ocaml/opam:alpine-${alpine_version}_ocaml-4.06.0 +FROM ocaml/opam:alpine-3.6_ocaml-4.06.0 ENV PACKAGER "Tezos " COPY opam-$opam_tag.tgz opam-$opam_tag.tgz RUN tar xzf opam-$opam_tag.tgz && \ diff --git a/scripts/ci/create_docker_image.build_deps.sh b/scripts/ci/create_docker_image.build_deps.sh index 383c86859..a07ce79e6 100755 --- a/scripts/ci/create_docker_image.build_deps.sh +++ b/scripts/ci/create_docker_image.build_deps.sh @@ -19,32 +19,18 @@ 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" +dependencies="$opam_files scripts/install_build_deps.raw.sh scripts/version.sh scripts/opam-pin.sh scripts/opam-unpin.sh scripts/opam-remove.sh" image_name="${1:-tezos_build_deps}" image_version="${2:-latest}" base_image="${3:-tezos_opam:alpine-${alpine_version}_ocaml-${ocaml_version}}" cached_image="${4:-}" -test_deps="ocp-indent alcotest.0.8.3 alcotest-lwt crowbar" cat < "$tmp_dir"/Dockerfile FROM $base_image COPY . tezos RUN sudo chown -R opam tezos -RUN opam exec -- ./tezos/scripts/install_build_deps.sh || \ - ( echo ; \ - echo "### Failed to build with preloaded package" ; \ - echo "### Retrying with the default opam repository" ; \ - echo ; \ - opam remote add default https://opam.ocaml.org/2.0 && \ - opam exec -- ./tezos/scripts/install_build_deps.sh ) -RUN opam install --yes $test_deps || \ - ( echo ; \ - echo "### Failed to build with preloaded package" ; \ - echo "### Retrying with the default opam repository" ; \ - echo ; \ - opam remote add default https://opam.ocaml.org/2.0 && \ - opam install --yes $test_deps ) +RUN cd tezos && opam exec -- ./scripts/install_build_deps.raw.sh EOF tar -c $dependencies | tar -C "$tmp_dir" -x diff --git a/scripts/ci/create_docker_image.opam.sh b/scripts/ci/create_docker_image.opam.sh index b9ff19a63..2273ffeeb 100755 --- a/scripts/ci/create_docker_image.opam.sh +++ b/scripts/ci/create_docker_image.opam.sh @@ -38,7 +38,7 @@ cp -a "$build_dir"/hidapi-$hidapi_version-r0.apk \ cp "$build_dir"/opam-$opam_tag "$tmp_dir/opam" cp "$build_dir"/opam-installer-$opam_tag "$tmp_dir/opam-installer" -tar -C "$tmp_dir" -xzf "$build_dir"/opam_repository-tezos_deps-$ocaml_version.tgz +tar -C "$tmp_dir" -xzf "$build_dir"/opam_repository-tezos_deps-$ocaml_version-$opam_repository_tag.tgz cat < "$tmp_dir"/Dockerfile FROM alpine:$alpine_version @@ -73,11 +73,11 @@ RUN mkdir ~/.ssh && \ chmod 700 ~/.ssh && \ git config --global user.email "ci@tezos.com" && \ git config --global user.name "Tezos CI" && \ - opam init --bare --no-setup --yes \ + opam init --disable-sandboxing --bare --no-setup --yes \ tezos_deps /home/opam/opam-repository-tezos_deps && \ - opam switch create --yes tezos ocaml-base-compiler.${ocaml_version} + opam switch create --yes /home/opam/tezos ocaml-base-compiler.${ocaml_version} -RUN opam install --yes opam-depext +RUN opam install --switch=/home/opam/tezos --yes opam-depext ENTRYPOINT [ "opam", "exec", "--" ] CMD [ "/bin/bash" ] diff --git a/scripts/ci/create_opam_repository.tezos_deps.sh b/scripts/ci/create_opam_repository.tezos_deps.sh index fa8cc543d..162b1d8eb 100755 --- a/scripts/ci/create_opam_repository.tezos_deps.sh +++ b/scripts/ci/create_opam_repository.tezos_deps.sh @@ -11,7 +11,7 @@ cd "$src_dir" build_dir=${build_dir:-_docker_build} -if [ -f "$build_dir/opam_repository-tezos_deps-$ocaml_version.tgz" ]; then +if [ -f "$build_dir/opam_repository-tezos_deps-$ocaml_version-$opam_repository_tag.tgz" ]; then exit 0 fi @@ -30,7 +30,7 @@ trap cleanup EXIT INT ## Creating a repository of tezos packages repo="$tmp_dir"/opam-repository-tezos -opams=$(find "$src_dir" -name \*.opam -print) +opams=$(find "$src_dir/src" "$src_dir"/vendors -name \*.opam -print) mkdir -p "$repo/packages" echo "1.2" > "$repo/version" packages= @@ -50,15 +50,9 @@ done # inline some of the test and doc dependencies. extra_packages="depext alcotest-lwt ocp-indent odoc ounit crowbar" -if ! [ -f "$build_dir"/opam-repository-master.tgz ]; then - echo - echo "### Fetching opam-repository-master.tar.gz ..." - echo - mkdir -p "$build_dir" - wget -O "$build_dir"/opam-repository-master.tgz \ - https://github.com/ocaml/opam-repository/archive/master.tar.gz -fi -tar -C "$tmp_dir" -xzf "$build_dir"/opam-repository-master.tgz +git clone $opam_repository_url "$tmp_dir/opam-repository-master" +git -C "$tmp_dir"/opam-repository-master reset --hard $opam_repository_tag +rm -rf "$tmp_dir"/opam-repository-master/.git ## HACK: Once opam2 is released, we should use the `ocaml/opam` image ## instead of this custom installation of ocaml and opam. @@ -71,17 +65,15 @@ echo "### Building tezos_bundle.tar.gz..." echo cat < "$tmp_dir"/Dockerfile -FROM alpine +FROM alpine:3.7 ENV PACKAGER "Tezos " COPY opam-repository-master opam-repository-master COPY opam /usr/local/bin/opam RUN apk add --no-cache ocaml build-base m4 tar xz bzip2 curl perl rsync -RUN cd ./opam-repository-master/compilers && \ - ( ls -1 | grep -v ${ocaml_version} | xargs rm -r ) -RUN opam init --no-setup --yes default ./opam-repository-master +RUN opam init --disable-sandboxing --no-setup --yes default ./opam-repository-master RUN opam install --yes opam-bundle COPY opam-repository-tezos opam-repository-tezos -RUN opam bundle --yes --output="tezos_bundle-$ocaml_version" \ +RUN opam bundle --yes --output="tezos_bundle-$ocaml_version-$opam_repository_tag" \ --repository=opam-repository-tezos \ --repository=opam-repository-master \ --ocaml=$ocaml_version \ @@ -91,20 +83,20 @@ EOF docker build --pull -t $tmp_image "$tmp_dir" container=$(docker create $tmp_image) -docker cp -L $container:/tezos_bundle-$ocaml_version.tar.gz "$tmp_dir" +docker cp -L $container:/tezos_bundle-$ocaml_version-$opam_repository_tag.tar.gz "$tmp_dir" cd "$tmp_dir" -tar xf tezos_bundle-$ocaml_version.tar.gz tezos_bundle-$ocaml_version/repo +tar xf tezos_bundle-$ocaml_version-$opam_repository_tag.tar.gz tezos_bundle-$ocaml_version-$opam_repository_tag/repo # removing fake tezos packages -cd tezos_bundle-$ocaml_version/repo/packages +cd tezos_bundle-$ocaml_version-$opam_repository_tag/repo/packages rm -r $packages # Repacking the repo cd "$tmp_dir" -mv tezos_bundle-$ocaml_version/repo opam_repository-tezos_deps -tar czf "opam_repository-tezos_deps-$ocaml_version.tgz" \ +mv tezos_bundle-$ocaml_version-$opam_repository_tag/repo opam_repository-tezos_deps +tar czf "opam_repository-tezos_deps-$ocaml_version-$opam_repository_tag.tgz" \ opam_repository-tezos_deps cd "$src_dir" -mv "$tmp_dir"/opam_repository-tezos_deps-$ocaml_version.tgz "$build_dir" +mv "$tmp_dir"/opam_repository-tezos_deps-$ocaml_version-$opam_repository_tag.tgz "$build_dir" diff --git a/scripts/install_build_deps.raw.sh b/scripts/install_build_deps.raw.sh new file mode 100755 index 000000000..fa050459b --- /dev/null +++ b/scripts/install_build_deps.raw.sh @@ -0,0 +1,13 @@ +#! /bin/sh + +script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")" +src_dir="$(dirname "$script_dir")" + +. "$script_dir"/version.sh + +"$script_dir"/opam-unpin.sh +. "$script_dir"/opam-pin.sh + +opam depext $packages + +opam install $packages --deps-only --with-test diff --git a/scripts/install_build_deps.sh b/scripts/install_build_deps.sh index 2039cf1f1..5b2f8ab90 100755 --- a/scripts/install_build_deps.sh +++ b/scripts/install_build_deps.sh @@ -28,10 +28,6 @@ if [ "$(ocaml -vnum)" != "$ocaml_version" ]; then opam install --unlock-base ocaml-base-compiler.$ocaml_version fi -"$script_dir"/opam-unpin.sh -. "$script_dir"/opam-pin.sh - opam list --installed depext || opam install depext -opam depext $packages -opam install $packages --deps-only --with-test +"$script_dir"/install_build_deps.raw.sh diff --git a/scripts/version.sh b/scripts/version.sh index 465a29785..3f105306a 100644 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -9,5 +9,5 @@ hidapi_version=0.8.0_rc1 opam_version=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_url=https://gitlab.com/tezos/opam-repository.git opam_repository=$opam_repository_url\#$opam_repository_tag