From 31218def9ba9e017014f355988b44c4e2a6fb700 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Wed, 26 Feb 2025 10:40:45 +0100 Subject: [PATCH] Ensure the right versions of packages are used when simulating pinning Co-authored-by: Kate --- master_changes.md | 1 + src/client/opamAuxCommands.ml | 13 +++++++++++-- tests/reftests/pin.test | 15 ++++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/master_changes.md b/master_changes.md index 2273a1d77c7..932e81f7c2e 100644 --- a/master_changes.md +++ b/master_changes.md @@ -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 diff --git a/src/client/opamAuxCommands.ml b/src/client/opamAuxCommands.ml index 5bb3cb18d02..81069630722 100644 --- a/src/client/opamAuxCommands.ml +++ b/src/client/opamAuxCommands.ml @@ -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 = @@ -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 = @@ -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 = diff --git a/tests/reftests/pin.test b/tests/reftests/pin.test index abde4563446..87e86ab553d 100644 --- a/tests/reftests/pin.test +++ b/tests/reftests/pin.test @@ -1060,10 +1060,11 @@ opam-version: "2.0" ### opam-version: "2.0" ### opam install ./sim --deps-only -The following actions will be performed: -=== install 1 package - - install deps-sim 1 [required by sim] - -<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> --> installed deps-sim.1 -Done. +[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 #