/*-------------------------------------------------------------------
* Check if dependency is possible
*
- * mirrors solver_dep_fulfilled but uses map m instead of the decisionmap
- * used in solver_addrpmrulesforweak and solver_createcleandepsmap
+ * mirrors solver_dep_fulfilled but uses map m instead of the decisionmap.
+ * used in solver_addrpmrulesforweak and solver_createcleandepsmap.
*/
static inline int
}
int
-solver_samerule(Solver *solv, Rule *r1, Rule *r2)
+solver_rulecmp(Solver *solv, Rule *r1, Rule *r2)
{
return unifyrules_sortcmp(r1, r2, solv->pool);
}
return r;
}
+void
+solver_shrinkrules(Solver *solv, int nrules)
+{
+ solv->nrules = nrules;
+ solv->rules = solv_extend_resize(solv->rules, solv->nrules, sizeof(Rule), RULES_BLOCK);
+}
/******************************************************************************
***
dontfix = 1; /* dont care about broken rpm deps */
}
- if (!dontfix
- && s->arch != ARCH_SRC
- && s->arch != ARCH_NOSRC
- && !pool_installable(pool, s))
+ if (!dontfix)
{
- POOL_DEBUG(SOLV_DEBUG_RULE_CREATION, "package %s [%d] is not installable\n", pool_solvable2str(pool, s), (Id)(s - pool->solvables));
- addrpmrule(solv, -n, 0, SOLVER_RULE_RPM_NOT_INSTALLABLE, 0);
+ if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC
+ ? pool_disabled_solvable(pool, s)
+ : !pool_installable(pool, s))
+ {
+ POOL_DEBUG(SOLV_DEBUG_RULE_CREATION, "package %s [%d] is not installable\n", pool_solvable2str(pool, s), (Id)(s - pool->solvables));
+ addrpmrule(solv, -n, 0, SOLVER_RULE_RPM_NOT_INSTALLABLE, 0);
+ }
}
/* yet another SUSE hack, sigh */
continue;
s = pool->solvables + i;
- if (!pool_installable(pool, s)) /* only look at installable ones */
+ if (!s->repo)
continue;
+ if (s->repo != pool->installed && !pool_installable(pool, s))
+ continue; /* only look at installable ones */
sup = 0;
if (s->supplements)
}
qs.count = j;
}
+ else if (p != -SYSTEMSOLVABLE)
+ {
+ /* could fallthrough, but then we would do pool_queuetowhatprovides twice */
+ queue_free(&qs);
+ solver_addrule(solv, p, d); /* allow update of s */
+ return;
+ }
}
if (qs.count && p == -SYSTEMSOLVABLE)
p = queue_shift(&qs);
r = solv->rules + solv->featurerules + (p - solv->installed->start);
if (r->p && r->d >= 0)
solver_disablerule(solv, r);
+ if (solv->bestrules_pkg)
+ {
+ int i, ni;
+ ni = solv->bestrules_end - solv->bestrules;
+ for (i = 0; i < ni; i++)
+ if (solv->bestrules_pkg[i] == p)
+ solver_disablerule(solv, solv->rules + solv->bestrules + i);
+ }
}
static inline void
r = solv->rules + solv->updaterules + (p - solv->installed->start);
if (r->p)
{
- if (r->d >= 0)
- return;
- solver_enablerule(solv, r);
- IF_POOLDEBUG (SOLV_DEBUG_SOLUTIONS)
+ if (r->d < 0)
{
- POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "@@@ re-enabling ");
- solver_printruleclass(solv, SOLV_DEBUG_SOLUTIONS, r);
+ solver_enablerule(solv, r);
+ IF_POOLDEBUG (SOLV_DEBUG_SOLUTIONS)
+ {
+ POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "@@@ re-enabling ");
+ solver_printruleclass(solv, SOLV_DEBUG_SOLUTIONS, r);
+ }
}
- return;
}
- r = solv->rules + solv->featurerules + (p - solv->installed->start);
- if (r->p && r->d < 0)
+ else
{
- solver_enablerule(solv, r);
- IF_POOLDEBUG (SOLV_DEBUG_SOLUTIONS)
+ r = solv->rules + solv->featurerules + (p - solv->installed->start);
+ if (r->p && r->d < 0)
{
- POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "@@@ re-enabling ");
- solver_printruleclass(solv, SOLV_DEBUG_SOLUTIONS, r);
+ solver_enablerule(solv, r);
+ IF_POOLDEBUG (SOLV_DEBUG_SOLUTIONS)
+ {
+ POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "@@@ re-enabling ");
+ solver_printruleclass(solv, SOLV_DEBUG_SOLUTIONS, r);
+ }
}
}
+ if (solv->bestrules_pkg)
+ {
+ int i, ni;
+ ni = solv->bestrules_end - solv->bestrules;
+ for (i = 0; i < ni; i++)
+ if (solv->bestrules_pkg[i] == p)
+ solver_enablerule(solv, solv->rules + solv->bestrules + i);
+ }
}
***
***/
+static inline void
+add_cleandeps_package(Solver *solv, Id p)
+{
+ if (!solv->cleandeps_updatepkgs)
+ {
+ solv->cleandeps_updatepkgs = solv_calloc(1, sizeof(Queue));
+ queue_init(solv->cleandeps_updatepkgs);
+ }
+ queue_pushunique(solv->cleandeps_updatepkgs, p);
+}
+
+static inline void
+solver_addtodupmaps(Solver *solv, Id p, Id how, int targeted)
+{
+ Pool *pool = solv->pool;
+ Solvable *ps, *s = pool->solvables + p;
+ Repo *installed = solv->installed;
+ Id pi, pip, obs, *obsp;
+
+ MAPSET(&solv->dupinvolvedmap, p);
+ if (targeted)
+ MAPSET(&solv->dupmap, p);
+ FOR_PROVIDES(pi, pip, s->name)
+ {
+ ps = pool->solvables + pi;
+ if (ps->name != s->name)
+ continue;
+ MAPSET(&solv->dupinvolvedmap, pi);
+ if (targeted && ps->repo == installed && solv->obsoletes && solv->obsoletes[pi - installed->start])
+ {
+ Id *opp, pi2;
+ for (opp = solv->obsoletes_data + solv->obsoletes[pi - installed->start]; (pi2 = *opp++) != 0;)
+ if (pool->solvables[pi2].repo != installed)
+ MAPSET(&solv->dupinvolvedmap, pi2);
+ }
+ if (ps->repo == installed && (how & SOLVER_FORCEBEST) != 0)
+ {
+ if (!solv->bestupdatemap.size)
+ map_grow(&solv->bestupdatemap, installed->end - installed->start);
+ MAPSET(&solv->bestupdatemap, pi - installed->start);
+ }
+ if (ps->repo == installed && (how & SOLVER_CLEANDEPS) != 0)
+ add_cleandeps_package(solv, pi);
+ if (!targeted && ps->repo != installed)
+ MAPSET(&solv->dupmap, pi);
+ }
+ if (s->repo == installed && solv->obsoletes && solv->obsoletes[p - installed->start])
+ {
+ Id *opp;
+ for (opp = solv->obsoletes_data + solv->obsoletes[p - installed->start]; (pi = *opp++) != 0;)
+ {
+ ps = pool->solvables + pi;
+ if (ps->repo == installed)
+ continue;
+ MAPSET(&solv->dupinvolvedmap, pi);
+ if (!targeted)
+ MAPSET(&solv->dupmap, pi);
+ }
+ }
+ if (targeted && s->repo != installed && s->obsoletes)
+ {
+ /* XXX: check obsoletes/provides combination */
+ obsp = s->repo->idarraydata + s->obsoletes;
+ while ((obs = *obsp++) != 0)
+ {
+ FOR_PROVIDES(pi, pip, obs)
+ {
+ Solvable *ps = pool->solvables + pi;
+ if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps, obs))
+ continue;
+ if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
+ continue;
+ MAPSET(&solv->dupinvolvedmap, pi);
+ if (targeted && ps->repo == installed && solv->obsoletes && solv->obsoletes[pi - installed->start])
+ {
+ Id *opp, pi2;
+ for (opp = solv->obsoletes_data + solv->obsoletes[pi - installed->start]; (pi2 = *opp++) != 0;)
+ if (pool->solvables[pi2].repo != installed)
+ MAPSET(&solv->dupinvolvedmap, pi2);
+ }
+ if (ps->repo == installed && (how & SOLVER_FORCEBEST) != 0)
+ {
+ if (!solv->bestupdatemap.size)
+ map_grow(&solv->bestupdatemap, installed->end - installed->start);
+ MAPSET(&solv->bestupdatemap, pi - installed->start);
+ }
+ if (ps->repo == installed && (how & SOLVER_CLEANDEPS) != 0)
+ add_cleandeps_package(solv, pi);
+ }
+ }
+ }
+}
+
void
solver_createdupmaps(Solver *solv)
{
Queue *job = &solv->job;
Pool *pool = solv->pool;
- Repo *repo;
- Id select, how, what, p, pi, pp, pip, obs, *obsp;
- Solvable *s, *ps;
- int i;
+ Repo *installed = solv->installed;
+ Id select, how, what, p, pp;
+ Solvable *s;
+ int i, targeted;
map_init(&solv->dupmap, pool->nsolvables);
map_init(&solv->dupinvolvedmap, pool->nsolvables);
switch (how & SOLVER_JOBMASK)
{
case SOLVER_DISTUPGRADE:
- if (select != SOLVER_SOLVABLE_REPO)
+ if (select == SOLVER_SOLVABLE_REPO)
{
- int haveinstalled;
- p = 0;
- if (solv->installed)
+ Repo *repo;
+ if (what <= 0 || what > pool->nrepos)
+ break;
+ repo = pool_id2repo(pool, what);
+ if (!repo)
+ break;
+ if (repo != installed && !(how & SOLVER_TARGETED) && solv->noautotarget)
+ break;
+ targeted = repo != installed || (how & SOLVER_TARGETED) != 0;
+ FOR_REPO_SOLVABLES(repo, p, s)
+ {
+ if (repo != installed && !pool_installable(pool, s))
+ continue;
+ solver_addtodupmaps(solv, p, how, targeted);
+ }
+ }
+ else
+ {
+ targeted = how & SOLVER_TARGETED ? 1 : 0;
+ if (installed && !targeted && !solv->noautotarget)
{
FOR_JOB_SELECT(p, pp, select, what)
- if (pool->solvables[p].repo == solv->installed)
+ if (pool->solvables[p].repo == installed)
break;
+ targeted = p == 0;
}
- haveinstalled = p != 0;
+ else if (!installed && !solv->noautotarget)
+ targeted = 1;
FOR_JOB_SELECT(p, pp, select, what)
{
Solvable *s = pool->solvables + p;
if (!s->repo)
continue;
- if (haveinstalled && s->repo != solv->installed)
+ if (s->repo != installed && !targeted)
continue;
- if (s->repo != solv->installed && !pool_installable(pool, s))
- continue;
- MAPSET(&solv->dupinvolvedmap, p);
- if (!haveinstalled)
- MAPSET(&solv->dupmap, p);
- FOR_PROVIDES(pi, pip, s->name)
- {
- ps = pool->solvables + pi;
- if (ps->name != s->name)
- continue;
- MAPSET(&solv->dupinvolvedmap, pi);
- if (haveinstalled && ps->repo != solv->installed)
- MAPSET(&solv->dupmap, pi);
- }
- if (haveinstalled)
- {
- if (solv->obsoletes && solv->obsoletes[p - solv->installed->start])
- {
- Id *opp;
- for (opp = solv->obsoletes_data + solv->obsoletes[p - solv->installed->start]; (pi = *opp++) != 0;)
- {
- ps = pool->solvables + pi;
- if (ps->repo == solv->installed)
- continue;
- MAPSET(&solv->dupinvolvedmap, pi);
- MAPSET(&solv->dupmap, pi);
- }
- }
- }
- else if (s->obsoletes)
- {
- /* XXX: check obsoletes/provides combination */
- obsp = s->repo->idarraydata + s->obsoletes;
- while ((obs = *obsp++) != 0)
- {
- FOR_PROVIDES(pi, pp, obs)
- {
- Solvable *pis = pool->solvables + pi;
- if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, pis, obs))
- continue;
- if (pool->obsoleteusescolors && !pool_colormatch(pool, s, pis))
- continue;
- MAPSET(&solv->dupinvolvedmap, pi);
- }
- }
- }
- }
- break;
- }
- if (what <= 0 || what > pool->nrepos)
- break;
- repo = pool_id2repo(pool, what);
- FOR_REPO_SOLVABLES(repo, p, s)
- {
- if (repo != solv->installed && !pool_installable(pool, s))
- continue;
- MAPSET(&solv->dupmap, p);
- FOR_PROVIDES(pi, pip, s->name)
- {
- ps = pool->solvables + pi;
- if (ps->name != s->name)
+ if (s->repo != installed && !pool_installable(pool, s))
continue;
- MAPSET(&solv->dupinvolvedmap, pi);
- }
- if (s->obsoletes)
- {
- /* XXX: check obsoletes/provides combination */
- obsp = s->repo->idarraydata + s->obsoletes;
- while ((obs = *obsp++) != 0)
- {
- FOR_PROVIDES(pi, pp, obs)
- {
- Solvable *pis = pool->solvables + pi;
- if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, pis, obs))
- continue;
- if (pool->obsoleteusescolors && !pool_colormatch(pool, s, pis))
- continue;
- MAPSET(&solv->dupinvolvedmap, pi);
- }
- }
+ solver_addtodupmaps(solv, p, how, targeted);
}
}
break;
}
if (!ip)
solver_addrule(solv, -p, 0); /* no match, sorry */
+ else
+ MAPSET(&solv->dupmap, p); /* for best rules processing */
}
}
else if (!MAPTST(&solv->dupmap, p))
solver_reenablepolicyrules(Solver *solv, int jobidx)
{
Queue *job = &solv->job;
- int i, j;
+ int i, j, k, ai;
Queue q, allq;
Rule *r;
Id lastjob = -1;
- Id qbuf[32], allqbuf[128];
+ Id qbuf[32], allqbuf[32];
queue_init_buffer(&q, qbuf, sizeof(qbuf)/sizeof(*qbuf));
- queue_init_buffer(&allq, allqbuf, sizeof(allqbuf)/sizeof(*allqbuf));
jobtodisablelist(solv, job->elements[jobidx - 1], job->elements[jobidx], &q);
if (!q.count)
- return;
+ {
+ queue_free(&q);
+ return;
+ }
+ /* now remove everything from q that is disabled by other jobs */
+
+ /* first remove cleandeps packages, they count as DISABLE_UPDATE */
+ if (solv->cleandepsmap.size)
+ {
+ solver_createcleandepsmap(solv, &solv->cleandepsmap, 0);
+ for (j = k = 0; j < q.count; j += 2)
+ {
+ if (q.elements[j] == DISABLE_UPDATE)
+ {
+ Id p = q.elements[j + 1];
+ if (p >= solv->installed->start && p < solv->installed->end && MAPTST(&solv->cleandepsmap, p - solv->installed->start))
+ continue; /* remove element from q */
+ }
+ q.elements[k++] = q.elements[j];
+ q.elements[k++] = q.elements[j + 1];
+ }
+ q.count = k;
+ if (!q.count)
+ {
+ queue_free(&q);
+ return;
+ }
+ }
+
+ /* now go through the disable list of all other jobs */
+ queue_init_buffer(&allq, allqbuf, sizeof(allqbuf)/sizeof(*allqbuf));
for (i = solv->jobrules; i < solv->jobrules_end; i++)
{
r = solv->rules + i;
continue;
lastjob = j;
jobtodisablelist(solv, job->elements[j], job->elements[j + 1], &allq);
+ if (!allq.count)
+ continue;
+ /* remove all elements in allq from q */
+ for (j = k = 0; j < q.count; j += 2)
+ {
+ Id type = q.elements[j], arg = q.elements[j + 1];
+ for (ai = 0; ai < allq.count; ai += 2)
+ if (allq.elements[ai] == type && allq.elements[ai + 1] == arg)
+ break;
+ if (ai < allq.count)
+ continue; /* found it in allq, remove element from q */
+ q.elements[k++] = q.elements[j];
+ q.elements[k++] = q.elements[j + 1];
+ }
+ q.count = k;
+ if (!q.count)
+ {
+ queue_free(&q);
+ queue_free(&allq);
+ return;
+ }
+ queue_empty(&allq);
}
- if (solv->cleandepsmap.size)
- {
- solver_createcleandepsmap(solv, &solv->cleandepsmap, 0);
- for (i = solv->installed->start; i < solv->installed->end; i++)
- if (MAPTST(&solv->cleandepsmap, i - solv->installed->start))
- queue_push2(&allq, DISABLE_UPDATE, i);
- }
+ queue_free(&allq);
+
+ /* now re-enable anything that's left in q */
for (j = 0; j < q.count; j += 2)
{
Id type = q.elements[j], arg = q.elements[j + 1];
- for (i = 0; i < allq.count; i += 2)
- if (allq.elements[i] == type && allq.elements[i + 1] == arg)
- break;
- if (i < allq.count)
- continue; /* still disabled */
switch(type)
{
case DISABLE_UPDATE:
break;
}
}
- queue_free(&allq);
queue_free(&q);
}
*depp = solv->job.elements[jidx + 1];
if ((r->d == 0 || r->d == -1) && r->w2 == 0 && r->p == -SYSTEMSOLVABLE)
{
- if ((solv->job.elements[jidx] & SOLVER_SELECTMASK) == SOLVER_SOLVABLE_NAME)
+ if ((solv->job.elements[jidx] & (SOLVER_JOBMASK|SOLVER_SELECTMASK)) == (SOLVER_INSTALL|SOLVER_SOLVABLE_NAME))
return SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
- if ((solv->job.elements[jidx] & SOLVER_SELECTMASK) == SOLVER_SOLVABLE_PROVIDES)
+ if ((solv->job.elements[jidx] & (SOLVER_JOBMASK|SOLVER_SELECTMASK)) == (SOLVER_INSTALL|SOLVER_SOLVABLE_PROVIDES))
return SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
+ if ((solv->job.elements[jidx] & (SOLVER_JOBMASK|SOLVER_SELECTMASK)) == (SOLVER_ERASE|SOLVER_SOLVABLE_NAME))
+ return SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM;
+ if ((solv->job.elements[jidx] & (SOLVER_JOBMASK|SOLVER_SELECTMASK)) == (SOLVER_ERASE|SOLVER_SOLVABLE_PROVIDES))
+ return SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM;
}
return SOLVER_RULE_JOB;
}
*depp = pool->solvables[-r->p].name;
return SOLVER_RULE_INFARCH;
}
+ if (rid >= solv->bestrules && rid < solv->bestrules_end)
+ {
+ return SOLVER_RULE_BEST;
+ }
if (rid >= solv->choicerules && rid < solv->choicerules_end)
{
return SOLVER_RULE_CHOICE;
return SOLVER_RULE_DISTUPGRADE;
if (rid >= solv->infarchrules && rid < solv->infarchrules_end)
return SOLVER_RULE_INFARCH;
+ if (rid >= solv->bestrules && rid < solv->bestrules_end)
+ return SOLVER_RULE_BEST;
if (rid >= solv->choicerules && rid < solv->choicerules_end)
return SOLVER_RULE_CHOICE;
if (rid >= solv->learntrules)
solver_ruleliterals(Solver *solv, Id rid, Queue *q)
{
Pool *pool = solv->pool;
- Id p, *pp;
+ Id p, pp;
Rule *r;
queue_empty(q);
Rule *r;
Queue q, qi;
int i, j, rid, havechoice;
- Id p, d, *pp;
+ Id p, d, pp;
Id p2, pp2;
Solvable *s, *s2;
+ Id lastaddedp, lastaddedd;
+ int lastaddedcnt;
solv->choicerules = solv->nrules;
if (!pool->installed)
for (rid = solv->duprules, r = solv->rules + rid; rid < solv->duprules_end; rid++, r++)
if (r->p < 0 && !r->w2 && (r->d == 0 || r->d == -1))
MAPSET(&mneg, -r->p);
+ lastaddedp = 0;
+ lastaddedd = 0;
+ lastaddedcnt = 0;
for (rid = 1; rid < solv->rpmrules_end ; rid++)
{
r = solv->rules + rid;
#endif
continue;
}
+
+ /* don't add identical rules */
+ if (lastaddedp == r->p && lastaddedcnt == q.count)
+ {
+ for (i = 0; i < q.count; i++)
+ if (q.elements[i] != pool->whatprovidesdata[lastaddedd + i])
+ break;
+ if (i == q.count)
+ continue; /* already added that one */
+ }
d = q.count ? pool_queuetowhatprovides(pool, &q) : 0;
+
+ lastaddedp = r->p;
+ lastaddedd = d;
+ lastaddedcnt = q.count;
+
solver_addrule(solv, r->p, d);
queue_push(&solv->weakruleq, solv->nrules - 1);
solv->choicerules_ref[solv->nrules - 1 - solv->choicerules] = rid;
void
solver_disablechoicerules(Solver *solv, Rule *r)
{
- Id rid, p, *pp;
+ Id rid, p, pp;
Pool *pool = solv->pool;
Map m;
Rule *or;
}
}
+static void
+prune_to_update_targets(Solver *solv, Id *cp, Queue *q)
+{
+ int i, j;
+ Id p, *cp2;
+ for (i = j = 0; i < q->count; i++)
+ {
+ p = q->elements[i];
+ for (cp2 = cp; *cp2; cp2++)
+ if (*cp2 == p)
+ {
+ q->elements[j++] = p;
+ break;
+ }
+ }
+ queue_truncate(q, j);
+}
+
+static void
+prune_to_dup_packages(Solver *solv, Id p, Queue *q)
+{
+ int i, j;
+ for (i = j = 0; i < q->count; i++)
+ {
+ Id p = q->elements[i];
+ if (MAPTST(&solv->dupmap, p))
+ q->elements[j++] = p;
+ }
+ queue_truncate(q, j);
+}
+
+void
+solver_addbestrules(Solver *solv, int havebestinstalljobs)
+{
+ Pool *pool = solv->pool;
+ Id p;
+ Solvable *s;
+ Repo *installed = solv->installed;
+ Queue q, q2;
+ Rule *r;
+ Queue r2pkg;
+ int i, oldcnt;
+
+ solv->bestrules = solv->nrules;
+ if (!installed)
+ {
+ solv->bestrules_end = solv->nrules;
+ return;
+ }
+ queue_init(&q);
+ queue_init(&q2);
+ queue_init(&r2pkg);
+
+ if (havebestinstalljobs)
+ {
+ for (i = 0; i < solv->job.count; i += 2)
+ {
+ if ((solv->job.elements[i] & (SOLVER_JOBMASK | SOLVER_FORCEBEST)) == (SOLVER_INSTALL | SOLVER_FORCEBEST))
+ {
+ int j;
+ Id p2, pp2;
+ for (j = 0; j < solv->ruletojob.count; j++)
+ if (solv->ruletojob.elements[j] == i)
+ break;
+ if (j == solv->ruletojob.count)
+ continue;
+ r = solv->rules + solv->jobrules + j;
+ queue_empty(&q);
+ FOR_RULELITERALS(p2, pp2, r)
+ if (p2 > 0)
+ queue_push(&q, p2);
+ if (!q.count)
+ continue; /* orphaned */
+ /* select best packages, just look at prio and version */
+ oldcnt = q.count;
+ policy_filter_unwanted(solv, &q, POLICY_MODE_RECOMMEND);
+ if (q.count == oldcnt)
+ continue; /* nothing filtered */
+ p2 = queue_shift(&q);
+ solver_addrule(solv, p2, q.count ? pool_queuetowhatprovides(pool, &q) : 0);
+ queue_push(&r2pkg, -(solv->jobrules + j));
+ }
+ }
+ }
+
+ if (solv->bestupdatemap_all || solv->bestupdatemap.size)
+ {
+ FOR_REPO_SOLVABLES(installed, p, s)
+ {
+ Id d, p2, pp2;
+ if (!solv->updatemap_all && (!solv->updatemap.size || !MAPTST(&solv->updatemap, p - installed->start)))
+ continue;
+ if (!solv->bestupdatemap_all && (!solv->bestupdatemap.size || !MAPTST(&solv->bestupdatemap, p - installed->start)))
+ continue;
+ queue_empty(&q);
+ if (solv->bestobeypolicy)
+ r = solv->rules + solv->updaterules + (p - installed->start);
+ else
+ {
+ r = solv->rules + solv->featurerules + (p - installed->start);
+ if (!r->p) /* identical to update rule? */
+ r = solv->rules + solv->updaterules + (p - installed->start);
+ }
+ if (solv->multiversionupdaters && (d = solv->multiversionupdaters[p - installed->start]) != 0 && r == solv->rules + solv->updaterules + (p - installed->start))
+ {
+ /* need to check multiversionupdaters */
+ if (r->p == p) /* be careful with the dup case */
+ queue_push(&q, p);
+ while ((p2 = pool->whatprovidesdata[d++]) != 0)
+ queue_push(&q, p2);
+ }
+ else
+ {
+ FOR_RULELITERALS(p2, pp2, r)
+ if (p2 > 0)
+ queue_push(&q, p2);
+ }
+ if (solv->update_targets && solv->update_targets->elements[p - installed->start])
+ prune_to_update_targets(solv, solv->update_targets->elements + solv->update_targets->elements[p - installed->start], &q);
+ if (solv->dupinvolvedmap.size && MAPTST(&solv->dupinvolvedmap, p))
+ prune_to_dup_packages(solv, p, &q);
+ /* select best packages, just look at prio and version */
+ policy_filter_unwanted(solv, &q, POLICY_MODE_RECOMMEND);
+ if (!q.count)
+ continue; /* orphaned */
+ if (solv->bestobeypolicy)
+ {
+ /* also filter the best of the feature rule packages and add them */
+ r = solv->rules + solv->featurerules + (p - installed->start);
+ if (r->p)
+ {
+ int j;
+ queue_empty(&q2);
+ FOR_RULELITERALS(p2, pp2, r)
+ if (p2 > 0)
+ queue_push(&q2, p2);
+ if (solv->update_targets && solv->update_targets->elements[p - installed->start])
+ prune_to_update_targets(solv, solv->update_targets->elements + solv->update_targets->elements[p - installed->start], &q2);
+ if (solv->dupinvolvedmap.size && MAPTST(&solv->dupinvolvedmap, p))
+ prune_to_dup_packages(solv, p, &q);
+ policy_filter_unwanted(solv, &q2, POLICY_MODE_RECOMMEND);
+ for (j = 0; j < q2.count; j++)
+ queue_pushunique(&q, q2.elements[j]);
+ }
+ }
+ p2 = queue_shift(&q);
+ solver_addrule(solv, p2, q.count ? pool_queuetowhatprovides(pool, &q) : 0);
+ queue_push(&r2pkg, p);
+ }
+ }
+ if (r2pkg.count)
+ {
+ solv->bestrules_pkg = solv_calloc(r2pkg.count, sizeof(Id));
+ memcpy(solv->bestrules_pkg, r2pkg.elements, r2pkg.count * sizeof(Id));
+ }
+ solv->bestrules_end = solv->nrules;
+ queue_free(&q);
+ queue_free(&q2);
+ queue_free(&r2pkg);
+}
+
#undef CLEANDEPSDEBUG
/*
queue_push(q, p);
}
+static int
+check_xsupp(Solver *solv, Queue *depq, Id dep)
+{
+ Pool *pool = solv->pool;
+ Id p, pp;
+
+ if (ISRELDEP(dep))
+ {
+ Reldep *rd = GETRELDEP(pool, dep);
+ if (rd->flags >= 8)
+ {
+ if (rd->flags == REL_AND)
+ {
+ if (!check_xsupp(solv, depq, rd->name))
+ return 0;
+ return check_xsupp(solv, depq, rd->evr);
+ }
+ if (rd->flags == REL_OR)
+ {
+ if (check_xsupp(solv, depq, rd->name))
+ return 1;
+ return check_xsupp(solv, depq, rd->evr);
+ }
+ if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
+ return solver_splitprovides(solv, rd->evr);
+ if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_INSTALLED)
+ return solver_dep_installed(solv, rd->evr);
+ }
+ if (depq && rd->flags == REL_NAMESPACE)
+ {
+ int i;
+ for (i = 0; i < depq->count; i++)
+ if (depq->elements[i] == dep || depq->elements[i] == rd->name)
+ return 1;
+ }
+ }
+ FOR_PROVIDES(p, pp, dep)
+ if (p == SYSTEMSOLVABLE || pool->solvables[p].repo == solv->installed)
+ return 1;
+ return 0;
+}
+
+static inline int
+queue_contains(Queue *q, Id id)
+{
+ int i;
+ for (i = 0; i < q->count; i++)
+ if (q->elements[i] == id)
+ return 1;
+ return 0;
+}
+
+
/*
* Find all installed packages that are no longer
* needed regarding the current solver job.
Map installedm;
Rule *r;
Id rid, how, what, select;
- Id p, pp, ip, *jp;
+ Id p, pp, ip, jp;
Id req, *reqp, sup, *supp;
Solvable *s;
- Queue iq;
+ Queue iq, iqcopy, xsuppq;
int i;
map_empty(cleandepsmap);
map_init(&im, pool->nsolvables);
map_init(&installedm, pool->nsolvables);
queue_init(&iq);
+ queue_init(&xsuppq);
for (i = 0; i < job->count; i += 2)
{
if (pool->solvables[p].repo == installed)
MAPSET(&userinstalled, p - installed->start);
}
+ if ((how & (SOLVER_JOBMASK | SOLVER_SELECTMASK)) == (SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES))
+ {
+ what = job->elements[i + 1];
+ if (ISRELDEP(what))
+ {
+ Reldep *rd = GETRELDEP(pool, what);
+ if (rd->flags != REL_NAMESPACE)
+ continue;
+ if (rd->evr == 0)
+ {
+ queue_pushunique(&iq, rd->name);
+ continue;
+ }
+ FOR_PROVIDES(p, pp, what)
+ if (p)
+ break;
+ if (p)
+ continue;
+ queue_pushunique(&iq, what);
+ }
+ }
+ }
+
+ /* have special namespace cleandeps erases */
+ if (iq.count)
+ {
+ for (ip = solv->installed->start; ip < solv->installed->end; ip++)
+ {
+ s = pool->solvables + ip;
+ if (s->repo != installed)
+ continue;
+ if (!s->supplements)
+ continue;
+ supp = s->repo->idarraydata + s->supplements;
+ while ((sup = *supp++) != 0)
+ if (check_xsupp(solv, &iq, sup) && !check_xsupp(solv, 0, sup))
+ {
+#ifdef CLEANDEPSDEBUG
+ printf("xsupp %s from %s\n", pool_dep2str(pool, sup), pool_solvid2str(pool, ip));
+#endif
+ queue_pushunique(&xsuppq, sup);
+ }
+ }
+ queue_empty(&iq);
}
/* also add visible patterns to userinstalled for openSUSE */
if (di.solvid <= 0)
continue;
s = pool->solvables + di.solvid;
- if (!s->requires)
+ if (!s->repo || !s->requires)
continue;
- if (!pool_installable(pool, s))
+ if (s->repo != installed && !pool_installable(pool, s))
continue;
if (strncmp(pool_id2str(pool, s->name), "pattern:", 8) != 0)
continue;
for (rid = solv->jobrules; rid < solv->jobrules_end; rid++)
{
r = solv->rules + rid;
- if (r->d < 0)
+ if (r->d < 0) /* disabled? */
continue;
- if (r->d == 0 && r->p < 0 && r->w2 == 0)
+ if (r->d == 0 && r->p < 0 && r->w2 == 0) /* negative assertion (erase job)? */
{
p = -r->p;
if (pool->solvables[p].repo != installed)
if ((how & (SOLVER_JOBMASK|SOLVER_CLEANDEPS)) == (SOLVER_ERASE|SOLVER_CLEANDEPS))
queue_push(&iq, p);
}
- else if (r->p > 0)
+ else if (r->p > 0) /* install job */
{
if (unneeded)
continue;
}
}
}
+ queue_init_clone(&iqcopy, &iq);
if (!unneeded)
{
continue;
MAPSET(&im, p);
}
+ MAPSET(&installedm, SYSTEMSOLVABLE);
+ MAPSET(&im, SYSTEMSOLVABLE);
#ifdef CLEANDEPSDEBUG
printf("REMOVE PASS\n");
if (unneeded)
break;
/* supplements pass */
- for (ip = solv->installed->start; ip < solv->installed->end; ip++)
+ for (ip = installed->start; ip < installed->end; ip++)
{
if (!MAPTST(&installedm, ip))
continue;
{
supp = s->repo->idarraydata + s->supplements;
while ((sup = *supp++) != 0)
- if (dep_possible(solv, sup, &installedm))
+ if (dep_possible(solv, sup, &installedm) || (xsuppq.count && queue_contains(&xsuppq, sup)))
{
/* no longer supplemented, also erase */
int iqcount = iq.count;
}
queue_truncate(&iq, iqcount);
#ifdef CLEANDEPSDEBUG
- printf("%s supplemented\n", pool_solvid2str(pool, ip));
+ printf("%s supplemented [%s]\n", pool_solvid2str(pool, ip), pool_dep2str(pool, sup));
#endif
queue_push(&iq, ip);
}
}
}
if (!iq.count)
- break;
+ break; /* no supplementing package found, we're done */
}
ip = queue_shift(&iq);
s = pool->solvables + ip;
#endif
FOR_PROVIDES(p, pp, req)
{
- if (MAPTST(&im, p))
+ if (p != SYSTEMSOLVABLE && MAPTST(&im, p))
{
#ifdef CLEANDEPSDEBUG
printf("%s requires %s\n", pool_solvid2str(pool, ip), pool_solvid2str(pool, p));
#endif
FOR_PROVIDES(p, pp, req)
{
- if (MAPTST(&im, p))
+ if (p != SYSTEMSOLVABLE && MAPTST(&im, p))
{
#ifdef CLEANDEPSDEBUG
printf("%s recommends %s\n", pool_solvid2str(pool, ip), pool_solvid2str(pool, p));
if (pool->solvables[p].repo == installed)
MAPSET(&userinstalled, p - installed->start);
}
+ MAPSET(&im, SYSTEMSOLVABLE); /* in case we cleared it above */
for (p = installed->start; p < installed->end; p++)
if (MAPTST(&im, p))
queue_push(&iq, p);
while ((req = *reqp++) != 0)
{
FOR_PROVIDES(p, pp, req)
+ if (MAPTST(&im, p))
+ break;
+ if (p)
+ continue;
+ FOR_PROVIDES(p, pp, req)
{
if (!MAPTST(&im, p) && MAPTST(&installedm, p))
{
while ((req = *reqp++) != 0)
{
FOR_PROVIDES(p, pp, req)
+ if (MAPTST(&im, p))
+ break;
+ if (p)
+ continue;
+ FOR_PROVIDES(p, pp, req)
{
if (!MAPTST(&im, p) && MAPTST(&installedm, p))
{
}
queue_free(&iq);
+ /* make sure the updatepkgs and mistakes are not in the cleandeps map */
if (solv->cleandeps_updatepkgs)
for (i = 0; i < solv->cleandeps_updatepkgs->count; i++)
MAPSET(&im, solv->cleandeps_updatepkgs->elements[i]);
if (solv->cleandeps_mistakes)
for (i = 0; i < solv->cleandeps_mistakes->count; i++)
MAPSET(&im, solv->cleandeps_mistakes->elements[i]);
+ /* also remove original iq packages */
+ for (i = 0; i < iqcopy.count; i++)
+ MAPSET(&im, iqcopy.elements[i]);
+ queue_free(&iqcopy);
for (p = installed->start; p < installed->end; p++)
{
if (pool->solvables[p].repo != installed)
map_free(&im);
map_free(&installedm);
map_free(&userinstalled);
+ queue_free(&xsuppq);
+#ifdef CLEANDEPSDEBUG
+ printf("=== final cleandeps map:\n");
+ for (p = installed->start; p < installed->end; p++)
+ if (MAPTST(cleandepsmap, p - installed->start))
+ printf(" - %s\n", pool_solvid2str(pool, p));
+#endif
}