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

Add 'hidden-version' pkg flag and tweak criteria #4281

Merged
merged 4 commits into from
Jul 21, 2020
Merged
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: 2 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ New option are prefixed with ◈
## Solver
* Fix Cudf generation for compat with external solvers [#4261 @AltGr]
* Check for a solution before calling the solver [#4263 @AltGr]
* Add the package flag 'hidden-version' to discourage selection by the solver [#4281 @AltGr]
* Tweak the default criteria to handle 'missing-depexts' and 'hidden-version' flags [#4281 @AltGr]

## Test
* Add show cram test [#4206 @rjbou]
Expand Down
2 changes: 2 additions & 0 deletions src/format/opamTypes.mli
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ type package_flag =
| Pkgflag_Compiler (** Package may be used for 'opam switch' *)
| Pkgflag_Conf (** Virtual package: no source, no install or remove instructions,
.install, but likely has depexts *)
| Pkgflag_HiddenVersion (** This version of the package will only be installed if
strictly required *)
| Pkgflag_Unknown of string (** Used for error reporting, otherwise ignored *)

(** At some point we want to abstract so that the same functions can be used
Expand Down
2 changes: 2 additions & 0 deletions src/format/opamTypesBase.ml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ let string_of_pkg_flag = function
| Pkgflag_Plugin -> "plugin"
| Pkgflag_Compiler -> "compiler"
| Pkgflag_Conf -> "conf"
| Pkgflag_HiddenVersion -> "hidden-version"
| Pkgflag_Unknown s -> s

let pkg_flag_of_string = function
Expand All @@ -144,6 +145,7 @@ let pkg_flag_of_string = function
| "plugin" -> Pkgflag_Plugin
| "compiler" -> Pkgflag_Compiler
| "conf" -> Pkgflag_Conf
| "hidden-version" -> Pkgflag_HiddenVersion
| s -> Pkgflag_Unknown s

let action_contents = function
Expand Down
9 changes: 8 additions & 1 deletion src/solver/opamBuiltinMccs.ml.real
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ let name solver_backend = "builtin-"^Mccs.get_solver_id ~solver:solver_backend (

let default_criteria = {
crit_default = "-removed,\
-count[hidden-version,changed],\
-count[version-lag,request],\
-count[version-lag,changed],\
-count[missing-depexts,changed],\
-changed";
crit_upgrade = "-removed,\
-count[hidden-version,changed],\
-count[version-lag,solution],\
-count[missing-depexts,changed],\
-new";
crit_fixup = "-changed,-count[version-lag:,false]";
crit_fixup = "-changed,\
-count[hidden-version:,true],\
-count[version-lag:,false],\
-count[missing-depexts:,true]";
crit_best_effort_prefix = Some "+count[opam-query:,false],";
}

Expand Down
9 changes: 8 additions & 1 deletion src/solver/opamBuiltinZ3.ml.real
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ let command_name = None

let default_criteria = {
crit_default = "-removed,\
-count[hidden-version,changed],\
-count[version-lag,request],\
-count[version-lag,changed],\
-count[missing-depexts,changed],\
-changed";
crit_upgrade = "-removed,\
-count[hidden-version,changed],\
-count[version-lag,solution],\
-count[missing-depexts,changed],\
-new";
crit_fixup = "-changed,-count[version-lag,solution]";
crit_fixup = "-changed,\
-count[hidden-version,changed],\
-count[version-lag,solution],\
-count[missing-depexts,changed]";
crit_best_effort_prefix = Some "+count[opam-query,solution],";
}

Expand Down
20 changes: 17 additions & 3 deletions src/solver/opamCudfSolver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,23 @@ module Aspcud_def = struct
let default_criteria =
{
crit_default = "-count(removed),\
-sum(solution,hidden-version),\
-sum(request,version-lag),\
-count(down),\
-sum(solution,version-lag),\
-count(changed)";
-count(changed),\
-sum(solution,missing-depexts)";
crit_upgrade = "-count(down),\
-count(removed),\
-sum(solution,hidden-version),\
-sum(solution,version-lag),\
-sum(solution,missing-depexts),\
-count(new)";
crit_fixup = "-count(changed),\
-notuptodate(solution),-sum(solution,version-lag)";
-count[hidden-version:,true],\
-notuptodate(solution),\
-sum(solution,version-lag),\
-count[missing-depexts:,true]";
crit_best_effort_prefix = Some "+sum(solution,opam-query),";
}
end
Expand Down Expand Up @@ -170,14 +177,21 @@ module Mccs_def = struct

let default_criteria = {
crit_default = "-removed,\
-count[hidden-version:,true],\
-count[version-lag:,true],\
-changed,\
-count[version-lag:,false],\
-count[missing-depexts:,true],\
-new";
crit_upgrade = "-removed,\
-count[hidden-version:,true],\
-count[version-lag:,false],\
-count[missing-depexts:,true],\
-new";
crit_fixup = "-changed,-count[version-lag:,false]";
crit_fixup = "-changed,\
-count[hidden-version:,true],\
-count[version-lag:,false],\
-count[missing-depexts:,true]";
crit_best_effort_prefix = Some "+count[opam-query:,false],";
}
end
Expand Down
10 changes: 9 additions & 1 deletion src/state/opamSwitchState.ml
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,13 @@ let universe st
(Lazy.force st.sys_packages)
OpamPackage.Set.empty
in
let hidden_versions =
OpamPackage.Map.fold (fun nv opam acc ->
if OpamFile.OPAM.has_flag Pkgflag_HiddenVersion opam
then OpamPackage.Set.add nv acc else acc)
st.opams
OpamPackage.Set.empty
in
let u =
{
u_packages = st.packages;
Expand All @@ -897,7 +904,8 @@ let universe st
u_invariant;
u_reinstall;
u_attrs = ["opam-query", requested_allpkgs;
"missing-depexts", missing_depexts];
"missing-depexts", missing_depexts;
"hidden-version", hidden_versions];
}
in
u
Expand Down