Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set OPAMCLI=2.0 by default during compilation/install/remove phases #4492

Merged
merged 4 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions src/client/opamAction.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
65 changes: 63 additions & 2 deletions tests/reftests/cli-versioning.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -61,8 +61,69 @@ 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
### <opams/env-2-0.opam>
opam-version: "2.0"
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$'"]
### <opams/env-2-1.opam>
opam-version: "2.0"
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: 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 env-2-0

<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><>
[env-2-0.~dev] synchronised (no changes)

The following actions will be performed:
∗ install env-2-0 ~dev*

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved env-2-0.~dev (file://${BASEDIR}/opams)
∗ installed env-2-0.~dev
Done.
### opam install env-2-1

<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><>
[env-2-1.~dev] synchronised (no changes)

The following actions will be performed:
∗ install env-2-1 ~dev*

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved env-2-1.~dev (file://${BASEDIR}/opams)
∗ installed env-2-1.~dev
Done.
### opam remove env-2-0
The following actions will be performed:
⊘ remove env-2-0 ~dev*

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved env-2-0.~dev (no changes)
⊘ removed env-2-0.~dev
Done.
### opam remove env-2-1
The following actions will be performed:
⊘ remove env-2-1 ~dev*

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved env-2-1.~dev (no changes)
⊘ removed env-2-1.~dev
Done.