Skip to content

Commit

Permalink
Feed it
Browse files Browse the repository at this point in the history
  • Loading branch information
dra27 authored and rjbou committed Jul 24, 2024
1 parent d553061 commit 897fddc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
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
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

0 comments on commit 897fddc

Please sign in to comment.