BSolver: Add VerifyInstallation()
... and implement it in LibsolvSolver.
This commit is contained in:
@@ -32,6 +32,7 @@ public:
|
|||||||
virtual status_t Install(
|
virtual status_t Install(
|
||||||
const BSolverPackageSpecifierList&
|
const BSolverPackageSpecifierList&
|
||||||
packages) = 0;
|
packages) = 0;
|
||||||
|
virtual status_t VerifyInstallation() = 0;
|
||||||
|
|
||||||
bool HasProblems() const
|
bool HasProblems() const
|
||||||
{ return CountProblems() > 0; }
|
{ return CountProblems() > 0; }
|
||||||
|
|||||||
@@ -220,32 +220,35 @@ LibsolvSolver::Install(const BSolverPackageSpecifierList& packages)
|
|||||||
queue_push(&jobs, matchingPackages.elements[j]);
|
queue_push(&jobs, matchingPackages.elements[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add solver mode to job queue elements
|
// set jobs' solver mode and solve
|
||||||
int solverMode = SOLVER_INSTALL;
|
_SetJobsSolverMode(jobs, SOLVER_INSTALL);
|
||||||
for (int i = 0; i < jobs.count; i += 2) {
|
|
||||||
jobs.elements[i] |= solverMode;
|
|
||||||
// if (cleandeps)
|
|
||||||
// jobs.elements[i] |= SOLVER_CLEANDEPS;
|
|
||||||
// if (forcebest)
|
|
||||||
// jobs.elements[i] |= SOLVER_FORCEBEST;
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the solver and solve
|
return _Solve(jobs);
|
||||||
fSolver = solver_create(fPool);
|
}
|
||||||
solver_set_flag(fSolver, SOLVER_FLAG_SPLITPROVIDES, 1);
|
|
||||||
solver_set_flag(fSolver, SOLVER_FLAG_BEST_OBEY_POLICY, 1);
|
|
||||||
|
|
||||||
// get the problems (if any)
|
|
||||||
fProblems.MakeEmpty();
|
|
||||||
|
|
||||||
int problemCount = solver_solve(fSolver, &jobs);
|
status_t
|
||||||
for (Id problemId = 1; problemId <= problemCount; problemId++) {
|
LibsolvSolver::VerifyInstallation()
|
||||||
error = _AddProblem(problemId);
|
{
|
||||||
if (error != B_OK)
|
if (fInstalledRepository == NULL)
|
||||||
return error;
|
return B_BAD_VALUE;
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
// add repositories to pool
|
||||||
|
status_t error = _AddRepositories();
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
// prepare pool for solving
|
||||||
|
pool_createwhatprovides(fPool);
|
||||||
|
|
||||||
|
// add the verify job to the job queue
|
||||||
|
SolvQueue jobs;
|
||||||
|
queue_push2(&jobs, SOLVER_SOLVABLE_ALL, 0);
|
||||||
|
|
||||||
|
// set jobs' solver mode and solve
|
||||||
|
_SetJobsSolverMode(jobs, SOLVER_VERIFY);
|
||||||
|
|
||||||
|
return _Solve(jobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -617,3 +620,39 @@ LibsolvSolver::_GetResolvableExpression(Id id,
|
|||||||
_expression.SetTo(name, op, version);
|
_expression.SetTo(name, op, version);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
LibsolvSolver::_Solve(Queue& jobs)
|
||||||
|
{
|
||||||
|
// create the solver and solve
|
||||||
|
fSolver = solver_create(fPool);
|
||||||
|
solver_set_flag(fSolver, SOLVER_FLAG_SPLITPROVIDES, 1);
|
||||||
|
solver_set_flag(fSolver, SOLVER_FLAG_BEST_OBEY_POLICY, 1);
|
||||||
|
|
||||||
|
int problemCount = solver_solve(fSolver, &jobs);
|
||||||
|
|
||||||
|
// get the problems (if any)
|
||||||
|
fProblems.MakeEmpty();
|
||||||
|
|
||||||
|
for (Id problemId = 1; problemId <= problemCount; problemId++) {
|
||||||
|
status_t error = _AddProblem(problemId);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
LibsolvSolver::_SetJobsSolverMode(Queue& jobs, int solverMode)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < jobs.count; i += 2) {
|
||||||
|
jobs.elements[i] |= solverMode;
|
||||||
|
// if (cleandeps)
|
||||||
|
// jobs.elements[i] |= SOLVER_CLEANDEPS;
|
||||||
|
// if (forcebest)
|
||||||
|
// jobs.elements[i] |= SOLVER_FORCEBEST;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public:
|
|||||||
virtual status_t Install(
|
virtual status_t Install(
|
||||||
const BSolverPackageSpecifierList&
|
const BSolverPackageSpecifierList&
|
||||||
packages);
|
packages);
|
||||||
|
virtual status_t VerifyInstallation();
|
||||||
|
|
||||||
virtual int32 CountProblems() const;
|
virtual int32 CountProblems() const;
|
||||||
virtual BSolverProblem* ProblemAt(int32 index) const;
|
virtual BSolverProblem* ProblemAt(int32 index) const;
|
||||||
@@ -64,6 +65,9 @@ private:
|
|||||||
BPackageResolvableExpression& _expression)
|
BPackageResolvableExpression& _expression)
|
||||||
const;
|
const;
|
||||||
|
|
||||||
|
status_t _Solve(Queue& jobs);
|
||||||
|
void _SetJobsSolverMode(Queue& jobs, int solverMode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Pool* fPool;
|
Pool* fPool;
|
||||||
Solver* fSolver;
|
Solver* fSolver;
|
||||||
|
|||||||
Reference in New Issue
Block a user