123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869moduleMake(Context:S.CONTEXT)=structmoduleInput=Model.Make(Context)letversion=Input.versionletpackage_name=Input.package_nameletformula=Input.formulaletrequirements~contextpkgs=letrole=matchpkgswith|[pkg]->Input.rolecontextpkg|pkgs->letimpl=Input.virtual_impl~context~depends:pkgs()inInput.virtual_role[impl]in{Input.role;command=None}moduleSolver=Zeroinstall_solver.Make(Input)moduleDiagnostics=Zeroinstall_solver.Diagnostics(Solver.Output)typet=Context.ttypeselections=Solver.Output.ttypediagnostics=Input.requirements(* So we can run another solve *)letsolvecontextpkgs=letreq=requirements~contextpkgsinmatchSolver.do_solve~closest_match:falsereqwith|Somesels->Oksels|None->Errorreqletpp_shortf(impl:Input.impl)=Input.pp_implfimplletrecpartitionf=function|[]->[],[]|x::xs->letys,zs=partitionfxsinmatchfxwith|`Lefty->(y::ys),zs|`Rightz->ys,(z::zs)letpp_rolemap~verbosefreasons=letshort,long=reasons|>Solver.Output.RoleMap.bindings|>partition(fun(_role,component)->matchDiagnostics.Component.selected_implcomponentwith|SomeimplwhenDiagnostics.Component.notescomponent=[]->`Leftimpl|_->`Rightcomponent)inletpp_itemfc=Fmt.pff"- @[%a@]"(Diagnostics.Component.pp~verbose)cinFmt.pff"Selected: @[<hov>%a@]@,%a"(Fmt.(list~sep:sp)pp_short)short(Fmt.(list~sep:cut)pp_item)longletdiagnostics_rolemapreq=Solver.do_solvereq~closest_match:true|>Option.get|>Diagnostics.of_resultletdiagnostics?(verbose=false)req=diagnostics_rolemapreq|>Fmt.str"Can't find all required versions.@\n@[<v0>%a@]"(pp_rolemap~verbose)letpackages_of_resultsels=sels|>Solver.Output.to_map|>Solver.Output.RoleMap.to_seq|>List.of_seq|>List.filter_map(fun(_role,sel)->Input.version(Solver.Output.unwrapsel))end