Skip to content

Commit

Permalink
Add support for opam-0install-cudf 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate committed Aug 16, 2024
1 parent 6fc00fd commit e684403
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.ml
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@ let main oc : unit =
("OPAM12CACHE", "~/.cache/opam1.2/cache");
(* These should be identical to the values in appveyor.yml *)
("OPAM_REPO", "https://github.com/ocaml/opam-repository.git");
("OPAM_TEST_REPO_SHA", "dff745994c64d083a6ba3ddc5a9c28ed0ad0f40a");
("OPAM_REPO_SHA", "dff745994c64d083a6ba3ddc5a9c28ed0ad0f40a");
("OPAM_TEST_REPO_SHA", "6eee105e52e098e36949a584c053a18bcb9b2f6b");
("OPAM_REPO_SHA", "6eee105e52e098e36949a584c053a18bcb9b2f6b");
("SOLVER", "");
(* Cygwin configuration *)
("CYGWIN_MIRROR", "http://mirrors.kernel.org/sourceware/cygwin/");
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/depexts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defaults:
env:
OPAMVERSION: 2.1.6
OPAM_REPO: https://github.com/ocaml/opam-repository.git
OPAM_REPO_SHA: dff745994c64d083a6ba3ddc5a9c28ed0ad0f40a
OPAM_REPO_SHA: 6eee105e52e098e36949a584c053a18bcb9b2f6b

