1
0
Fork 0

Policy rules cannot conflict with jobs anymore

As we no longer need special feature rules for updating installed packages
we don't have policy rules which might conflict with job rules anymore.
Everything is driven by jobs now.
pull/667/head
Nils Adermann 2012-04-27 18:21:25 +02:00
parent 5feff954a4
commit c51fedef8c
1 changed files with 0 additions and 196 deletions

View File

@ -481,191 +481,6 @@ class Solver
}
$this->disableProblem($why);
/** TODO solver_reenablepolicyrules(solv, -(v + 1)); */
}
}
/***********************************************************************
***
*** Policy rule disabling/reenabling
***
*** Disable all policy rules that conflict with our jobs. If a job
*** gets disabled later on, reenable the involved policy rules again.
***
*** /
#define DISABLE_UPDATE 1
#define DISABLE_INFARCH 2
#define DISABLE_DUP 3
*/
protected function jobToDisableQueue(array $job, array $disableQueue)
{
switch ($job['cmd']) {
case 'install':
foreach ($job['packages'] as $package) {
if (isset($this->installedMap[$package->getId()])) {
$disableQueue[] = array('type' => 'update', 'package' => $package);
}
/* all job packages obsolete * /
qstart = q->count;
pass = 0;
memset(&omap, 0, sizeof(omap));
FOR_JOB_SELECT(p, pp, select, what)
{
Id p2, pp2;
if (pass == 1)
map_grow(&omap, installed->end - installed->start);
s = pool->solvables + p;
if (s->obsoletes)
{
Id obs, *obsp;
obsp = s->repo->idarraydata + s->obsoletes;
while ((obs = *obsp++) != 0)
FOR_PROVIDES(p2, pp2, obs)
{
Solvable *ps = pool->solvables + p2;
if (ps->repo != installed)
continue;
if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps, obs))
continue;
if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
continue;
if (pass)
MAPSET(&omap, p2 - installed->start);
else
queue_push2(q, DISABLE_UPDATE, p2);
}
}
FOR_PROVIDES(p2, pp2, s->name)
{
Solvable *ps = pool->solvables + p2;
if (ps->repo != installed)
continue;
if (!pool->implicitobsoleteusesprovides && ps->name != s->name)
continue;
if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
continue;
if (pass)
MAPSET(&omap, p2 - installed->start);
else
queue_push2(q, DISABLE_UPDATE, p2);
}
if (pass)
{
for (i = j = qstart; i < q->count; i += 2)
{
if (MAPTST(&omap, q->elements[i + 1] - installed->start))
{
MAPCLR(&omap, q->elements[i + 1] - installed->start);
q->elements[j + 1] = q->elements[i + 1];
j += 2;
}
}
queue_truncate(q, j);
}
if (q->count == qstart)
break;
pass++;
}
if (omap.size)
map_free(&omap);
if (qstart == q->count)
return; /* nothing to prune * /
if ((set & (SOLVER_SETEVR | SOLVER_SETARCH | SOLVER_SETVENDOR)) == (SOLVER_SETEVR | SOLVER_SETARCH | SOLVER_SETVENDOR))
return; /* all is set */
/* now that we know which installed packages are obsoleted check each of them * /
for (i = j = qstart; i < q->count; i += 2)
{
Solvable *is = pool->solvables + q->elements[i + 1];
FOR_JOB_SELECT(p, pp, select, what)
{
int illegal = 0;
s = pool->solvables + p;
if ((set & SOLVER_SETEVR) != 0)
illegal |= POLICY_ILLEGAL_DOWNGRADE; /* ignore * /
if ((set & SOLVER_SETARCH) != 0)
illegal |= POLICY_ILLEGAL_ARCHCHANGE; /* ignore * /
if ((set & SOLVER_SETVENDOR) != 0)
illegal |= POLICY_ILLEGAL_VENDORCHANGE; /* ignore * /
illegal = policy_is_illegal(solv, is, s, illegal);
if (illegal && illegal == POLICY_ILLEGAL_DOWNGRADE && (set & SOLVER_SETEV) != 0)
{
/* it's ok if the EV is different * /
if (evrcmp(pool, is->evr, s->evr, EVRCMP_COMPARE_EVONLY) != 0)
illegal = 0;
}
if (illegal)
break;
}
if (!p)
{
/* no package conflicts with the update rule * /
/* thus keep the DISABLE_UPDATE * /
q->elements[j + 1] = q->elements[i + 1];
j += 2;
}
}
queue_truncate(q, j);
return;*/
}
break;
case 'remove':
foreach ($job['packages'] as $package) {
if (isset($this->installedMap[$package->getId()])) {
$disableQueue[] = array('type' => 'update', 'package' => $package);
}
}
break;
}
return $disableQueue;
}
protected function disableUpdateRule($package)
{
if (isset($this->packageToFeatureRule[$package->getId()])) {
$this->packageToFeatureRule[$package->getId()]->disable();
}
}
/**
* Disables all policy rules that conflict with jobs
*/
protected function disablePolicyRules()
{
$lastJob = null;
$allQueue = array();
$iterator = $this->rules->getIteratorFor(RuleSet::TYPE_JOB);
foreach ($iterator as $rule) {
if ($rule->isDisabled()) {
continue;
}
$job = $this->ruleToJob[$rule->getId()];
if ($job === $lastJob) {
continue;
}
$lastJob = $job;
$allQueue = $this->jobToDisableQueue($job, $allQueue);
}
foreach ($allQueue as $disable) {
switch ($disable['type']) {
case 'update':
$this->disableUpdateRule($disable['package']);
break;
default:
throw new \RuntimeException("Unsupported disable type: " . $disable['type']);
}
}
}
@ -734,8 +549,6 @@ class Solver
$updates = $this->policy->findUpdatePackages($this, $this->pool, $this->installedMap, $package);
$rule = $this->createUpdateRule($package, $updates, Rule::RULE_INTERNAL_ALLOW_UPDATE, (string) $package);
$rule->setWeak(true);
//$this->addRule(RuleSet::TYPE_FEATURE, $rule);
$this->packageToFeatureRule[$package->getId()] = $rule;
}
@ -781,9 +594,6 @@ class Solver
$this->addWatchesToRule($rule);
}
/* disable update rules that conflict with our job */
$this->disablePolicyRules();
/* make decisions based on job/update assertions */
$this->makeAssertionRuleDecisions();
@ -1369,12 +1179,6 @@ class Solver
}
$this->disableProblem($why);
/**
@TODO what does v < 0 mean here? ($why == v)
if (v < 0)
solver_reenablepolicyrules(solv, -(v + 1));
*/
$this->resetSolver();
return true;