[yum-commits] Branch 'yum-3_2_X' - 2 commits - yum/depsolve.py yum/__init__.py yum/rpmsack.py
James Antill
james at osuosl.org
Tue Oct 19 15:46:00 UTC 2010
yum/__init__.py | 14 ++++++++++++++
yum/depsolve.py | 6 +++++-
yum/rpmsack.py | 33 +++++++++++++++++++++++++++------
3 files changed, 46 insertions(+), 7 deletions(-)
New commits:
commit 72d67825062ef7c4d0c2b2a80615c6bb0520b52d
Author: James Antill <james at and.org>
Date: Mon Oct 18 11:31:03 2010 -0400
Use rpmdb conflict index if available, in rpm-4.9.x, no need to cache.
diff --git a/yum/depsolve.py b/yum/depsolve.py
index b3d014f..4fcc6f3 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -38,7 +38,7 @@ import Errors
import warnings
warnings.simplefilter("ignore", Errors.YumFutureDeprecationWarning)
-from yum import _
+from yum import _, _rpm_ver_atleast
try:
assert max(2, 4) == 4
@@ -1104,6 +1104,10 @@ class Depsolve(object):
continue
ret.append( (po, self._prco_req_nfv2req(r, f, v),
conflicting_po) )
+
+ if _rpm_ver_atleast((4, 9, 0)):
+ return ret # Don't need the conflicts cache anymore
+
self.rpmdb.transactionCacheConflictPackages(cpkgs)
return ret
diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index ae64fa6..6d6bf1c 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -593,12 +593,34 @@ class RPMDBPackageSack(PackageSackBase):
return pkgobjlist
def _uncached_returnConflictPackages(self):
+ """ Load the packages which have conflicts from the rpmdb, newer
+ versions of rpm have an index here so this is as fast as
+ cached (we test rpm version at cache write time). """
+
if self._cached_conflicts_data is None:
- ret = []
- for pkg in self.returnPackages():
- if len(pkg.conflicts):
- ret.append(pkg)
- self._cached_conflicts_data = ret
+ result = {}
+ ts = self.readOnlyTS()
+ mi = ts.dbMatch('conflictname')
+
+ for hdr in mi:
+ if hdr['name'] == 'gpg-pubkey': # Just in case...
+ continue
+
+ po = self._makePackageObject(hdr, mi.instance())
+ result[po.pkgid] = po
+ if po._has_hdr:
+ continue # Unlikely, but, meh...
+
+ po.hdr = hdr
+ po._has_hdr = True
+ po.conflicts
+ po._has_hdr = False
+ del po.hdr
+ self._cached_conflicts_data = result.values()
+
+ if self.auto_close:
+ self.ts.close()
+
return self._cached_conflicts_data
def _write_conflicts_new(self, pkgs, rpmdbv):
@@ -1140,7 +1162,6 @@ class RPMDBPackageSack(PackageSackBase):
if self.auto_close:
self.ts.close()
-
def _header_from_index(self, idx):
"""returns a package header having been given an index"""
warnings.warn('_header_from_index() will go away in a future version of Yum.\n',
commit 3f9186cf1fa2809c71e3f23e1a94e24c8bbc1dbe
Author: James Antill <james at and.org>
Date: Mon Oct 18 11:30:55 2010 -0400
Add internal _rpm_ver_atleast(), for testing rpm versions (to feature test).
diff --git a/yum/__init__.py b/yum/__init__.py
index cecdf32..14eabc9 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -21,6 +21,19 @@ The Yum RPM software updater.
import os
import os.path
import rpm
+
+def _rpm_ver_atleast(vertup):
+ """ Check if rpm is at least the current vertup. Can return False/True/None
+ as rpm hasn't had version info for a long time. """
+ if not hasattr(rpm, '__version_info__'):
+ return None
+ try:
+ # 4.8.x rpm used strings for the tuple members, so convert.
+ vi = tuple([ int(num) for num in rpm.__version_info__])
+ return vi >= vertup
+ except:
+ return None # Something went wrong...
+
import re
import types
import errno
@@ -86,6 +99,7 @@ __version_info__ = tuple([ int(num) for num in __version__.split('.')])
# multiple YumBase() objects.
default_grabber.opts.user_agent += " yum/" + __version__
+
class _YumPreBaseConf:
"""This is the configuration interface for the YumBase configuration.
So if you want to change if plugins are on/off, or debuglevel/etc.
More information about the Yum-commits
mailing list