jobs:
opam-cache:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ env:
OPAMBSROOT: ~/.cache/.opam.cached
OPAM12CACHE: ~/.cache/opam1.2/cache
OPAM_REPO: https://github.com/ocaml/opam-repository.git
OPAM_TEST_REPO_SHA: dff745994c64d083a6ba3ddc5a9c28ed0ad0f40a
OPAM_REPO_SHA: dff745994c64d083a6ba3ddc5a9c28ed0ad0f40a
OPAM_TEST_REPO_SHA: 6eee105e52e098e36949a584c053a18bcb9b2f6b
OPAM_REPO_SHA: 6eee105e52e098e36949a584c053a18bcb9b2f6b
SOLVER:
CYGWIN_MIRROR: http://mirrors.kernel.org/sourceware/cygwin/
CYGWIN_ROOT: D:\cygwin
Expand Down
6 changes: 3 additions & 3 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ AC_CHECK_OCAML_PKG_AT_LEAST([dose3.common], [6.1])
AC_CHECK_OCAML_PKG_AT_LEAST([dose3.algo], [6.1])
AC_CHECK_OCAML_PKG_AT_LEAST([opam-file-format], [2.1.4])
AC_CHECK_OCAML_PKG([spdx_licenses])
AC_CHECK_OCAML_PKG_AT_LEAST([opam-0install-cudf],[0.4])
AC_CHECK_OCAML_PKG_AT_LEAST([opam-0install-cudf],[0.5.0])
AC_CHECK_OCAML_PKG([jsonm])
AC_CHECK_OCAML_PKG([uutf])
AC_CHECK_OCAML_PKG([sha])
Expand Down
7 changes: 7 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ users)
## Build
* Synchronise opam-core.opam with opam-repository changes [#6043 @dra27]
* Unset OPAM_SWITCH_PREFIX when using make cold [#5534 @kit-ty-kate]
* Bump the vendored opam-0install-cudf to 0.5.0 [#6130 @kit-ty-kate]
* Require opam-0install-cudf >= 0.5.0 [#6130 @kit-ty-kate]

## Infrastructure

Expand Down Expand Up @@ -119,6 +121,11 @@ users)
## Opam file format

## Solver
* Add support for unordered criteria with the `builtin-0install` solver [#6130 @kit-ty-kate]
* Add support for the `-changed` criteria with the `builtin-0install` solver, to make the solver prefer to keep packages installed at their current version [#6130 @kit-ty-kate]
* Add support for the `-count[avoid-version,solution]` criteria with the `builtin-0install` solver, to avoid packages marked with `avoid-version` flag [#6130 @kit-ty-kate]
* The default criteria for the `builtin-0install` solver changed from empty to `-changed,-count[avoid-version,solution]` [#6130 @kit-ty-kate]
* The upgrade and fixup criteria for the `builtin-0install` solver changed from empty to `-count[avoid-version,solution]` [#6130 @kit-ty-kate]

## Client

Expand Down
2 changes: 1 addition & 1 deletion opam-solver.opam
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ depends: [
"cudf" {>= "0.7"}
"re" {>= "1.9.0"}
"dune" {>= "2.0.0"}
"opam-0install-cudf" {>= "0.4"}
"opam-0install-cudf" {>= "0.5.0"}
]
depopts: [
"z3"
Expand Down
59 changes: 44 additions & 15 deletions src/solver/opamBuiltin0install.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ let command_name = None
let preemptive_check = false

let default_criteria = {
crit_default = "";
crit_upgrade = "";
crit_fixup = "";
crit_default = "-changed,\
-count[avoid-version,solution]";
crit_upgrade = "-count[avoid-version,solution]";
crit_fixup = "-count[avoid-version,solution]";
crit_best_effort_prefix = None;
}

Expand Down Expand Up @@ -90,25 +91,53 @@ let reconstruct_universe universe selections =
type options = {
drop_installed_packages : bool;
prefer_oldest : bool;
handle_avoid_version : bool;
prefer_installed : bool;
}

let parse_criteria criteria =
let default = {drop_installed_packages = false; prefer_oldest = false} in
match criteria with
| "" -> default
| "+removed" -> {drop_installed_packages = true; prefer_oldest = false}
| "+count[version-lag,solution]" -> {drop_installed_packages = false; prefer_oldest = true}
| "+removed,+count[version-lag,solution]" ->
{drop_installed_packages = true; prefer_oldest = true}
| _ ->
OpamConsole.warning "Criteria '%s' is not supported by the 0install solver" criteria;
default
let default =
{
drop_installed_packages = false;
prefer_oldest = false;
handle_avoid_version = false;
prefer_installed = false;
}
in
let rec parse default = function
| [] | [""] -> default
| "+removed"::xs ->
parse {default with drop_installed_packages = true} xs
| "+count[version-lag"::"solution]"::xs ->
parse {default with prefer_oldest = true} xs
| "-count[avoid-version"::"solution]"::xs ->
parse {default with handle_avoid_version = true} xs
| "-changed"::xs ->
parse {default with prefer_installed = true} xs
| criteria::xs ->
OpamConsole.warning
"Criteria '%s' is not supported by the 0install solver"
criteria;
parse default xs
in
parse default (String.split_on_char ',' criteria)

let call ~criteria ?timeout:_ (preamble, universe, request) =
let {drop_installed_packages; prefer_oldest} = parse_criteria criteria in
let {
drop_installed_packages;
prefer_oldest;
handle_avoid_version;
prefer_installed;
} =
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
~prefer_oldest ~handle_avoid_version ~prefer_installed
~constraints universe
in
match Opam_0install_cudf.solve context pkgs with
| Ok selections ->
let universe = reconstruct_universe universe selections in
Expand Down
4 changes: 2 additions & 2 deletions src_ext/Makefile.sources
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ MD5_dose3 = bc99cbcea8fca29dca3ebbee54be45e1
URL_mccs = https://github.com/ocaml-opam/ocaml-mccs/archive/refs/tags/1.1+17.tar.gz
MD5_mccs = 844d99bc531e0713238fe4b6b8511ed1

URL_opam-0install-cudf = https://github.com/ocaml-opam/opam-0install-solver/releases/download/v0.4.3/opam-0install-cudf-0.4.3.tbz
MD5_opam-0install-cudf = ae0c197deace373ad87737468a04f76b
URL_opam-0install-cudf = https://github.com/ocaml-opam/opam-0install-cudf/releases/download/v0.5.0/opam-0install-cudf-0.5.0.tar.gz
MD5_opam-0install-cudf = 75419722aa839f518a25cae1b3c6efd4

URL_0install-solver = https://github.com/0install/0install/releases/download/v2.18/0install-2.18.tbz
MD5_0install-solver = 030edc9b1d3676c06d51397ffb5a737d
Expand Down

0 comments on commit e684403

Please sign in to comment.