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

Ensure the right versions of packages are used when simulating pinning #6256

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ users)
* [BUG] Stop double pin of packages located in ./opam/opam [#6343 @kit-ty-kate - fix #6342]
* Don't ask confirmation when pinning an unknown package (absent from repositories) [#6309 @kit-ty-kate @rjbou - fix #3199]
* [BUG] Do not ask to install pin-depends twice [#6375 @kit-ty-kate - fix #6374]
* [BUG] Ensure the right versions of packages are used when simulating pinning [#6256 @rjbou @kit-ty-kate - fix #6248 #6379]

## List

Expand Down Expand Up @@ -180,6 +181,7 @@ users)
* Add a test showing the behaviour when a pin depend is unpinned [#6380 @rjbou]
* Add a test to ensure `opam upgrade <pkg>` will not upgrade unrelated things [#6373 @kit-ty-kate]
* Add a test in init to show ocaml system compiler selection behaviour [#6307 @kit-ty-kate @rjbou]
* Add a test showing simulated pinning does not propagate version information [#6256 @rjbou]

### Engine

Expand Down
13 changes: 11 additions & 2 deletions src/client/opamAuxCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,15 @@ let simulate_local_pinnings ?quiet ?(for_view=false) st to_pin =
} in
st, local_packages

let simulate_pinned_atoms pins atoms =
List.map (function
| (_name, Some _) as a -> a
| (name, None) as a ->
match OpamPackage.package_of_name_opt pins name with
| Some pkg -> (name, Some (`Eq, OpamPackage.version pkg))
| None -> a)
atoms

let simulate_autopin st ?quiet ?(for_view=false) ?locked ?recurse ?subpath
atom_or_local_list =
let atoms, to_pin, obsolete_pins, already_pinned_set =
Expand Down Expand Up @@ -424,7 +433,7 @@ let simulate_autopin st ?quiet ?(for_view=false) ?locked ?recurse ?subpath
OpamConsole.note "The following may not reflect the above pinnings (their \
package definitions are not available at this stage)";
OpamConsole.msg "\n"));
st, atoms
st, simulate_pinned_atoms pins atoms

let autopin st ?(simulate=false) ?quiet ?locked ?recurse ?subpath
atom_or_local_list =
Expand Down Expand Up @@ -494,7 +503,7 @@ let autopin st ?(simulate=false) ?quiet ?locked ?recurse ?subpath
else
OpamUpdate.dev_packages st ~working_dir:OpamPackage.Set.empty already_pinned
in
st, atoms
st, simulate_pinned_atoms pins atoms

let check_and_revert_sandboxing root config =
let sdbx_wrappers =
Expand Down
33 changes: 33 additions & 0 deletions tests/reftests/pin.test
Original file line number Diff line number Diff line change
Expand Up @@ -1035,3 +1035,36 @@ The following actions will be performed:
-> installed dep2.2
-> installed dep1.dev
Done.
### : opam install . --deps-only not selecting the good version
### <pkg:simcomp.1>
opam-version: "2.0"
flags: compiler
### opam switch create simulate-pin simcomp

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["simcomp"]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed simcomp.1
Done.
### <pin:sim/sim.opam>
opam-version: "2.0"
version: "2.0"
depends: "deps-sim" { = "2" }
conflicts: "simcomp"
### <pkg:sim.1>
opam-version: "2.0"
depends: "deps-sim" { = "1" }
### <pkg:deps-sim.1>
opam-version: "2.0"
### <pkg:deps-sim.2>
opam-version: "2.0"
### opam install ./sim --deps-only
[ERROR] Package conflict!
* Incompatible packages:
- (invariant) -> simcomp
- deps-of-sim
You can temporarily relax the switch invariant with `--update-invariant'

No solution found, exiting
# Return code 20 #