[Yum-devel] [PATCH] Use rpmdb conflict index if available, in rpm-4.9.x, no need to cache.

seth vidal skvidal at fedoraproject.org
Tue Oct 19 14:54:09 UTC 2010


On Mon, 2010-10-18 at 11:55 -0400, James Antill wrote:
> ---
>  yum/depsolve.py |    6 +++++-
>  yum/rpmsack.py  |   33 +++++++++++++++++++++++++++------
>  2 files changed, 32 insertions(+), 7 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..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',


ACK.
-sv




More information about the Yum-devel mailing list