x = a->p - b->p;
if (x)
- return x; /* p differs */
+ return x; /* p differs */
/* identical p */
- if (a->d == 0 && b->d == 0)
- return a->w2 - b->w2; /* assertion: return w2 diff */
+ if (a->d == 0 && b->d == 0) /* both assertions or binary */
+ return a->w2 - b->w2;
- if (a->d == 0) /* a is assertion, b not */
+ if (a->d == 0) /* a is assertion or binary, b not */
{
x = a->w2 - pool->whatprovidesdata[b->d];
return x ? x : -1;
}
- if (b->d == 0) /* b is assertion, a not */
+ if (b->d == 0) /* b is assertion or binary, a not */
{
x = pool->whatprovidesdata[a->d] - b->w2;
return x ? x : 1;
}
+ if (a->d == b->d)
+ return 0;
+
/* compare whatprovidesdata */
ad = pool->whatprovidesdata + a->d;
bd = pool->whatprovidesdata + b->d;
int i, j;
Rule *ir, *jr;
- if (solv->nrules <= 2) /* nothing to unify */
+ if (solv->nrules <= 2) /* nothing to unify */
return;
+ if (solv->recommendsruleq)
+ {
+ /* mis-use n2 as recommends rule marker */
+ for (i = 1, ir = solv->rules + i; i < solv->nrules; i++, ir++)
+ ir->n2 = 0;
+ for (i = 0; i < solv->recommendsruleq->count; i++)
+ solv->rules[solv->recommendsruleq->elements[i]].n2 = 1;
+ }
+
/* sort rules first */
solv_sort(solv->rules + 1, solv->nrules - 1, sizeof(Rule), unifyrules_sortcmp, solv->pool);
- /* prune rules
- * i = unpruned
- * j = pruned
- */
+ /* prune rules */
jr = 0;
for (i = j = 1, ir = solv->rules + i; i < solv->nrules; i++, ir++)
{
if (jr && !unifyrules_sortcmp(ir, jr, pool))
- continue; /* prune! */
- jr = solv->rules + j++; /* keep! */
+ {
+ jr->n2 &= ir->n2; /* bitwise-and recommends marker */
+ continue; /* prune! */
+ }
+ jr = solv->rules + j++; /* keep! */
if (ir != jr)
*jr = *ir;
}
POOL_DEBUG(SOLV_DEBUG_STATS, "pruned rules from %d to %d\n", solv->nrules, j);
/* adapt rule buffer */
- solv->nrules = j;
- solv->rules = solv_extend_resize(solv->rules, solv->nrules, sizeof(Rule), RULES_BLOCK);
+ solver_shrinkrules(solv, j);
+
+ if (solv->recommendsruleq)
+ {
+ /* rebuild recommendsruleq */
+ queue_empty(solv->recommendsruleq);
+ for (i = 1, ir = solv->rules + i; i < solv->nrules; i++, ir++)
+ if (ir->n2)
+ {
+ ir->n2 = 0;
+ queue_push(solv->recommendsruleq, i);
+ }
+ }
/*
* debug: log rule statistics
* the work for unifyrules a bit easier */
if (!solv->pkgrules_end) /* we add pkg rules */
{
- r = solv->rules + solv->nrules - 1;
+ r = solv->rules + solv->lastpkgrule;
if (d)
{
Id *dp;
if (p == -p2)
return 0; /* rule is self-fulfilling */
}
+ solv->lastpkgrule = solv->nrules;
}
solv->rules = solv_extend(solv->rules, solv->nrules, 1, sizeof(Rule), RULES_BLOCK);
{
solv->nrules = nrules;
solv->rules = solv_extend_resize(solv->rules, solv->nrules, sizeof(Rule), RULES_BLOCK);
+ solv->lastpkgrule = 0;
}
/******************************************************************************
if (!dp[j])
continue;
}
+ if (type == SOLVER_RULE_PKG_RECOMMENDS && !*dp)
+ continue;
/* check if the rule contains both p and -p */
for (j = 0; dp[j] != 0; j++)
if (dp[j] == p)
break;
if (dp[j])
continue;
- addpkgrule(solv, -p, 0, dp - pool->whatprovidesdata, SOLVER_RULE_PKG_REQUIRES, dep);
+ addpkgrule(solv, -p, 0, dp - pool->whatprovidesdata, type, dep);
/* push all non-visited providers on the work queue */
if (m)
for (; *dp; dp++)
}
}
+ if (s->recommends && solv->strongrecommends)
+ {
+ int start = solv->nrules;
+ solv->lastpkgrule = 0;
+ reqp = s->repo->idarraydata + s->recommends;
+ while ((req = *reqp++) != 0) /* go through all recommends */
+ {
+#ifdef ENABLE_COMPLEX_DEPS
+ if (pool_is_complex_dep(pool, req))
+ {
+ /* we have AND/COND deps, normalize */
+ add_complex_deprules(solv, n, req, SOLVER_RULE_PKG_RECOMMENDS, dontfix, &workq, m);
+ continue;
+ }
+#endif
+ dp = pool_whatprovides_ptr(pool, req);
+ if (*dp == SYSTEMSOLVABLE || !*dp) /* always installed or not installable */
+ continue;
+ for (i = 0; dp[i] != 0; i++)
+ if (n == dp[i])
+ break;
+ if (dp[i])
+ continue; /* provided by itself, no need to add rule */
+ addpkgrule(solv, -n, 0, dp - pool->whatprovidesdata, SOLVER_RULE_PKG_RECOMMENDS, req);
+ if (m)
+ for (; *dp; dp++)
+ if (!MAPTST(m, *dp))
+ queue_push(&workq, *dp);
+ }
+ if (!solv->ruleinfoq && start < solv->nrules)
+ {
+ if (!solv->recommendsruleq)
+ {
+ solv->recommendsruleq = solv_calloc(1, sizeof(Queue));
+ queue_init(solv->recommendsruleq);
+ }
+ for (i = start; i < solv->nrules; i++)
+ queue_push(solv->recommendsruleq, i);
+ solv->lastpkgrule = 0;
+ }
+ }
+
/* that's all we check for src packages */
if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
continue;
queuep_free(&solv->suggestscplxq);
queuep_free(&solv->brokenorphanrules);
queuep_free(&solv->favorq);
+ queuep_free(&solv->recommendsruleq);
map_free(&solv->recommendsmap);
map_free(&solv->suggestsmap);
return solv->needupdateprovide;
case SOLVER_FLAG_URPM_REORDER:
return solv->urpmreorder;
+ case SOLVER_FLAG_STRONG_RECOMMENDS:
+ return solv->strongrecommends;
default:
break;
}
case SOLVER_FLAG_URPM_REORDER:
solv->urpmreorder = value;
break;
+ case SOLVER_FLAG_STRONG_RECOMMENDS:
+ solv->strongrecommends = value;
+ break;
default:
break;
}
if (solv->nrules != initialnrules)
solver_shrinkrules(solv, initialnrules);
solv->nrules = initialnrules;
+ solv->lastpkgrule = 0;
solv->pkgrules_end = 0;
if (installed)
if (solv->nrules > initialnrules)
solver_unifyrules(solv); /* remove duplicate pkg rules */
solv->pkgrules_end = solv->nrules; /* mark end of pkg rules */
+ solv->lastpkgrule = 0;
if (solv->nrules > initialnrules)
addedmap2deduceq(solv, &addedmap); /* so that we can recreate the addedmap */
POOL_DEBUG(SOLV_DEBUG_STATS, "overall rule memory used: %d K\n", solv->nrules * (int)sizeof(Rule) / 1024);
/* create weak map */
- if (solv->weakruleq.count)
+ if (solv->weakruleq.count || solv->recommendsruleq)
{
map_grow(&solv->weakrulemap, solv->nrules);
for (i = 0; i < solv->weakruleq.count; i++)
p = solv->weakruleq.elements[i];
MAPSET(&solv->weakrulemap, p);
}
+ if (solv->recommendsruleq)
+ {
+ for (i = 0; i < solv->recommendsruleq->count; i++)
+ {
+ p = solv->recommendsruleq->elements[i];
+ MAPSET(&solv->weakrulemap, p);
+ }
+ }
}
/* enable cleandepsmap creation if we have updatepkgs */
*/
Rule *rules; /* all rules */
Id nrules; /* [Offset] index of the last rule */
+ Id lastpkgrule; /* last package rule we added */
Queue ruleassertions; /* Queue of all assertion rules */
int focus_best; /* true: resolve job dependencies first */
int do_yum_obsoletes; /* true: add special yumobs rules */
int urpmreorder; /* true: do special urpm package reordering */
+ int strongrecommends; /* true: create weak rules for recommends */
Map dupmap; /* dup these packages*/
int dupmap_all; /* dup all packages */
int installedpos; /* for resolve_installed */
int do_extra_reordering; /* reorder for future installed packages */
+
+ Queue *recommendsruleq; /* pkg rules comming from recommends */
#endif /* LIBSOLV_INTERNAL */
};
#define SOLVER_FLAG_NEED_UPDATEPROVIDE 22
#define SOLVER_FLAG_URPM_REORDER 23
#define SOLVER_FLAG_FOCUS_BEST 24
+#define SOLVER_FLAG_STRONG_RECOMMENDS 25
#define GET_USERINSTALLED_NAMES (1 << 0) /* package names instead of ids */
#define GET_USERINSTALLED_INVERTED (1 << 1) /* autoinstalled */