[Yum-devel] [PATCH 2/2] Fix the previous testcase, by:

Tim Lauridsen tim.lauridsen at googlemail.com
Thu Aug 6 07:32:36 UTC 2009


On 08/05/2009 11:40 PM, James Antill wrote:
> 1. We always call into _compare_providers(), don't rely on
> NewestByNameArch to get the same result.
>
> 2. Filter out nevra's, using repo comparison.
>
> ...this should fix the weird ncurses-lib problem, however the previous
> testcase doesn't model that exactly (it just shows a "problem" that if
> fixed will fix it).
>   Also the #1 part of the fix probably isn't needed for real life, but is
> to fix the testcase because of the way the unittests use one repo. with
> packages from multiple repos. (without using MetaSack).
> ---
>   yum/depsolve.py |   32 ++++++++++++++++++++------------
>   1 files changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/yum/depsolve.py b/yum/depsolve.py
> index dc9b388..d6b1b02 100644
> --- a/yum/depsolve.py
> +++ b/yum/depsolve.py
> @@ -554,18 +554,15 @@ class Depsolve(object):
>                       self._last_req = pkg
>                       return checkdeps, missingdep
>
> -        # find out which arch of the ones we can choose from is closest
> -        # to the arch of the requesting pkg
> -        newest = provSack.returnNewestByNameArch()
> -        if len(newest)>  1: # there's no way this can be zero
> -
> -            pkgresults = self._compare_providers(newest, requiringPo)
> -            # take the first one...
> -            best = pkgresults[0][0]
> -
> -        elif len(newest) == 1:
> -            best = newest[0]
> -
> +        pkgs = provSack.returnPackages()
> +        if len(pkgs) == 1: # Minor opt.
> +            best = pkgs[0]
> +        else:
> +            #  Always do compare providers for multiple pkgs, it deals with
> +            # newest etc. ... so no need to do NewestNameArch() ... and it
> +            # stops compare_providers from being clever.
> +            pkgresults = self._compare_providers(pkgs, requiringPo)
> +            best = pkgresults[0][0]
>
>           if self.rpmdb.contains(po=best): # is it already installed?
>               missingdep = 1
> @@ -1060,6 +1057,17 @@ class Depsolve(object):
>               if y_dist == x_dist:
>                   return None
>               return x
> +
> +        #  Actual start of _compare_providers().
> +
> +        # Do a NameArch filtering, based on repo. __cmp__
> +        unique_nevra_pkgs = {}
> +        for pkg in pkgs:
> +            if (pkg.pkgtup in unique_nevra_pkgs and
> +                unique_nevra_pkgs[pkg.pkgtup].repo<= pkg.repo):
> +                continue
> +            unique_nevra_pkgs[pkg.pkgtup] = pkg
> +        pkgs = unique_nevra_pkgs.values()
>
>           pkgresults = {}
>           ipkgresults = {}

Looks fine to me

Tim


More information about the Yum-devel mailing list