Blame SOURCES/BZ-1186690-compare_providers_priorities.patch

d2a170
commit 9fb7032802a0f56cc85cf301478b48b3c72449e7
d2a170
Author: Valentina Mukhamedzhanova <vmukhame@redhat.com>
d2a170
Date:   Tue May 10 16:42:01 2016 +0200
d2a170
d2a170
    Add compare_providers_priority repository option.
d2a170
d2a170
diff --git a/test/testbase.py b/test/testbase.py
d2a170
index 467f8fb..73c97a1 100644
d2a170
--- a/test/testbase.py
d2a170
+++ b/test/testbase.py
d2a170
@@ -89,6 +89,7 @@ class FakeRepo(object):
d2a170
             sack = self.__fake_sack
d2a170
         self.sack = sack
d2a170
         self.cost = 1000
d2a170
+        self.compare_providers_priority = 80
d2a170
 
d2a170
     def __cmp__(self, other):
d2a170
         """ Sort base class repos. by alphanumeric on their id, also
d2a170
diff --git a/yum/config.py b/yum/config.py
d2a170
index cae914d..1ee6dd3 100644
d2a170
--- a/yum/config.py
d2a170
+++ b/yum/config.py
d2a170
@@ -1032,6 +1032,8 @@ class RepoConf(BaseConfig):
d2a170
 
d2a170
     check_config_file_age = Inherit(YumConf.check_config_file_age)
d2a170
 
d2a170
+    compare_providers_priority = IntOption(80, range_min=1, range_max=99)
d2a170
+
d2a170
     
d2a170
 class VersionGroupConf(BaseConfig):
d2a170
     """Option definitions for version groups."""
d2a170
diff --git a/yum/depsolve.py b/yum/depsolve.py
d2a170
index b482115..3453456 100644
d2a170
--- a/yum/depsolve.py
d2a170
+++ b/yum/depsolve.py
d2a170
@@ -1653,6 +1653,12 @@ class Depsolve(object):
d2a170
                         pkgresults[po] += 5
d2a170
 
d2a170
             # End of O(N*N): for nextpo in pkgs:
d2a170
+
d2a170
+            # Respect the repository priority for each provider, the default is 80
d2a170
+            pkgresults[po] += (100 - po.repo.compare_providers_priority) * 10
d2a170
+            self.verbose_logger.log(logginglevels.DEBUG_4,
d2a170
+                _('compare_providers_priority for %s is %s' % (po, po.repo.compare_providers_priority)))
d2a170
+
d2a170
             if _common_sourcerpm(po, reqpo):
d2a170
                 self.verbose_logger.log(logginglevels.DEBUG_4,
d2a170
                     _('common sourcerpm %s and %s' % (po, reqpo)))
d2a170
diff -up yum-3.4.3/docs/yum.conf.5.old yum-3.4.3/docs/yum.conf.5
d2a170
--- yum-3.4.3/docs/yum.conf.5.old	2016-05-10 17:00:13.406111903 +0200
d2a170
+++ yum-3.4.3/docs/yum.conf.5	2016-05-10 17:01:03.302427161 +0200
d2a170
@@ -1229,6 +1229,14 @@ parallel, if possible.  Defaults to True
d2a170
 Overrides the \fBui_repoid_vars\fR option from the [main] section for this
d2a170
 repository.
d2a170
 
d2a170
+.IP
d2a170
+\fBcompare_providers_priority \fR
d2a170
+During depsolving, when choosing the best provider among several, yum will respect
d2a170
+the priority of each provider's repository (note that there are other factors
d2a170
+which yum considers, which may overweigh the repository priority). The value is
d2a170
+an integer from 1 to 99, 1 being the most preferred repository, and 99 being
d2a170
+the least preferred one. By default all repositories have the priority of 80.
d2a170
+
d2a170
 .SH "URL INCLUDE SYNTAX"
d2a170
 .LP
d2a170
 The inclusion of external configuration files is supported for /etc/yum.conf