diff --git a/.github/workflows/ci.ml b/.github/workflows/ci.ml index 55808f635b1..e628ac7999e 100644 --- a/.github/workflows/ci.ml +++ b/.github/workflows/ci.ml @@ -472,7 +472,7 @@ let main oc : unit = (* 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_REPO_SHA", "6eee105e52e098e36949a584c053a18bcb9b2f6b"); ("SOLVER", ""); (* Cygwin configuration *) ("CYGWIN_MIRROR", "http://mirrors.kernel.org/sourceware/cygwin/"); diff --git a/.github/workflows/depexts.yml b/.github/workflows/depexts.yml index 7dcbcc1d9c5..88355bd2f5b 100644 --- a/.github/workflows/depexts.yml +++ b/.github/workflows/depexts.yml @@ -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: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4d7d9624140..87567fa4a5e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ env: OPAM12CACHE: ~/.cache/opam1.2/cache OPAM_REPO: https://github.com/ocaml/opam-repository.git OPAM_TEST_REPO_SHA: dff745994c64d083a6ba3ddc5a9c28ed0ad0f40a - OPAM_REPO_SHA: dff745994c64d083a6ba3ddc5a9c28ed0ad0f40a + OPAM_REPO_SHA: 6eee105e52e098e36949a584c053a18bcb9b2f6b SOLVER: CYGWIN_MIRROR: http://mirrors.kernel.org/sourceware/cygwin/ CYGWIN_ROOT: D:\cygwin diff --git a/configure b/configure index 6a916830055..b4f27953b88 100755 --- a/configure +++ b/configure @@ -6594,8 +6594,8 @@ printf "%s\n" "not found" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for OCaml findlib package opam-0install-cudf 0.4 or later" >&5 -printf %s "checking for OCaml findlib package opam-0install-cudf 0.4 or later... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for OCaml findlib package opam-0install-cudf 0.5.0 or later" >&5 +printf %s "checking for OCaml findlib package opam-0install-cudf 0.5.0 or later... " >&6; } if version=`$OCAMLFIND query opam-0install-cudf -format '%v' 2>/dev/null` then : @@ -6619,7 +6619,7 @@ then : -e 's/[^0-9]//g'` - ax_compare_version_B=`echo "0.4" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + ax_compare_version_B=`echo "0.5.0" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ diff --git a/configure.ac b/configure.ac index 1dd909807d4..b8eee9723cc 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) diff --git a/master_changes.md b/master_changes.md index 73bb678f71d..90369d5c2f7 100644 --- a/master_changes.md +++ b/master_changes.md @@ -94,6 +94,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 @@ -121,6 +123,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 diff --git a/opam-solver.opam b/opam-solver.opam index 7a15dbef61c..40ead91ed5c 100644 --- a/opam-solver.opam +++ b/opam-solver.opam @@ -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" diff --git a/src/solver/opamBuiltin0install.ml b/src/solver/opamBuiltin0install.ml index bc5c9c3fa37..3c672a760a0 100644 --- a/src/solver/opamBuiltin0install.ml +++ b/src/solver/opamBuiltin0install.ml @@ -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; } @@ -90,25 +91,54 @@ 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 (criteria : OpamCudfCriteria.criterion list) = + match criteria with + | [] -> default + | (Plus, Removed, None)::xs -> + parse {default with drop_installed_packages = true} xs + | (Plus, Solution, Some "version-lag")::xs -> + parse {default with prefer_oldest = true} xs + | (Minus, Solution, Some "avoid-version")::xs -> + parse {default with handle_avoid_version = true} xs + | (Minus, Changed, None)::xs -> + parse {default with prefer_installed = true} xs + | criterion::xs -> + OpamConsole.warning + "Criteria '%s' is not supported by the 0install solver" + (OpamCudfCriteria.criterion_to_string criterion); + parse default xs + in + parse default (OpamCudfCriteria.of_string 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 diff --git a/src_ext/Makefile.sources b/src_ext/Makefile.sources index b8079bbedb3..0bd663c1324 100644 --- a/src_ext/Makefile.sources +++ b/src_ext/Makefile.sources @@ -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