Blame SOURCES/BZ-1186690-compare_providers_priorities.patch

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