Skip to content

Commit

Permalink
Now reasonably fast :)
Browse files Browse the repository at this point in the history
  • Loading branch information
AltGr authored and rjbou committed Mar 23, 2021
1 parent 2043667 commit 08f5950
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 35 deletions.
13 changes: 10 additions & 3 deletions src/client/opamClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ let init
"Initial download of repository failed.");
let default_compiler =
if dontswitch then [] else
let chrono = OpamConsole.timer () in
let alternatives =
OpamFormula.to_dnf
(OpamFile.InitConfig.default_compiler init_config)
Expand All @@ -907,10 +908,16 @@ let init
~requested:OpamPackage.Name.Set.empty Query
in
let univ = { univ with u_invariant = invariant } in
OpamStd.List.find_opt
(OpamSolver.atom_coinstallability_check univ)
let default_compiler =
OpamStd.List.find_opt
(OpamSolver.atom_coinstallability_check univ)
alternatives
|> OpamStd.Option.default []
|> OpamStd.Option.default []
in
log "Selected default compiler %s in %0.3fs"
(OpamFormula.string_of_atoms default_compiler)
(chrono ());
default_compiler
in
gt, OpamRepositoryState.unlock ~cleanup:false rt, default_compiler
with e ->
Expand Down
34 changes: 13 additions & 21 deletions src/solver/opamSolver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -634,29 +634,21 @@ let check_for_conflicts universe =
coinstallability_check universe universe.u_installed

let atom_coinstallability_check universe atoms =
let packages = OpamFormula.packages_of_atoms universe.u_available atoms in
let map = OpamPackage.to_map packages in
List.for_all (fun (n, _) -> OpamPackage.Name.Map.mem n map) atoms &&
let version_map = cudf_versions_map universe universe.u_packages in
let check_pkg = {
Cudf.default_package with
package = "=check_coinstallability";
depends = List.map (fun at -> [atom2cudf () version_map at]) atoms;
} in
let cudf_universe =
load_cudf_universe ~build:true ~post:true ~version_map ~add_invariant:true
universe universe.u_packages ()
in
let cudf_ll =
OpamPackage.Name.Map.fold (fun n versions acc ->
let packages =
OpamPackage.Version.Set.fold
(fun v -> OpamPackage.(Set.add (create n v)))
versions OpamPackage.Set.empty
in
opam2cudf
universe ~depopts:false ~build:true ~post:true version_map
packages
:: acc)
map []
in
let result = Algo.Depsolver.edos_coinstall_prod cudf_universe cudf_ll in
List.exists Algo.Diagnostic.is_solution result
Cudf.load_universe
(check_pkg ::
opam_invariant_package version_map universe.u_invariant ::
opam2cudf universe version_map universe.u_available
~depopts:false ~build:true ~post:true)
in
Algo.Depsolver.edos_install cudf_universe check_pkg
|> Algo.Diagnostic.is_solution

let new_packages sol =
OpamCudf.ActionGraph.fold_vertex (fun action packages ->
Expand Down
12 changes: 8 additions & 4 deletions tests/reftests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,10 @@
(targets root-009e00fa)
(action
(progn
(ignore-stdout
(run %{bin:opam} init --root=%{targets}
--no-setup --bypass-checks --no-opamrc --bare
file://%{dep:opam-repo-009e00fa}))))
file://%{dep:opam-repo-009e00fa})))))

(rule
(targets opam-archive-632bc2e.tar.gz)
Expand All @@ -257,9 +258,10 @@
(targets root-632bc2e)
(action
(progn
(ignore-stdout
(run %{bin:opam} init --root=%{targets}
--no-setup --bypass-checks --no-opamrc --bare
file://%{dep:opam-repo-632bc2e}))))
file://%{dep:opam-repo-632bc2e})))))

(rule
(targets opam-archive-c1d23f0e.tar.gz)
Expand All @@ -276,9 +278,10 @@
(targets root-c1d23f0e)
(action
(progn
(ignore-stdout
(run %{bin:opam} init --root=%{targets}
--no-setup --bypass-checks --no-opamrc --bare
file://%{dep:opam-repo-c1d23f0e}))))
file://%{dep:opam-repo-c1d23f0e})))))

(rule
(targets opam-archive-f372039d.tar.gz)
Expand All @@ -295,6 +298,7 @@
(targets root-f372039d)
(action
(progn
(ignore-stdout
(run %{bin:opam} init --root=%{targets}
--no-setup --bypass-checks --no-opamrc --bare
file://%{dep:opam-repo-f372039d}))))
file://%{dep:opam-repo-f372039d})))))
3 changes: 2 additions & 1 deletion tests/reftests/gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ let opam_init_rule archive_hash =
(targets %s)
(action
(progn
(ignore-stdout
(run %%{bin:opam} init --root=%%{targets}
--no-setup --bypass-checks --no-opamrc --bare
file://%%{dep:%s}))))
file://%%{dep:%s})))))
|} (opamroot_directory ~archive_hash) (repo_directory ~archive_hash)

module StringSet = Set.Make(String)
Expand Down
9 changes: 3 additions & 6 deletions tests/reftests/init.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
### tar xzf ${OPAMROOT}/repo/default.tar.gz
### rm -rf ${OPAMROOT}
### OPAMVAR_sys_ocaml_version=''
### opam init --no-setup default default/ --fake
### opam init --no-setup --bypass-checks default default/ --fake
No configuration file found, using built-in defaults.
Checking for available remotes: rsync and local, git, mercurial, darcs. Perfect!

<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[default] Initialised
Expand Down Expand Up @@ -35,9 +34,8 @@ Done.
["ocaml" {>= "4.05.0"}]
### rm -rf ${OPAMROOT}
### OPAMVAR_sys_ocaml_version=4.02.3
### opam init --no-setup default default/ --fake
### opam init --no-setup --bypass-checks default default/ --fake
No configuration file found, using built-in defaults.
Checking for available remotes: rsync and local, git, mercurial, darcs. Perfect!

<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[default] Initialised
Expand Down Expand Up @@ -67,9 +65,8 @@ Done.
["ocaml" {>= "4.05.0"}]
### rm -rf ${OPAMROOT}
### OPAMVAR_sys_ocaml_version=4.07.0
### opam init --no-setup default default/ --fake
### opam init --no-setup --bypass-checks default default/ --fake
No configuration file found, using built-in defaults.
Checking for available remotes: rsync and local, git, mercurial, darcs. Perfect!

<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[default] Initialised
Expand Down

0 comments on commit 08f5950

Please sign in to comment.