summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2010-06-17 14:51:29 +0000
committerSol Jerome <sol.jerome@gmail.com>2010-06-21 14:11:34 -0500
commite1479f1d62577df523393f399d5698671c8bc3a5 (patch)
treeac2f86f1e0965067d8f206a69dde1242e13162f0
parent840258d4cdbd593b5bfdf7b5c0db7aed195ec0c3 (diff)
downloadbcfg2-e1479f1d62577df523393f399d5698671c8bc3a5.tar.gz
bcfg2-e1479f1d62577df523393f399d5698671c8bc3a5.tar.bz2
bcfg2-e1479f1d62577df523393f399d5698671c8bc3a5.zip
RPMng, YUMng improvements (patch from slack)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5944 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/lib/Client/Tools/RPMng.py11
-rw-r--r--src/lib/Client/Tools/YUMng.py55
2 files changed, 51 insertions, 15 deletions
diff --git a/src/lib/Client/Tools/RPMng.py b/src/lib/Client/Tools/RPMng.py
index 7caa9c2e4..a1e14b3a6 100644
--- a/src/lib/Client/Tools/RPMng.py
+++ b/src/lib/Client/Tools/RPMng.py
@@ -223,7 +223,16 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
if entry.get('name') in self.installed:
# There is at least one instance installed.
if self.pkg_checks == 'true' and entry.get('pkg_checks', 'true') == 'true':
- if entry.get('name') in self.installOnlyPkgs:
+ rpmTs = rpm.TransactionSet()
+ rpmHeader = None
+ for h in rpmTs.dbMatch(rpm.RPMTAG_NAME, entry.get('name')):
+ if rpmHeader is None or rpm.versionCompare(h, rpmHeader) > 0:
+ rpmHeader = h
+ rpmProvides = [ h['provides'] for h in \
+ rpmTs.dbMatch(rpm.RPMTAG_NAME, entry.get('name')) ]
+ rpmIntersection = set(rpmHeader['provides']) & \
+ set(self.installOnlyPkgs)
+ if len(rpmIntersection) > 0:
# Packages that should only be installed or removed.
# e.g. kernels.
self.logger.debug(" Install only package.")
diff --git a/src/lib/Client/Tools/YUMng.py b/src/lib/Client/Tools/YUMng.py
index e3a1e8a70..de5b221c1 100644
--- a/src/lib/Client/Tools/YUMng.py
+++ b/src/lib/Client/Tools/YUMng.py
@@ -130,21 +130,48 @@ class YUMng(Bcfg2.Client.Tools.RPMng.RPMng):
x.set('verify', entry.get('verify'))
if entry.get('type', False) == 'yum':
- # Make sure we are dealing with Packages from Yum
- # Resolve what provides this package. That's what
- # we need to verify. Otherwise we run into bad
- # obsoletes and provides fun.
- try:
- pkg = self.yb.returnPackageByDep(entry.get('name'))
- if entry.get('name') != pkg.name:
- self.logger.info("YUMng: remapping virtual package %s to %s" \
- % (entry.get('name'), pkg.name))
+ # Check for virtual provides or packages. If we don't have
+ # this package use Yum to resolve it to a real package name
+ knownPkgs = self.yum_installed.keys() + self.yum_avail.keys()
+ if entry.get('name') not in knownPkgs:
+ # If the package name matches something installed
+ # or available the that's the correct package.
+ try:
+ pkgDict = dict( [ (i.name, i) for i in \
+ self.yb.returnPackagesByDep(entry.get('name')) ] )
+ except yum.Errors.YumBaseError, e:
+ self.logger.error('Yum Error Depsolving for %s: %s' % \
+ (entry.get('name'), str(e)))
+ pkgDict = {}
+
+ if len(pkgDict) > 1:
+ # What do we do with multiple packages?
+ s = "YUMng: returnPackagesByDep(%s) returned many packages"
+ self.logger.info(s % entry.get('name'))
+ s = "YUMng: matching packages: %s"
+ self.logger.info(s % str(pkgDict.keys()))
+ pkgs = set(pkgDict.keys()) & set(self.yum_installed.keys())
+ if len(pkgs) > 0:
+ # Virtual packages matches an installed real package
+ pkg = pkgDict[pkgs.pop()]
+ s = "YUMng: chosing: %s" % pkg.name
+ self.logger.info(s)
+ else:
+ # What's the right package? This will fail verify
+ # and Yum should Do The Right Thing on package install
+ pkg = None
+ elif len(pkgDict) == 1:
+ pkg = pkgDict.values()[0]
+ else: # len(pkgDict) == 0
+ s = "YUMng: returnPackagesByDep(%s) returned no results"
+ self.logger.info(s % entry.get('name'))
+ pkg = None
+
+ if pkg is not None:
+ s = "YUMng: remapping virtual package %s to %s"
+ self.logger.info(s % (entry.get('name'), pkg.name))
entry.set('name', pkg.name)
- # Set the version? version = '%s:%s-%s.%s' % \
- # (pkg.epoch, pkg.version, pkg.release, pkg.arch)
- except yum.Errors.YumBaseError, e:
- self.logger.info('Yum Error Depsolving for %s: %s' % \
- (entry.get('name'), str(e)))
+
return Bcfg2.Client.Tools.RPMng.RPMng.VerifyPackage(self, entry,
modlist)