[yum-git] yum/depsolve.py yum/packages.py
Seth Vidal
skvidal at linux.duke.edu
Fri Feb 22 17:49:40 UTC 2008
yum/depsolve.py | 79 ++++++++++++++++++++++++++++++++++++++------------------
yum/packages.py | 2 +
2 files changed, 57 insertions(+), 24 deletions(-)
New commits:
commit fa4f1062a7b31a4b88701b8d9a1af2b28a5022a0
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Fri Feb 22 12:45:09 2008 -0500
depsolve: make sure our providers are obsolete-checked against one another
packages: if the the compared package is None then it is clear that these packages are NOT EQUAL - return true
diff --git a/yum/depsolve.py b/yum/depsolve.py
index ad47a1d..fb2a919 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -492,32 +492,21 @@ class Depsolve(object):
thisarch = requiringPo.arch
newest = provSack.returnNewestByNameArch()
if len(newest) > 1: # there's no way this can be zero
+
best = newest[0]
- for po in newest[1:]:
- if thisarch != 'noarch':
- best_dist = archDifference(thisarch, best.arch)
- if isMultiLibArch(): # only go to the next one if we're multilib - i686 can satisfy i386 deps
- if best_dist == 0: # can't really use best's arch anyway...
- best = po # just try the next one - can't be much worse
- continue
+ old_best = None
+ loop_run = 0
+ while best != old_best:
+ if loop_run >= len(newest)*2:
+ msg = _('Failure finding best provider of %s for %s, exceeded maximum loop length' % (needname, requiringPo))
+ errorlist.append(msg)
+ self.verbose_logger.debug(msg)
+ break
+ loop_run += 1
+ old_best = best
+ best = self._compare_providers(newest, best, thisarch)
+
- po_dist = archDifference(thisarch, po.arch)
- if po_dist > 0 and best_dist > po_dist:
- best = po
- continue
-
- if best_dist == po_dist:
- if len(po.name) < len(best.name):
- best=po
- continue
-
- elif len(po.name) < len(best.name):
- best = po
- elif len(po.name) == len(best.name):
- # compare arch
- arch = rpmUtils.arch.getBestArchFromList([po.arch, best.arch])
- if arch == po.arch:
- best = po
elif len(newest) == 1:
best = newest[0]
@@ -922,6 +911,48 @@ class Depsolve(object):
return installed
_isPackageInstalled = isPackageInstalled
+ def _compare_providers(self, pkgs, bestpkg, requiring_arch):
+
+ for po in pkgs:
+ if po == bestpkg: # if we're comparing the same one, skip it
+ continue
+ # if best is obsoleted by any of the packages, then the obsoleter
+ # is the new best
+ for obs in po.obsoletes:
+ if bestpkg.inPrcoRange('provides', obs):
+ return po
+
+ # make sure the best doesn't obsolete this po - if it does we're done
+ # we do this b/c it is possible for two entries to oscillate in this
+ # test - obsolete should trump no matter what
+ # NOTE: mutually obsoleting providers is completely and utterly doom
+ for obs in bestpkg.obsoletes:
+ if po.inPrcoRange('provides', obs):
+ return bestpkg
+
+ if requiring_arch != 'noarch':
+ best_dist = archDifference(requiring_arch, bestpkg.arch)
+ if isMultiLibArch(): # only go to the next one if we're multilib - i686 can satisfy i386 deps
+ if best_dist == 0: # can't really use best's arch anyway...
+ return po # just try the next one - can't be much worse
+
+
+ po_dist = archDifference(requiring_arch, po.arch)
+ if po_dist > 0 and best_dist > po_dist:
+ return po
+
+ if best_dist == po_dist:
+ if len(po.name) < len(bestpkg.name):
+ return po
+
+ elif len(po.name) < len(bestpkg.name):
+ return po
+ elif len(po.name) == len(bestpkg.name):
+ # compare arch
+ arch = rpmUtils.arch.getBestArchFromList([po.arch, bestpkg.arch])
+ if arch == po.arch:
+ return po
+
class DepCheck(object):
"""object that YumDepsolver uses to see what things are needed to close
diff --git a/yum/packages.py b/yum/packages.py
index 2a650f0..48fd524 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -247,6 +247,8 @@ class RpmBase(object):
return False
def __ne__(self, other):
+ if not other:
+ return True
if comparePoEVR(self, other) != 0 or self.arch != other.arch or self.name != other.name:
return True
return False
More information about the Yum-cvs-commits
mailing list