From 94a752b03e9bb6ffc88c4669304b4cf74b09fa03 Mon Sep 17 00:00:00 2001 From: Kate Date: Wed, 6 Jan 2021 14:34:33 +0000 Subject: [PATCH 1/4] Set OPAMCLI=2.0 by default during compilation/install/remove phases People who want to use the 2.1 features should be using --cli=2.1 or build-env: OPAMCLI = "2.1" --- src/client/opamAction.ml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/opamAction.ml b/src/client/opamAction.ml index 27eeeb38f46..1f409fca185 100644 --- a/src/client/opamAction.ml +++ b/src/client/opamAction.ml @@ -427,6 +427,7 @@ let compilation_env t opam = "OPAM_PACKAGE_VERSION", Eq, OpamPackage.Version.to_string (OpamFile.OPAM.version opam), Some "build environment definition"; + "OPAMCLI", Eq, "2.0", Some "opam CLI version"; ] @ OpamFile.OPAM.build_env opam) From efc6d28ca4a120a366be3d85dfb9adb1eb58a196 Mon Sep 17 00:00:00 2001 From: Kate Date: Wed, 6 Jan 2021 15:11:32 +0000 Subject: [PATCH 2/4] Update the changelog --- master_changes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/master_changes.md b/master_changes.md index d197590d781..0dd446e9258 100644 --- a/master_changes.md +++ b/master_changes.md @@ -10,6 +10,7 @@ New option/command/subcommand are prefixed with ◈. ## Global CLI * Fix hooks broken by 371963a6b [#4386 @lefessan] * CLI versioning usage [#4385 @rjbou] + * Set OPAMCLI=2.0 by default during the build/install/remove phases [#4492 @kit-ty-kate] ## Init * Fix sandbox check with not yet set opam environment variables [#4370 @rjbou - fix #4368] From 3d6f07b6332805486fadfa637596726f2fad7451 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Wed, 6 Jan 2021 23:35:31 +0100 Subject: [PATCH 3/4] add add test for opam cli 2.0 in build env --- tests/reftests/cli-versioning.test | 149 ++++++++++++++++++++++++++++- 1 file changed, 147 insertions(+), 2 deletions(-) diff --git a/tests/reftests/cli-versioning.test b/tests/reftests/cli-versioning.test index 1112733559f..ba60defee95 100644 --- a/tests/reftests/cli-versioning.test +++ b/tests/reftests/cli-versioning.test @@ -52,7 +52,7 @@ The following actions would be performed: ===== ∗ 6 ===== ### opam install ocaml.4.10.0 --unlock-base --show opam: unlock-base was removed in version 2.1 of the opam CLI, but version 2.1 has been requested. Use --update-invariant instead or set OPAMCLI environment variable to 2.0. -### #opam option use mk_command_ret +### # opam option uses mk_command_ret ### opam option foo [ERROR] No option named 'foo' found. Use 'opam option [--global]' to list them ### OPAMCLI=2.0 opam option foo @@ -61,8 +61,153 @@ opam: option was added in version 2.1 of the opam CLI, but version 2.0 has been [ERROR] Field or section foo not found ### OPAMCLI=2.0 opam option foo --global opam: global was added in version 2.1 of the opam CLI, but version 2.0 has been requested, which is older. -### # opam lock use mk_command +### # opam lock uses mk_command ### opam lock foo [ERROR] No package matching foo ### OPAMCLI=2.0 opam lock foo opam: lock was added in version 2.1 of the opam CLI, but version 2.0 has been requested, which is older. +### # Check for build test env +### # Note: you must have an installed opam with cli version enabled to pass these tests +### mkdir opams +### +opam-version: "2.0" +build: [ "opam" "config" "var" "prefix" "--readonly" ] +### +opam-version: "2.0" +build: [ "opam" "config" "var" "prefix" "--cli=2.0" "--readonly" ] +### +opam-version: "2.0" +build: [ "opam" "option" "depext" "--readonly" ] +### +opam-version: "2.0" +build: [ "opam" "option" "depext" "--cli=2.1" "--readonly" ] +### +opam-version: "2.0" +build-env: [ OPAMCLI = "2.1" ] +build: [ "opam" "option" "depext" "--readonly" ] +### +opam-version: "2.0" +build-env: [ OPAMCLI = "2.1" ] +build: [ "opam" "config" "var" "prefix" "--readonly" ] +### opam pin opams -yn +This will pin the following packages: ko-var-2-1-env, ko-var-2-1, ok-var-2-0-cli, ok-var-2-0, ok-var-2-1-cli, ok-var-2-1-env. Continue? [Y/n] y +Package ko-var-2-1-env does not exist, create as a NEW package? [Y/n] y +ko-var-2-1-env is now pinned to file://${BASEDIR}/opams (version ~dev) +Package ko-var-2-1 does not exist, create as a NEW package? [Y/n] y +ko-var-2-1 is now pinned to file://${BASEDIR}/opams (version ~dev) +Package ok-var-2-0-cli does not exist, create as a NEW package? [Y/n] y +ok-var-2-0-cli is now pinned to file://${BASEDIR}/opams (version ~dev) +Package ok-var-2-0 does not exist, create as a NEW package? [Y/n] y +ok-var-2-0 is now pinned to file://${BASEDIR}/opams (version ~dev) +Package ok-var-2-1-cli does not exist, create as a NEW package? [Y/n] y +ok-var-2-1-cli is now pinned to file://${BASEDIR}/opams (version ~dev) +Package ok-var-2-1-env does not exist, create as a NEW package? [Y/n] y +ok-var-2-1-env is now pinned to file://${BASEDIR}/opams (version ~dev) +### opam switch set-invariant --formula "[]" +### opam install ok-var-2-0 + +<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><> +[ok-var-2-0.~dev] synchronised (no changes) + +The following actions will be performed: + ∗ install ok-var-2-0 ~dev* + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +⬇ retrieved ok-var-2-0.~dev (file://${BASEDIR}/opams) +∗ installed ok-var-2-0.~dev +Done. +### opam install ok-var-2-0-cli + +<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><> +[ok-var-2-0-cli.~dev] synchronised (no changes) + +The following actions will be performed: + ∗ install ok-var-2-0-cli ~dev* + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +⬇ retrieved ok-var-2-0-cli.~dev (file://${BASEDIR}/opams) +∗ installed ok-var-2-0-cli.~dev +Done. +### opam install ko-var-2-1 2>&1 | sed -e 's/#/ø/g' | sed -e 's/log.*/log/g' + +<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><> +[ko-var-2-1.~dev] synchronised (no changes) + +The following actions will be performed: + ∗ install ko-var-2-1 ~dev* + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +⬇ retrieved ko-var-2-1.~dev (file://${BASEDIR}/opams) +[ERROR] The compilation of ko-var-2-1.~dev failed at "opam option depext --readonly". + +ø=== ERROR while compiling ko-var-2-1.~dev ====================================ø +ø context 2.1.0~beta4 | linux/x86_64 | | pinned(file://${BASEDIR}/opams) +ø path ${BASEDIR}/.opam/cli-versioning/.opam-switch/build/ko-var-2-1.~dev +ø command ${BASEDIR}/.opam/opam-init/hooks/sandbox.sh build opam option depext --readonly +ø exit-code 2 +ø env-file ${BASEDIR}/.opam/log +ø output-file ${BASEDIR}/.opam/log +øøø output øøø +ø opam: option was added in version 2.1 of the opam CLI, but version 2.0 has been requested, which is older. + + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> +┌─ The following actions failed +│ λ build ko-var-2-1 ~dev +└─ +╶─ No changes have been performed +### opam install ok-var-2-1-cli + +<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><> +[ok-var-2-1-cli.~dev] synchronised (no changes) + +The following actions will be performed: + ∗ install ok-var-2-1-cli ~dev* + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +⬇ retrieved ok-var-2-1-cli.~dev (file://${BASEDIR}/opams) +∗ installed ok-var-2-1-cli.~dev +Done. +### opam install ok-var-2-1-env + +<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><> +[ok-var-2-1-env.~dev] synchronised (no changes) + +The following actions will be performed: + ∗ install ok-var-2-1-env ~dev* + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +⬇ retrieved ok-var-2-1-env.~dev (file://${BASEDIR}/opams) +∗ installed ok-var-2-1-env.~dev +Done. +### opam install ko-var-2-1-env 2>&1 | sed -e 's/#/ø/g' | sed -e 's/log.*/log/g' + +<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><> +[ko-var-2-1-env.~dev] synchronised (no changes) + +The following actions will be performed: + ∗ install ko-var-2-1-env ~dev* + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +⬇ retrieved ko-var-2-1-env.~dev (file://${BASEDIR}/opams) +[ERROR] The compilation of ko-var-2-1-env.~dev failed at "opam config var prefix --readonly". + +ø=== ERROR while compiling ko-var-2-1-env.~dev ================================ø +ø context 2.1.0~beta4 | linux/x86_64 | | pinned(file://${BASEDIR}/opams) +ø path ${BASEDIR}/.opam/cli-versioning/.opam-switch/build/ko-var-2-1-env.~dev +ø command ${BASEDIR}/.opam/opam-init/hooks/sandbox.sh build opam config var prefix --readonly +ø exit-code 2 +ø env-file ${BASEDIR}/.opam/log +ø output-file ${BASEDIR}/.opam/log +øøø output øøø +ø [WARNING] Setting OPAMCLI is brittle - consider using the '--cli .' flag. +ø opam: var was removed in version 2.1 of the opam CLI, but version 2.1 has been requested. Use opam var instead or set OPAMCLI environment variable to 2.0. + + + +<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> +┌─ The following actions failed +│ λ build ko-var-2-1-env ~dev +└─ +╶─ No changes have been performed From 522e36a97c81602637dc3e62c921ed0ac95c034c Mon Sep 17 00:00:00 2001 From: Kate Date: Thu, 7 Jan 2021 18:10:30 +0000 Subject: [PATCH 4/4] Change the tests to test that OPAMCLI is "2.0" by default and that the OPAMCLI variable can be overwritten --- tests/reftests/cli-versioning.test | 148 +++++++---------------------- 1 file changed, 32 insertions(+), 116 deletions(-) diff --git a/tests/reftests/cli-versioning.test b/tests/reftests/cli-versioning.test index ba60defee95..d02a98e5ae5 100644 --- a/tests/reftests/cli-versioning.test +++ b/tests/reftests/cli-versioning.test @@ -69,145 +69,61 @@ opam: lock was added in version 2.1 of the opam CLI, but version 2.0 has been re ### # Check for build test env ### # Note: you must have an installed opam with cli version enabled to pass these tests ### mkdir opams -### +### opam-version: "2.0" -build: [ "opam" "config" "var" "prefix" "--readonly" ] -### +build: ["sh" "-c" "env | grep -q '^OPAMCLI=2\.0$'"] +install: ["sh" "-c" "env | grep -q '^OPAMCLI=2\.0$'"] +remove: ["sh" "-c" "env | grep -q '^OPAMCLI=2\.0$'"] +### opam-version: "2.0" -build: [ "opam" "config" "var" "prefix" "--cli=2.0" "--readonly" ] -### -opam-version: "2.0" -build: [ "opam" "option" "depext" "--readonly" ] -### -opam-version: "2.0" -build: [ "opam" "option" "depext" "--cli=2.1" "--readonly" ] -### -opam-version: "2.0" -build-env: [ OPAMCLI = "2.1" ] -build: [ "opam" "option" "depext" "--readonly" ] -### -opam-version: "2.0" -build-env: [ OPAMCLI = "2.1" ] -build: [ "opam" "config" "var" "prefix" "--readonly" ] +build-env: [OPAMCLI = "2.1"] +build: ["sh" "-c" "env | grep -q '^OPAMCLI=2\.1$'"] +install: ["sh" "-c" "env | grep -q '^OPAMCLI=2\.1$'"] +remove: ["sh" "-c" "env | grep -q '^OPAMCLI=2\.1$'"] ### opam pin opams -yn -This will pin the following packages: ko-var-2-1-env, ko-var-2-1, ok-var-2-0-cli, ok-var-2-0, ok-var-2-1-cli, ok-var-2-1-env. Continue? [Y/n] y -Package ko-var-2-1-env does not exist, create as a NEW package? [Y/n] y -ko-var-2-1-env is now pinned to file://${BASEDIR}/opams (version ~dev) -Package ko-var-2-1 does not exist, create as a NEW package? [Y/n] y -ko-var-2-1 is now pinned to file://${BASEDIR}/opams (version ~dev) -Package ok-var-2-0-cli does not exist, create as a NEW package? [Y/n] y -ok-var-2-0-cli is now pinned to file://${BASEDIR}/opams (version ~dev) -Package ok-var-2-0 does not exist, create as a NEW package? [Y/n] y -ok-var-2-0 is now pinned to file://${BASEDIR}/opams (version ~dev) -Package ok-var-2-1-cli does not exist, create as a NEW package? [Y/n] y -ok-var-2-1-cli is now pinned to file://${BASEDIR}/opams (version ~dev) -Package ok-var-2-1-env does not exist, create as a NEW package? [Y/n] y -ok-var-2-1-env is now pinned to file://${BASEDIR}/opams (version ~dev) +This will pin the following packages: env-2-0, env-2-1. Continue? [Y/n] y +Package env-2-0 does not exist, create as a NEW package? [Y/n] y +env-2-0 is now pinned to file://${BASEDIR}/opams (version ~dev) +Package env-2-1 does not exist, create as a NEW package? [Y/n] y +env-2-1 is now pinned to file://${BASEDIR}/opams (version ~dev) ### opam switch set-invariant --formula "[]" -### opam install ok-var-2-0 +### opam install env-2-0 <><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><> -[ok-var-2-0.~dev] synchronised (no changes) +[env-2-0.~dev] synchronised (no changes) The following actions will be performed: - ∗ install ok-var-2-0 ~dev* + ∗ install env-2-0 ~dev* <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -⬇ retrieved ok-var-2-0.~dev (file://${BASEDIR}/opams) -∗ installed ok-var-2-0.~dev +⬇ retrieved env-2-0.~dev (file://${BASEDIR}/opams) +∗ installed env-2-0.~dev Done. -### opam install ok-var-2-0-cli +### opam install env-2-1 <><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><> -[ok-var-2-0-cli.~dev] synchronised (no changes) +[env-2-1.~dev] synchronised (no changes) The following actions will be performed: - ∗ install ok-var-2-0-cli ~dev* + ∗ install env-2-1 ~dev* <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -⬇ retrieved ok-var-2-0-cli.~dev (file://${BASEDIR}/opams) -∗ installed ok-var-2-0-cli.~dev +⬇ retrieved env-2-1.~dev (file://${BASEDIR}/opams) +∗ installed env-2-1.~dev Done. -### opam install ko-var-2-1 2>&1 | sed -e 's/#/ø/g' | sed -e 's/log.*/log/g' - -<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><> -[ko-var-2-1.~dev] synchronised (no changes) - -The following actions will be performed: - ∗ install ko-var-2-1 ~dev* - -<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -⬇ retrieved ko-var-2-1.~dev (file://${BASEDIR}/opams) -[ERROR] The compilation of ko-var-2-1.~dev failed at "opam option depext --readonly". - -ø=== ERROR while compiling ko-var-2-1.~dev ====================================ø -ø context 2.1.0~beta4 | linux/x86_64 | | pinned(file://${BASEDIR}/opams) -ø path ${BASEDIR}/.opam/cli-versioning/.opam-switch/build/ko-var-2-1.~dev -ø command ${BASEDIR}/.opam/opam-init/hooks/sandbox.sh build opam option depext --readonly -ø exit-code 2 -ø env-file ${BASEDIR}/.opam/log -ø output-file ${BASEDIR}/.opam/log -øøø output øøø -ø opam: option was added in version 2.1 of the opam CLI, but version 2.0 has been requested, which is older. - - - -<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> -┌─ The following actions failed -│ λ build ko-var-2-1 ~dev -└─ -╶─ No changes have been performed -### opam install ok-var-2-1-cli - -<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><> -[ok-var-2-1-cli.~dev] synchronised (no changes) - +### opam remove env-2-0 The following actions will be performed: - ∗ install ok-var-2-1-cli ~dev* + ⊘ remove env-2-0 ~dev* <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -⬇ retrieved ok-var-2-1-cli.~dev (file://${BASEDIR}/opams) -∗ installed ok-var-2-1-cli.~dev +⬇ retrieved env-2-0.~dev (no changes) +⊘ removed env-2-0.~dev Done. -### opam install ok-var-2-1-env - -<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><> -[ok-var-2-1-env.~dev] synchronised (no changes) - +### opam remove env-2-1 The following actions will be performed: - ∗ install ok-var-2-1-env ~dev* + ⊘ remove env-2-1 ~dev* <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -⬇ retrieved ok-var-2-1-env.~dev (file://${BASEDIR}/opams) -∗ installed ok-var-2-1-env.~dev +⬇ retrieved env-2-1.~dev (no changes) +⊘ removed env-2-1.~dev Done. -### opam install ko-var-2-1-env 2>&1 | sed -e 's/#/ø/g' | sed -e 's/log.*/log/g' - -<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><> -[ko-var-2-1-env.~dev] synchronised (no changes) - -The following actions will be performed: - ∗ install ko-var-2-1-env ~dev* - -<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -⬇ retrieved ko-var-2-1-env.~dev (file://${BASEDIR}/opams) -[ERROR] The compilation of ko-var-2-1-env.~dev failed at "opam config var prefix --readonly". - -ø=== ERROR while compiling ko-var-2-1-env.~dev ================================ø -ø context 2.1.0~beta4 | linux/x86_64 | | pinned(file://${BASEDIR}/opams) -ø path ${BASEDIR}/.opam/cli-versioning/.opam-switch/build/ko-var-2-1-env.~dev -ø command ${BASEDIR}/.opam/opam-init/hooks/sandbox.sh build opam config var prefix --readonly -ø exit-code 2 -ø env-file ${BASEDIR}/.opam/log -ø output-file ${BASEDIR}/.opam/log -øøø output øøø -ø [WARNING] Setting OPAMCLI is brittle - consider using the '--cli .' flag. -ø opam: var was removed in version 2.1 of the opam CLI, but version 2.1 has been requested. Use opam var instead or set OPAMCLI environment variable to 2.0. - - - -<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> -┌─ The following actions failed -│ λ build ko-var-2-1-env ~dev -└─ -╶─ No changes have been performed