Do not call solver multiple times, reuse same assertion

Introduce Cut(), it allows to filter in the assertion to achieve the same hashes
This commit is contained in:
Ettore Di Giacinto
2019-12-14 15:00:16 +01:00
parent c4b83605ef
commit fe608469d8
4 changed files with 50 additions and 7 deletions

View File

@@ -442,17 +442,13 @@ func (cs *LuetCompiler) ComputeDepTree(p CompilationSpec) (solver.PackagesAssert
dependencies := solution.Order(cs.Database, p.GetPackage().GetFingerPrint())
assertions := solver.PackagesAssertions{}
for _, assertion := range dependencies { //highly dependent on the order
if assertion.Value {
nthsolution, err := s.Install([]pkg.Package{assertion.Package})
if err != nil {
return nil, errors.Wrap(err, "While computing a solution for "+p.GetPackage().GetName())
}
nthsolution := dependencies.Cut(assertion.Package)
assertion.Hash = solver.PackageHash{
BuildHash: nthsolution.Order(cs.Database, assertion.Package.GetFingerPrint()).Drop(assertion.Package).AssertionHash(),
PackageHash: nthsolution.Order(cs.Database, assertion.Package.GetFingerPrint()).AssertionHash(),
BuildHash: nthsolution.Drop(assertion.Package).AssertionHash(),
PackageHash: nthsolution.AssertionHash(),
}
assertions = append(assertions, assertion)
}