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

Backport CUDF trimming to the 2.0 branch #4538

Closed
wants to merge 17 commits into from
Closed
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 .ocamlinit
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#use "topfind";;
#use "down.top";;
#require "opam-client";;

OpamClientConfig.opam_init ();;
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ endif
endif

ifneq ($(LIBINSTALL_DIR),)
OPAMINSTALLER_FLAGS += --libdir "$(LIBINSTALL_DIR)"
OPAMINSTALLER_FLAGS += --libdir "$(LIBINSTALL_DIR)" --docdir "$(LIBINSTALL_DIR)/../doc"
endif

opam-devel.install: $(DUNE_DEP)
Expand Down
68 changes: 32 additions & 36 deletions src/client/opamClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ let orphans ?changes ?(transitive=false) t =
| Some ch ->
if OpamPackage.Set.is_empty orphans then orphans else
let recompile_cone =
OpamPackage.Set.of_list @@
OpamSolver.reverse_dependencies
~depopts:true ~installed:true ~unavailable:true
~build:true ~post:false
Expand All @@ -82,7 +81,6 @@ let orphans ?changes ?(transitive=false) t =
let rec add_trans full_orphans orphan_versions =
(* fixpoint to check all packages with no available version *)
let new_orphans =
OpamPackage.Set.of_list @@
OpamSolver.reverse_dependencies
~depopts:false ~installed:false ~unavailable:true
~build:true ~post:false
Expand Down Expand Up @@ -278,11 +276,9 @@ let upgrade_t
OpamConsole.warning
"Upgrade is not possible because of conflicts or packages that \
are no longer available:";
OpamConsole.errmsg "%s" (OpamStd.Format.itemize (fun x -> x) reasons);
if chains <> [] then
OpamConsole.errmsg
"The following dependencies are the cause:\n%s"
(OpamStd.Format.itemize (fun x -> x) chains);
OpamConsole.errmsg " %s"
(OpamStd.Format.itemize (OpamCudf.string_of_conflict ~start_column:2)
reasons);
OpamConsole.errmsg
"\nYou may run \"opam upgrade --fixup\" to let opam fix the \
current state.\n"
Expand Down Expand Up @@ -936,20 +932,22 @@ let assume_built_restrictions t atoms =
let all_fixed = all_deps OpamPackage.Set.empty pkg_of_atoms in
OpamSolution.eq_atoms_of_packages all_fixed |> get_installed_atoms t
in
let atoms =
atoms @ OpamSolution.eq_atoms_of_packages
(OpamPackage.Set.of_list installed_fixed)
let uninstalled_dependencies =
(OpamPackage.Map.values missing
|> List.fold_left OpamPackage.Name.Set.union OpamPackage.Name.Set.empty
|> OpamPackage.packages_of_names available_packages)
-- installed_dependencies
in
let t =
let avp =
OpamPackage.Set.filter
(fun p -> not (List.exists (fun a -> OpamFormula.check a p)
not_installed_fixed))
(Lazy.force t.available_packages)
in
{ t with available_packages = lazy avp}
let available_packages = lazy (
(available_packages -- uninstalled_dependencies) ++ t.installed ++ pinned
) in
let fixed_atoms =
List.map (fun nv ->
(OpamPackage.name nv , Some (`Eq, OpamPackage.version nv)))
(OpamPackage.Set.elements pinned @
OpamPackage.Set.elements installed_dependencies)
in
t, atoms
{ t with available_packages }, fixed_atoms

let filter_unpinned_locally t atoms f =
OpamStd.List.filter_map (fun at ->
Expand Down Expand Up @@ -1121,10 +1119,10 @@ let remove_t ?ask ~autoremove ~force atoms t =
(slog OpamFormula.string_of_atoms) atoms;

let t, full_orphans, orphan_versions =
let changes =
if autoremove then None
else Some (OpamSwitchState.packages_of_atoms t atoms) in
orphans ?changes t
if atoms = [] then t, OpamPackage.Set.empty, OpamPackage.Set.empty
else
let changes = OpamSwitchState.packages_of_atoms t atoms in
orphans ~changes t
in

let nothing_to_do = ref true in
Expand Down Expand Up @@ -1160,32 +1158,30 @@ let remove_t ?ask ~autoremove ~force atoms t =
Remove
in
let to_remove =
OpamPackage.Set.of_list
(OpamSolver.reverse_dependencies ~build:true ~post:true
~depopts:false ~installed:true universe packages) in
OpamSolver.reverse_dependencies ~build:true ~post:true
~depopts:false ~installed:true universe packages
in
let to_keep =
(if autoremove then t.installed_roots %% t.installed else t.installed)
++ universe.u_base
-- to_remove -- full_orphans -- orphan_versions
-- to_remove
in
let to_keep =
OpamPackage.Set.of_list
(OpamSolver.dependencies ~build:true ~post:true
~depopts:true ~installed:true universe to_keep) in
OpamSolver.dependencies ~build:true ~post:true
~depopts:true ~installed:true universe to_keep in
(* to_keep includes the depopts, because we don't want to autoremove
them. But that may re-include packages that we wanted removed, so we
need to remove them again *)
let to_keep = to_keep -- to_remove in
let requested = OpamPackage.names_of_packages packages in
let to_remove =
if autoremove then
let to_remove = t.installed -- to_keep in
if atoms = [] then to_remove
let to_remove1 = t.installed -- to_keep in
if atoms = [] then to_remove1
else (* restrict to the dependency cone of removed pkgs *)
to_remove %%
(OpamPackage.Set.of_list
(OpamSolver.dependencies ~build:true ~post:true
~depopts:true ~installed:true universe to_remove))
to_remove1 %%
(OpamSolver.dependencies ~build:true ~post:true
~depopts:true ~installed:true universe to_remove)
else to_remove in
let t, solution =
OpamSolution.resolve_and_apply ?ask t Remove ~requested
Expand Down
11 changes: 2 additions & 9 deletions src/client/opamListCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ let apply_selector ~base st = function
~installed:false ~unavailable:true
(get_universe st tog)
(packages_of_atoms st atoms)
|> OpamPackage.Set.of_list
| Required_by (tog, atoms) ->
atom_dependencies st tog atoms |>
OpamFormula.packages base
Expand Down Expand Up @@ -643,14 +642,8 @@ let display st format packages =
~requested:(OpamPackage.names_of_packages packages)
Query
in
let deps_packages =
OpamSolver.dependencies
~depopts:true ~installed:false ~unavailable:true
~build:true ~post:false
universe packages
in
List.filter (fun nv -> OpamPackage.Set.mem nv packages) deps_packages |>
List.rev
OpamSolver.dependency_sort ~depopts:true ~build:true ~post:false
universe packages
else match format.order with
| `Custom o -> List.sort o (OpamPackage.Set.elements packages)
| _ -> OpamPackage.Set.elements packages
Expand Down
Loading