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

Support avoid-version and deprecated with the 0install-solver #5879

Closed
wants to merge 2 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
2 changes: 1 addition & 1 deletion src/solver/opamBuiltin0install.ml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ let call ~criteria ?timeout:_ (preamble, universe, request) =
let {drop_installed_packages; prefer_oldest} = parse_criteria criteria in
let timer = OpamConsole.timer () in
let pkgs, constraints = create_spec ~drop_installed_packages universe request in
let context = Opam_0install_cudf.create ~prefer_oldest ~constraints universe in
let context = Opam_0install_cudf.create ~handle_avoid_version:true ~prefer_oldest ~constraints universe in
match Opam_0install_cudf.solve context pkgs with
| Ok selections ->
let universe = reconstruct_universe universe selections in
Expand Down
1 change: 1 addition & 0 deletions src/solver/opamCudf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ let s_reinstall = "reinstall"
let s_installed_root = "installed-root"
let s_pinned = "pinned"
let s_version_lag = "version-lag"
let s_avoid_version = "avoid-version"

let opam_invariant_package_name =
Dose_common.CudfAdd.encode "=opam-invariant"
Expand Down
3 changes: 3 additions & 0 deletions src/solver/opamCudf.mli
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ val s_pinned: string
(** the number of versions of the package since this one, cubed *)
val s_version_lag: string

(** the avoid-version flag *)
val s_avoid_version: string

(** valid cudf name for the dummy package used for enforcing opam's switch
invariants *)
val opam_invariant_package_name: string
Expand Down
22 changes: 14 additions & 8 deletions src/solver/opamSolver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,25 @@ let opam2cudf_map universe version_map packages =
OpamPackage.Set.fold (fun nv -> OpamPackage.Map.add nv true)
(packages %% set) OpamPackage.Map.empty
in
let avoid_versions =
OpamStd.Option.default OpamPackage.Set.empty @@
OpamStd.List.assoc_opt String.equal "avoid-version" universe.u_attrs
in
let base_map =
OpamPackage.Set.fold (fun nv ->
let pkg_extra = [
OpamCudf.s_source, `String(OpamPackage.name_to_string nv);
OpamCudf.s_source_number, `String(OpamPackage.version_to_string nv);
] in
let pkg_extra =
if OpamPackage.Set.mem nv avoid_versions then
(OpamCudf.s_avoid_version, `Bool true)::pkg_extra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else
pkg_extra in
OpamPackage.Map.add nv
{ Cudf.default_package with
Cudf.package = name_to_cudf nv.name;
pkg_extra = [
OpamCudf.s_source, `String(OpamPackage.name_to_string nv);
OpamCudf.s_source_number, `String(OpamPackage.version_to_string nv);
];
pkg_extra;
})
packages OpamPackage.Map.empty
in
Expand All @@ -188,10 +198,6 @@ let opam2cudf_map universe version_map packages =
let reinstall_map = set_to_bool_map universe.u_reinstall in
let installed_root_map = set_to_bool_map universe.u_installed_roots in
let pinned_to_current_version_map = set_to_bool_map universe.u_pinned in
let avoid_versions =
OpamStd.Option.default OpamPackage.Set.empty @@
OpamStd.List.assoc_opt String.equal "avoid-version" universe.u_attrs
in
let version_lag_map =
OpamPackage.Name.Map.fold (fun name version_set acc ->
let nvers, vs =
Expand Down
Loading