[Yum-devel] [PATCH 2/2] Use rpmdb conflict index if available, in rpm-4.9.x, no need to cache.
James Antill
james at and.org
Mon Oct 18 15:31:14 UTC 2010
---
yum/depsolve.py | 6 +++++-
yum/rpmsack.py | 28 ++++++++++++++++++++++++----
2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/yum/depsolve.py b/yum/depsolve.py
index 886cca8..d4aa0b2 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
@@ -1092,6 +1092,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..fde04bd 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -593,12 +593,33 @@ 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)
+ ts = self.readOnlyTS()
+ mi = ts.dbMatch('conflictname')
+
+ for hdr in mi:
+ if hdr['name'] == 'gpg-pubkey': # Just in case...
+ continue
+
+ ret.append(self._makePackageObject(hdr, mi.instance()))
+ if ret[-1]._has_hdr:
+ continue # Unlikely, but, meh...
+
+ ret[-1].hdr = hdr
+ ret[-1]._has_hdr = True
+ ret[-1].conflicts
+ ret[-1]._has_hdr = False
+ del ret[-1].hdr
self._cached_conflicts_data = ret
+
+ if self.auto_close:
+ self.ts.close()
+
return self._cached_conflicts_data
def _write_conflicts_new(self, pkgs, rpmdbv):
@@ -1140,7 +1161,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',
--
1.7.2.3
More information about the Yum-devel
mailing list