diff --git a/master_changes.md b/master_changes.md index 47a1eae1162..b839b8c1532 100644 --- a/master_changes.md +++ b/master_changes.md @@ -25,6 +25,7 @@ users) ## Install * Fix `opam install ` not updating and storing pinned packages' metadata [#6209 @kit-ty-kate - fix #5567] + * Fix `opam install --deps-only/--show-action ` not updating (without storing) pinned packages' metadata [#6209 @kit-ty-kate - fix #5567] ## Build (package) diff --git a/src/client/opamAuxCommands.ml b/src/client/opamAuxCommands.ml index 7e0bcf27ac4..da456eb6727 100644 --- a/src/client/opamAuxCommands.ml +++ b/src/client/opamAuxCommands.ml @@ -404,6 +404,29 @@ let simulate_local_pinnings ?quiet ?(for_view=false) st to_pin = st.switch_global st.switch st.switch_config ~pinned ~opams:local_opams) ); + reinstall = lazy ( + let open OpamPackage.Set.Op in + let installed_pinned = st.pinned %% st.installed in + OpamPackage.Set.fold (fun pinned_pkg reinstall -> + match + OpamPackage.Set.find_opt + (fun pkg -> + OpamPackage.Name.equal + (OpamPackage.name pinned_pkg) + (OpamPackage.name pkg)) + local_packages + with + | None -> reinstall + | Some local_pkg -> + let old_opam = OpamPackage.Map.find pinned_pkg st.installed_opams in + let new_opam = OpamPackage.Map.find local_pkg local_opams in + if OpamFile.OPAM.effectively_equal old_opam new_opam then + reinstall + else + OpamPackage.Set.add local_pkg + (OpamPackage.Set.remove pinned_pkg reinstall)) + installed_pinned (Lazy.force st.reinstall) + ); pinned; } in st, local_packages diff --git a/src/client/opamClient.ml b/src/client/opamClient.ml index 535135fb191..b7aa57786fd 100644 --- a/src/client/opamClient.ml +++ b/src/client/opamClient.ml @@ -2207,9 +2207,6 @@ let install_t t ?ask ?(ignore_conflicts=false) ?(depext_only=false) in let pkg_reinstall = if assume_built then OpamPackage.Set.of_list pkg_skip - else if deps_only then OpamPackage.Set.empty - (* NOTE: As we only install dependency packages, there are no intersections - between t.reinstall and pkg_skip *) else Lazy.force t.reinstall %% OpamPackage.Set.of_list pkg_skip in (* Add the packages to the list of package roots and display a diff --git a/tests/reftests/pin.test b/tests/reftests/pin.test index 67d8453abf2..a6359b9ab7f 100644 --- a/tests/reftests/pin.test +++ b/tests/reftests/pin.test @@ -464,6 +464,19 @@ depends: "dependency" {= "2"} ### opam install --deps-only ./pin-change [NOTE] Ignoring uncommitted changes in ${BASEDIR}/pin-change (`--working-dir' not specified or specified with no argument). [pin-change.dev] synchronised (no changes) +The following actions will be performed: +=== recompile 1 package + - recompile pin-change dev (pinned) [uses dependency] +=== upgrade 1 package + - upgrade dependency 1 to 2 [required by pin-change] + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> removed dependency.1 +-> installed dependency.2 +-> retrieved pin-change.dev (no changes) +-> removed pin-change.dev +-> installed pin-change.dev +Done. ### opam remove pin-change The following actions will be performed: === remove 1 package @@ -480,10 +493,10 @@ depends: "dependency" {= "3"} [pin-change.dev] synchronised (no changes) The following actions will be performed: === upgrade 1 package - - upgrade dependency 1 to 3 [required by pin-change] + - upgrade dependency 2 to 3 [required by pin-change] <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> --> removed dependency.1 +-> removed dependency.2 -> installed dependency.3 Done. ### opam pin diff --git a/tests/reftests/working-dir.test b/tests/reftests/working-dir.test index f432c25193f..5a311f80106 100644 --- a/tests/reftests/working-dir.test +++ b/tests/reftests/working-dir.test @@ -256,7 +256,11 @@ Done. opam-version: "2.0" depends: ["qux" {= "1"}] ### opam install ./ongoing --working-dir --show-action -[NOTE] Package ongoing is already installed (current version is dev). +The following actions would be performed: +=== downgrade 1 package + - downgrade qux 4 to 1 [required by ongoing] +=== recompile 1 package + - recompile ongoing dev (pinned) ### opam reinstall ./ongoing --working-dir --show-action <><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><>