summaryrefslogtreecommitdiff
path: root/lib/rpmal.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-06-11 17:22:59 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-06-11 17:22:59 +0300
commitaf0ea37a918690626c9385af5d22f7d007a285dd (patch)
treee6865b6688e5d109be408cb341d2fa1be4381d13 /lib/rpmal.c
parent31f0d94df1c50a7a2802c76f491620be22b9a8fa (diff)
downloadrpm-af0ea37a918690626c9385af5d22f7d007a285dd.tar.gz
rpm-af0ea37a918690626c9385af5d22f7d007a285dd.tar.bz2
rpm-af0ea37a918690626c9385af5d22f7d007a285dd.zip
Make rpmalSatisfiesDepend() smarter
- Instead of blindly picking the first match, try to pick the best provider for the dependency: for colored dependencies, try to find a provider of matching color. For non-colored dependencies, prefer providers of transaction preferred color. - This avoids creating bogus and loopy relations between 32- and 64-bit packages where they dont exist, and makes behavior with things like /sbin/ldconfig consistent by returning the preferred colored element.
Diffstat (limited to 'lib/rpmal.c')
-rw-r--r--lib/rpmal.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/lib/rpmal.c b/lib/rpmal.c
index 021261482..59d2751ad 100644
--- a/lib/rpmal.c
+++ b/lib/rpmal.c
@@ -381,12 +381,29 @@ rpmalAllSatisfiesDepend(const rpmal al, const rpmds ds)
rpmte
rpmalSatisfiesDepend(const rpmal al, const rpmds ds)
{
- rpmte * tmp = rpmalAllSatisfiesDepend(al, ds);
-
- if (tmp) {
- rpmte ret = tmp[0];
- free(tmp);
- return ret;
+ rpmte *providers = rpmalAllSatisfiesDepend(al, ds);
+ rpmte best = NULL;
+
+ if (providers) {
+ if (al->tscolor) {
+ /*
+ * For colored dependencies, try to find a matching provider.
+ * Otherwise prefer provider of ts preferred color.
+ */
+ rpm_color_t dscolor = rpmdsColor(ds);
+ for (rpmte *p = providers; *p; p++) {
+ rpm_color_t tecolor = rpmteColor(*p);
+ if (dscolor) {
+ if (dscolor == tecolor) best = *p;
+ } else if (al->prefcolor) {
+ if (al->prefcolor == tecolor) best = *p;
+ }
+ if (best) break;
+ }
+ }
+ /* if not decided by now, just pick first match */
+ if (!best) best = providers[0];
+ free(providers);
}
- return NULL;
+ return best;
}