[yum-git] 2 commits - yum/depsolve.py yum/__init__.py
James Antill
james at linux.duke.edu
Mon Feb 25 23:02:20 UTC 2008
yum/__init__.py | 27 ++++++---------------------
yum/depsolve.py | 42 +++++++++++++++++++++++++++++++++++-------
2 files changed, 41 insertions(+), 28 deletions(-)
New commits:
commit c01b4f4ae75c2a1c512e4ee05523e164484d5fdd
Author: James Antill <james at and.org>
Date: Mon Feb 25 17:23:59 2008 -0500
Do _var substitution for repos in the main yum.conf file.
Do repo name checking for repos in the main yum.conf file.
Don't allow repos called "main" even in yum.repos.d/*.repo files.
diff --git a/yum/__init__.py b/yum/__init__.py
index a842076..e40ca9d 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -219,6 +219,9 @@ class YumBase(depsolve.Depsolve):
# Check sections in the .repo file that was just slurped up
for section in parser.sections():
+ if section == 'main':
+ continue
+
# Check the repo.id against the valid chars
bad = None
for byte in section:
@@ -259,31 +262,13 @@ class YumBase(depsolve.Depsolve):
def getReposFromConfig(self):
"""read in repositories from config main and .repo files"""
- #FIXME this method could be a simpler
-
- # Check yum.conf for repositories
- for section in self.conf.cfg.sections():
- # All sections except [main] are repositories
- if section == 'main':
- continue
-
- try:
- thisrepo = self.readRepoConfig(self.conf.cfg, section)
- except (Errors.RepoError, Errors.ConfigError), e:
- self.logger.warning(e)
- else:
- thisrepo.repo_config_age = self.conf.config_file_age
- thisrepo.repofile = self.conf.config_file_path
-
- try:
- self._repos.add(thisrepo)
- except Errors.RepoError, e:
- self.logger.warning(e)
-
# Read .repo files from directories specified by the reposdir option
# (typically /etc/yum/repos.d)
repo_config_age = self.conf.config_file_age
+ # Get the repos from the main yum.conf file
+ self.getReposFromConfigFile(self.conf.config_file_path, repo_config_age)
+
for reposdir in self.conf.reposdir:
if os.path.exists(self.conf.installroot+'/'+reposdir):
reposdir = self.conf.installroot + '/' + reposdir
commit 598f36ebcd8da6498317b30929238b65a6db623e
Author: James Antill <james at and.org>
Date: Fri Feb 22 15:41:57 2008 -0500
Add sourcerpm and common prefix length into deciding best pkg, solves
installing totem-debuginfo giving you xmms-lirc instead of totem-lirc as a dep.
diff --git a/yum/depsolve.py b/yum/depsolve.py
index 6efe242..714f041 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -489,7 +489,6 @@ class Depsolve(object):
# find out which arch of the ones we can choose from is closest
# to the arch of the requesting pkg
- thisarch = requiringPo.arch
newest = provSack.returnNewestByNameArch()
if len(newest) > 1: # there's no way this can be zero
@@ -504,7 +503,7 @@ class Depsolve(object):
break
loop_run += 1
old_best = best
- best = self._compare_providers(newest, best, thisarch)
+ best = self._compare_providers(newest, best, requiringPo)
elif len(newest) == 1:
@@ -911,7 +910,20 @@ class Depsolve(object):
return installed
_isPackageInstalled = isPackageInstalled
- def _compare_providers(self, pkgs, bestpkg, requiring_arch):
+ def _compare_providers(self, pkgs, bestpkg, reqpo):
+
+ def _common_prefix_len(x, y, minlen=2):
+ num = min(len(x), len(y))
+ for off in range(num):
+ if x[off] != y[off]:
+ return max(off, minlen)
+ return max(num, minlen)
+ def _common_sourcerpm(x, y):
+ if not hasattr(x, 'sourcerpm'):
+ return False
+ if not hasattr(y, 'sourcerpm'):
+ return False
+ return x.sourcerpm == y.sourcerpm
for po in pkgs:
if po == bestpkg: # if we're comparing the same one, skip it
@@ -930,21 +942,37 @@ class Depsolve(object):
if po.inPrcoRange('provides', obs):
return bestpkg
- if requiring_arch != 'noarch':
- best_dist = archDifference(requiring_arch, bestpkg.arch)
+ if reqpo.arch != 'noarch':
+ best_dist = archDifference(reqpo.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)
+ po_dist = archDifference(reqpo.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):
+ if (not _common_sourcerpm(reqpo, bestpkg) and
+ _common_sourcerpm(reqpo, po)):
+ return po
+ cplp = _common_prefix_len(reqpo.name, po.name)
+ cplb = _common_prefix_len(reqpo.name, bestpkg.name)
+ if cplp > cplb:
+ return po
+ if cplp == cplb and len(po.name) < len(bestpkg.name):
return po
+ elif (not _common_sourcerpm(reqpo, bestpkg) and
+ _common_sourcerpm(reqpo, po)):
+ return po
+ elif (_common_prefix_len(reqpo.name, po.name) >
+ _common_prefix_len(reqpo.name, bestpkg.name)):
+ return po
+ elif (_common_prefix_len(reqpo.name, po.name) <
+ _common_prefix_len(reqpo.name, bestpkg.name)):
+ return bestpkg
elif len(po.name) < len(bestpkg.name):
return po
elif len(po.name) == len(bestpkg.name):
More information about the Yum-cvs-commits
mailing list