summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2014-08-15 15:10:16 +0300
committerPanu Matilainen <pmatilai@redhat.com>2014-08-18 10:00:56 +0300
commit0fe96e75d1570dd91ced92af38ef159158e71cd6 (patch)
treefa4e100a3382bfeb36d7034da039ef00cd886bd3
parentad12c08f0dcc3ace7a57eaf908dacca8db72b827 (diff)
downloadrpm-0fe96e75d1570dd91ced92af38ef159158e71cd6.tar.gz
Introduce a simple score system for determining best providers in ordering
- Look at all providers and calculate a simple score for them: We want to prefer self-provides during ordering (RhBug:1111349) but only when other things are equal, coloring needs to prevail. Otherwise ordering can miss crucial dependencies to the preferred arch packages whose files are actually laid down: eg on x86_64 Fedora, both glibc.i686 and glibc.x86_64 provide and require /sbin/ldconfig, but only installing glibc.x86_64 will actually get the file on disk for itself and others to use, so glibc.i686 cannot satisfy its own /sbin/ldconfig provide, crazy as it is. - Also fixes a memleak on self-provided dependencies introduced in commit 6b6f8e6ecba05c69e4ecfc0ef6981a920b4b0eb6 (cherry picked from commit 9b2810544cbd30f692456344ed8d8a0d7a96fc18)
-rw-r--r--lib/rpmal.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/rpmal.c b/lib/rpmal.c
index f732788c8..c66055f5a 100644
--- a/lib/rpmal.c
+++ b/lib/rpmal.c
@@ -516,27 +516,34 @@ rpmalSatisfiesDepend(const rpmal al, const rpmte te, const rpmds ds)
{
rpmte *providers = rpmalAllSatisfiesDepend(al, ds);
rpmte best = NULL;
+ int bestscore = 0;
if (providers) {
rpm_color_t dscolor = rpmdsColor(ds);
for (rpmte *p = providers; *p; p++) {
- if (*p == te) {
- /* package provides requirement itself */
- return *p;
- }
- if (al->tscolor) {
+ int score = 0;
+
/*
- * For colored dependencies, try to find a matching provider.
+ * For colored dependencies, prefer a matching colored provider.
* Otherwise prefer provider of ts preferred color.
*/
+ if (al->tscolor) {
rpm_color_t tecolor = rpmteColor(*p);
if (dscolor) {
- if (dscolor == tecolor) best = *p;
- } else if (al->prefcolor && !best) {
- /* Do not overwrite previous findings */
- if (al->prefcolor == tecolor) best = *p;
+ if (dscolor == tecolor) score += 2;
+ } else if (al->prefcolor) {
+ if (al->prefcolor == tecolor) score += 2;
}
}
+
+ /* Being self-provided is a bonus */
+ if (*p == te)
+ score += 1;
+
+ if (score > bestscore) {
+ bestscore = score;
+ best = *p;
+ }
}
/* if not decided by now, just pick first match */
if (!best) best = providers[0];