diff --git a/Makefile.config.in b/Makefile.config.in index 6b23ad3e174..9171697571a 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -9,6 +9,7 @@ PACKS = $(filter-out no,@OCAML_PKG_unix@ @OCAML_PKG_bigarray@ @OCAML_PKG_extlib@ CONF_OCAMLFLAGS = @CONF_OCAMLFLAGS@ MCCS_ENABLED = @MCCS_ENABLED@ +OPAM_0INSTALL_SOLVER_ENABLED = @OPAM_0INSTALL_SOLVER_ENABLED@ OCAMLLIB = @OCAMLLIB@ diff --git a/configure b/configure index 5aa7d8f4dca..4c36ec72777 100755 --- a/configure +++ b/configure @@ -627,6 +627,7 @@ hasalldeps ac_ct_CXX CXXFLAGS CXX +OCAML_PKG_opam_0install_cudf OCAML_PKG_mccs OCAML_PKG_opam_file_format OCAML_PKG_dose3_algo @@ -662,6 +663,7 @@ CONF_LIBACL_LINK EGREP GREP CPP +OPAM_0INSTALL_SOLVER_ENABLED MCCS_ENABLED DEVELOPER OBJEXT @@ -740,6 +742,7 @@ enable_version_check enable_checks enable_developer_mode with_mccs +with_0install_solver with_libacl with_private_runtime enable_cold_check @@ -1393,6 +1396,10 @@ Optional Packages: --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --without-mccs Compile without a built-in Cudf solver (only works if 'mccs' is not otherwise installed) + --without-0install-solver + Compile without the built-in 0install solver (only + works if 'opam-0install-cudf' is not otherwise + installed) --with-libacl Compile opam with libacl support --with-private-runtime For a mingw-w64 build, manifest the runtime DLLs locally in Opam.Runtime.arch @@ -3451,6 +3458,16 @@ else fi +# Check whether --with-0install-solver was given. +if test "${with_0install_solver+set}" = set; then : + withval=$with_0install_solver; +else + OPAM_0INSTALL_SOLVER_DEFAULT=yes + +fi + + + # Check whether --with-libacl was given. if test "${with_libacl+set}" = set; then : @@ -4276,6 +4293,13 @@ else MCCS_ENABLED=true fi +if test "x${with_0install_solver}" = "xno"; then : + OPAM_0INSTALL_SOLVER_ENABLED=false + +else + OPAM_0INSTALL_SOLVER_ENABLED=true + +fi ac_ext=c @@ -6020,9 +6044,36 @@ $as_echo "not found" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OCaml findlib package opam-0install-cudf" >&5 +$as_echo_n "checking for OCaml findlib package opam-0install-cudf... " >&6; } + + unset found + unset pkg + found=no + for pkg in opam-0install-cudf ; do + if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + OCAML_PKG_opam_0install_cudf=$pkg + found=yes + break + fi + done + if test "$found" = "no" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + OCAML_PKG_opam_0install_cudf=no + fi + + + + if test "x${with_mccs}" = "xno" && test "x$OCAML_PKG_mccs" != "xno"; then : as_fn_error $? "Option --without-mccs is not available without uninstalling the 'mccs' package" "$LINENO" 5 fi +if test "x${with_0install_solver}" = "xno" && test "x$OCAML_PKG_opam_0install_cudf" != "xno"; then : + as_fn_error $? "Option --without-0install-solver is not available without uninstalling the 'opam-0install-cudf' package" "$LINENO" 5 +fi if test "x$MCCS_ENABLED" = "xtrue"; then : @@ -6311,6 +6362,57 @@ fi fi +if test "x$MCCS_ENABLED" = "xtrue"; then : + + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "$OCAMLVERSION" | 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' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "4.08" | 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' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/false/;s/x${ax_compare_version_B}/true/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + + if test "x$OPAM_0INSTALL_SOLVER_DEFAULT" = "xyes"; then : + + OPAM_0INSTALL_SOLVER_ENABLED=false + + +else + + as_fn_error $? "Your version of OCaml: $OCAMLVERSION does not support the requested 0install-solver. \ + You can either re-run the configure script with --without-0install-solver or use make cold" "$LINENO" 5 + +fi + + fi + + +fi echo @@ -6323,7 +6425,8 @@ if test "x${enable_checks}" != "xno" && { test "x$OCAML_PKG_dose3_common" = "xno" || test "x$OCAML_PKG_opam_file_format" = "xno" || test "x$CPPO" = "x" || - test "x$OCAML_PKG_mccs$MCCS_ENABLED" = "xnotrue";}; then : + test "x$OCAML_PKG_mccs$MCCS_ENABLED" = "xnotrue" || + test "x$OCAML_PKG_opam_0install_cudf$OPAM_0INSTALL_SOLVER_ENABLED" = "xnotrue";}; then : echo "============================================================================" echo "Some dependencies are missing. If you are just interested in the stand-alone" @@ -7549,7 +7652,7 @@ bindir="`eval echo ${bindir}`" mandir="`eval echo ${mandir}`" mandir="`eval echo ${mandir}`" -if test "x$MCCS_ENABLED" = "xfalse"; then : +if test "x$MCCS_ENABLED" = "xfalse" -a "x$OPAM_0INSTALL_SOLVER_ENABLED" = "xfalse"; then : echo "Opam will be built WITHOUT a built-in solver" diff --git a/configure.ac b/configure.ac index ff5c7ded63f..332b66b3717 100644 --- a/configure.ac +++ b/configure.ac @@ -57,6 +57,13 @@ AC_ARG_WITH([mccs], AC_HELP_STRING([--without-mccs], [Compile without a built-in Cudf solver (only works if 'mccs' is not otherwise installed)]),[],[MCCS_DEFAULT=yes] ) +AC_ARG_WITH([0install-solver], + AC_HELP_STRING([--without-0install-solver], + [Compile without the built-in 0install solver (only works if 'opam-0install-cudf' is not otherwise installed)]), + [], + [OPAM_0INSTALL_SOLVER_DEFAULT=yes] +) + AC_ARG_WITH([libacl], AC_HELP_STRING([--with-libacl], @@ -144,6 +151,7 @@ AS_IF([test "x${enable_developer_mode}" = "xyes"],[ ]) AS_IF([test "x${with_mccs}" = "xno"], [AC_SUBST(MCCS_ENABLED,false)], [AC_SUBST(MCCS_ENABLED,true)]) +AS_IF([test "x${with_0install_solver}" = "xno"], [AC_SUBST(OPAM_0INSTALL_SOLVER_ENABLED,false)], [AC_SUBST(OPAM_0INSTALL_SOLVER_ENABLED,true)]) AS_IF([test "x${with_libacl}" != "xno"],[ have_libacl=yes @@ -321,9 +329,12 @@ AC_CHECK_OCAML_PKG(dose3.common,dose.common) AC_CHECK_OCAML_PKG(dose3.algo,dose.algo) AC_CHECK_OCAML_PKG([opam-file-format]) AC_CHECK_OCAML_PKG([mccs]) +AC_CHECK_OCAML_PKG([opam-0install-cudf]) AS_IF([test "x${with_mccs}" = "xno" && test "x$OCAML_PKG_mccs" != "xno"], [AC_MSG_ERROR([Option --without-mccs is not available without uninstalling the 'mccs' package])]) +AS_IF([test "x${with_0install_solver}" = "xno" && test "x$OCAML_PKG_opam_0install_cudf" != "xno"], + [AC_MSG_ERROR([Option --without-0install-solver is not available without uninstalling the 'opam-0install-cudf' package])]) dnl -- that's what we would like to do, but no way to disable mccs in jbuilder dnl -- if it's installed, at the moment @@ -349,6 +360,16 @@ AS_IF([test "x$MCCS_ENABLED" = "xtrue"],[ ]) ]) +AS_IF([test "x$MCCS_ENABLED" = "xtrue"],[ + AX_COMPARE_VERSION([$OCAMLVERSION], [lt], [4.08],[ + AS_IF([test "x$OPAM_0INSTALL_SOLVER_DEFAULT" = "xyes"],[ + AC_SUBST(OPAM_0INSTALL_SOLVER_ENABLED,false) + ],[ + AC_MSG_ERROR([Your version of OCaml: $OCAMLVERSION does not support the requested 0install-solver. \ + You can either re-run the configure script with --without-0install-solver or use make cold]) + ]) + ]) +]) dnl echo dnl echo "extlib........................ ${OCAML_PKG_extlib}" @@ -368,7 +389,8 @@ AS_IF([test "x${enable_checks}" != "xno" && { test "x$OCAML_PKG_dose3_common" = "xno" || test "x$OCAML_PKG_opam_file_format" = "xno" || test "x$CPPO" = "x" || - test "x$OCAML_PKG_mccs$MCCS_ENABLED" = "xnotrue";}],[ + test "x$OCAML_PKG_mccs$MCCS_ENABLED" = "xnotrue" || + test "x$OCAML_PKG_opam_0install_cudf$OPAM_0INSTALL_SOLVER_ENABLED" = "xnotrue";}],[ echo "============================================================================" echo "Some dependencies are missing. If you are just interested in the stand-alone" echo "'opam' binary, run 'make lib-ext' to download and include them." @@ -423,7 +445,7 @@ bindir="`eval echo ${bindir}`" mandir="`eval echo ${mandir}`" mandir="`eval echo ${mandir}`" -AS_IF([test "x$MCCS_ENABLED" = "xfalse"],[ +AS_IF([test "x$MCCS_ENABLED" = "xfalse" -a "x$OPAM_0INSTALL_SOLVER_ENABLED" = "xfalse"],[ echo "Opam will be built WITHOUT a built-in solver" ],[ echo "Opam will be built WITH a built-in solver" diff --git a/master_changes.md b/master_changes.md index 828d0556e47..bb8357ff2c0 100644 --- a/master_changes.md +++ b/master_changes.md @@ -120,6 +120,7 @@ New option/command/subcommand are prefixed with ◈. * Fix Cudf preprocessing [#4534 #4627 @AltGr - fix #4624] * Allow to upgrade to a hidden-version package if a hidden-version package is already installed [#4525 @kit-ty-kate] * Add support for a few select criteria useful to CI to the 0install solver: `+count[version-lag,solution]` to always choose the oldest version available, `+removed` to not try to keep installed packages [#4631 @kit-ty-kate] + * Build opam with the builtin 0install solver whenever possible [#4643 @kit-ty-kate] ## Client * ✘ Environment variables initialised only at opam client launch, no more via libraries [#4606 @rjbou] diff --git a/src_ext/Makefile b/src_ext/Makefile index 7a799035839..d577435e484 100644 --- a/src_ext/Makefile +++ b/src_ext/Makefile @@ -33,12 +33,16 @@ MD5_PKG_$(1) = $(MD5_$(1)) endef SRC_EXTS = cppo extlib re cmdliner ocamlgraph cudf dose3 opam-file-format result seq stdlib-shims -PKG_EXTS = $(SRC_EXTS) dune-local findlib ocamlbuild topkg mccs +PKG_EXTS = $(SRC_EXTS) dune-local findlib ocamlbuild topkg mccs opam-0install-cudf 0install-solver ifeq ($(MCCS_ENABLED),true) SRC_EXTS := $(SRC_EXTS) mccs endif +ifeq ($(0INSTALL_SOLVER_ENABLED),true) +SRC_EXTS := $(SRC_EXTS) opam-0install-cudf 0install-solver +endif + include Makefile.sources ifneq ($(shell PATH="$(PATH)" command -v ocamlc 2>/dev/null),) include Makefile.packages diff --git a/src_ext/Makefile.packages b/src_ext/Makefile.packages index 76cf8b0482d..bd2c8900151 100644 --- a/src_ext/Makefile.packages +++ b/src_ext/Makefile.packages @@ -41,6 +41,10 @@ dose3.pkgbuild: findlib.pkgbuild ocamlbuild.pkgbuild cppo.pkgbuild extlib.pkgbui # mccs.pkgbuild depends on findlib because the files are explicitly installed using it mccs.pkgbuild: dune-local.pkgbuild cudf.pkgbuild findlib.pkgbuild +opam-0install-cudf.pkgbuild: dune-local.pkgbuild cudf.pkgbuild 0install-solver + +0install-solver.pkgbuild: dune-local.pkgbuild + stdlib-shims.pkgbuild: dune-local.pkgbuild dune-local.pkgbuild: findlib.pkgbuild @@ -107,6 +111,14 @@ mccs-pkg-build: ocamlfind install mccs $(addprefix _build/install/default/lib/,$(addprefix mccs/,META libmccs_stubs.$(EXT_LIB) mccs.*) stublibs/*.$(EXT_DLL)) cp -RL _build/install/default/lib/mccs/glpk $(SITELIB)/mccs/ +opam-0install-cudf-pkg-build: + dune build @install -p opam-0install-cudf + dune install -p opam-0install-cudf opam-0install-cudf + +0install-solver-pkg-build: + dune build @install -p 0install-solver + dune install -p 0install-solver 0install-solver + seq-pkg-build: dune build @install -p seq dune install -p seq seq diff --git a/src_ext/Makefile.sources b/src_ext/Makefile.sources index c495835177c..2d58a2a982a 100644 --- a/src_ext/Makefile.sources +++ b/src_ext/Makefile.sources @@ -38,6 +38,16 @@ MD5_mccs = 7086eefb41e631a63e26b23577cef582 $(call PKG_SAME,mccs) +URL_opam-0install-cudf = /~https://github.com/ocaml-opam/opam-0install-solver/releases/download/v0.4.1/opam-0install-cudf-v0.4.1.tbz +MD5_opam-0install-cudf = 44e6d5a7fcdbc130db5dc86a6b9aeca6 + +$(call PKG_SAME,opam-0install-cudf) + +URL_0install-solver = /~https://github.com/0install/0install/releases/download/v2.17/0install-v2.17.tbz +MD5_0install-solver = 50daf035b04b29399a3c6e6f965ac447 + +$(call PKG_SAME,0install-solver) + URL_opam-file-format = /~https://github.com/ocaml/opam-file-format/archive/2.1.2.tar.gz MD5_opam-file-format = f16ed774167fc1881876b8185087e0ab