diff --git a/scripts/install_build_deps.raw.sh b/scripts/install_build_deps.raw.sh index 38034285e6a5d8c728aec374d2a3da0ed07c4170..e050691e828460564823cd7e7b6e4f28f2beb44f 100755 --- a/scripts/install_build_deps.raw.sh +++ b/scripts/install_build_deps.raw.sh @@ -18,7 +18,17 @@ export OPAMYES=${OPAMYES:=true} # Note that install_build_deps.sh calls install_build_deps.rust.sh # which checks whether Rust is installed with the right version and explains how # to install it if needed, so using opam depext is redundant anyway. -opam depext conf-gmp conf-libev conf-pkg-config conf-hidapi ctypes-foreign conf-autoconf conf-libffi conf-zlib #conf-rust +conf_packages="conf-gmp conf-libev conf-pkg-config conf-hidapi ctypes-foreign conf-autoconf conf-libffi conf-zlib" #conf-rust + +# Opam < 2.1 uses opam-depext as a plugin, later versions provide the option +# `--depext-only`: +case $(opam --version) in + 2.0.* ) opam_depext_command="opam depext $conf_packages" ;; + * ) opam_depext_command="opam install --depext-only $conf_packages" ;; +esac +## ShellCheck does not fail when non-quoted variables are at the beginning +## of a command: +$opam_depext_command ## In an ideal world, `--with-test` should be present only when using ## `--dev`. But this would probably break the CI, so we postponed this diff --git a/scripts/install_build_deps.sh b/scripts/install_build_deps.sh index e378b4d9c98fba267f891ffd676898b33fe4e8e0..5461d84e74605283093da12e06ab1710bf83584d 100755 --- a/scripts/install_build_deps.sh +++ b/scripts/install_build_deps.sh @@ -80,7 +80,12 @@ fi # opam packages that depend on Rust. "$script_dir"/install_build_deps.rust.sh -opam install --yes opam-depext +# Opam < 2.1 requires opam-depext as a plugin, later versions include it +# natively: +case $(opam --version) in + 2.0.* ) + opam install --yes opam-depext ;; +esac "$script_dir"/install_build_deps.raw.sh diff --git a/scripts/update_opam_repo.sh b/scripts/update_opam_repo.sh index bc3959da77bd230b1d8928df3c5e4117f765dd9b..15d91312977b2443a8f4d2698faf01eda821225f 100755 --- a/scripts/update_opam_repo.sh +++ b/scripts/update_opam_repo.sh @@ -88,8 +88,23 @@ done ## Filtering unrequired packages cd $tmp_dir git reset --hard "$full_opam_repository_tag" +# Opam < 2.1 requires opam-depext as a plugin, later versions include it +# natively: +extra_warning="" +case $(opam --version) in + 2.0.* ) opam_depext_dep="opam-depext," ;; + * ) + opam_depext_dep="" + extra_warning=" +WARNING you are using opam $(opam --version), your patch +is potentially removing the opam 2.0.x dependency 'opam-depext', please +make sure you are not removing it (for instance by editing the patch, +fixing the resulting merge-request, or re-running with opam 2.0.x)." + ;; +esac +#shellcheck disable=SC2086 OPAMSOLVERTIMEOUT=600 opam admin filter --yes --resolve \ - $packages,ocaml,ocaml-base-compiler,odoc,opam-depext,js_of_ocaml-ppx,opam-ed + $packages,ocaml,ocaml-base-compiler,odoc,${opam_depext_dep}js_of_ocaml-ppx,opam-ed ## Adding useful compiler variants for variant in afl flambda fp spacetime ; do @@ -117,4 +132,5 @@ echo echo "Wrote proposed update in: $target." echo 'Please add this patch to: `https://gitlab.com/tezos/opam-repository`' echo 'And update accordingly the commit hash in: `.gitlab/ci/templates.yml` and `scripts/version.sh`' +echo "$extra_warning" echo diff --git a/scripts/version.sh b/scripts/version.sh index 40c7316af7f6a0fe949a56c4de63ca6cfe02618a..df6a495a6ed016612dc02eef4b92d3b40be34818 100755 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -14,7 +14,7 @@ ## with both the make and sh syntax export ocaml_version=4.12.1 -export opam_version=2.0 +export opam_version=2 export recommended_rust_version=1.52.1 ## full_opam_repository is a commit hash of the public OPAM repository, i.e.