Improve --nogreedy behaviour to select only the best packages for target arch. Also exact package arch can be selected by specifying $name.$arch in the config file.

This commit is contained in:
Daniel Mach 2012-03-02 03:33:00 -05:00 committed by Dennis Gilmore
parent 80454a89b2
commit 8ccc24e106

View File

@ -325,20 +325,35 @@ class Pungi(pypungi.PungiBase):
if req in provs: if req in provs:
continue continue
deps = self.ayum.whatProvides(r, f, v).returnPackages() if self.config.getboolean('pungi', 'alldeps'):
if not deps: # greedy
self.logger.warn("Unresolvable dependency %s in %s.%s" % (r, po.name, po.arch)) deps = self.ayum.whatProvides(r, f, v).returnPackages()
continue if not deps:
self.logger.warn("Unresolvable dependency %s in %s.%s" % (r, po.name, po.arch))
continue
if not self.config.getboolean('pungi', 'alldeps'): depsack = yum.packageSack.ListPackageSack(deps)
deps = self.ayum.bestPackagesFromList(deps)
depsack = yum.packageSack.ListPackageSack(deps) for dep in depsack.returnNewestByNameArch():
self.ayum.tsInfo.addInstall(dep)
for dep in depsack.returnNewestByNameArch(): self.logger.info('Added %s.%s for %s.%s' % (dep.name, dep.arch, po.name, po.arch))
self.ayum.tsInfo.addInstall(dep) added.append(dep)
else:
# nogreedy
try:
pkg_sack = self.ayum.whatProvides(r, f, v).returnPackages()
if not pkg_sack:
self.logger.warn("Unresolvable dependency %s in %s.%s" % (r, po.name, po.arch))
continue
match = self.ayum._bestPackageFromList(pkg_sack)
dep = match
self.ayum.install(dep)
except (yum.Errors.InstallError, yum.Errors.YumBaseError), ex:
self.logger.warn("Unresolvable dependency %s in %s.%s" % (r, po.name, po.arch))
continue
self.logger.info('Added %s.%s for %s.%s' % (dep.name, dep.arch, po.name, po.arch)) self.logger.info('Added %s.%s for %s.%s' % (dep.name, dep.arch, po.name, po.arch))
added.append(dep) added.append(dep)
self.resolved_deps[req] = None self.resolved_deps[req] = None
for add in added: for add in added:
self.getPackageDeps(add) self.getPackageDeps(add)
@ -465,23 +480,43 @@ class Pungi(pypungi.PungiBase):
# Make the search list unique # Make the search list unique
searchlist = yum.misc.unique(searchlist) searchlist = yum.misc.unique(searchlist)
# Search repos for things in our searchlist, supports globs if self.config.getboolean('pungi', 'alldeps'):
(exactmatched, matched, unmatched) = yum.packages.parsePackages(self.ayum.pkgSack.returnPackages(), searchlist, casematch=1) # greedy
matches = filter(self._filtersrcdebug, exactmatched + matched) # Search repos for things in our searchlist, supports globs
(exactmatched, matched, unmatched) = yum.packages.parsePackages(self.ayum.pkgSack.returnPackages(), searchlist, casematch=1)
matches = filter(self._filtersrcdebug, exactmatched + matched)
# Populate a dict of package objects to their names # Populate a dict of package objects to their names
for match in matches: for match in matches:
matchdict[match.name] = match matchdict[match.name] = match
# Get the newest results from the search # Get the newest results from the search
mysack = yum.packageSack.ListPackageSack(matches) mysack = yum.packageSack.ListPackageSack(matches)
for match in mysack.returnNewestByNameArch(): for match in mysack.returnNewestByNameArch():
self.ayum.tsInfo.addInstall(match) self.ayum.tsInfo.addInstall(match)
self.logger.debug('Found %s.%s' % (match.name, match.arch)) self.logger.info('Found %s.%s' % (match.name, match.arch))
for pkg in unmatched: for pkg in unmatched:
if not pkg in matchdict.keys(): if not pkg in matchdict.keys():
self.logger.warn('Could not find a match for %s in any configured repo' % pkg) self.logger.warn('Could not find a match for %s in any configured repo' % pkg)
else:
# nogreedy
for name in searchlist:
arch = None
if "." in name:
name, arch = name.rsplit(".", 1)
pkg_sack = self.ayum.pkgSack.searchNevra(name=name, arch=arch)
# filter sources out of the package sack
pkg_sack = [ i for i in pkg_sack if i.arch not in ("src", "nosrc") ]
match = self.ayum._bestPackageFromList(pkg_sack)
if not match:
self.logger.warn('Could not find a match for %s in any configured repo' % name)
continue
self.ayum.tsInfo.addInstall(match)
self.logger.info('Found %s.%s' % (match.name, match.arch))
if len(self.ayum.tsInfo) == 0: if len(self.ayum.tsInfo) == 0:
raise yum.Errors.MiscError, 'No packages found to download.' raise yum.Errors.MiscError, 'No packages found to download.'