On Wed, 2012-02-01 at 11:16 -0500, James Antill wrote:
> On Wed, 2012-02-01 at 13:24 +0100, Zdeněk Pavlas wrote:
> > 'list available' hides packages that are installed, or a newer
> > version is installed.  To find out the newest version installed,
> > ghe RPMDB query must not contain explicit version.
> > ---
> >  yum/__init__.py |    6 +++++-
> >  1 files changed, 5 insertions(+), 1 deletions(-)
> > 
> > diff --git a/yum/__init__.py b/yum/__init__.py
> > index 4c68e22..d1807c2 100644
> > --- a/yum/__init__.py
> > +++ b/yum/__init__.py
> > @@ -2517,7 +2517,11 @@ class YumBase(depsolve.Depsolve):
> >          if pkgnarrow == 'all': 
> >              dinst = {}
> >              ndinst = {} # Newest versions by name.arch
> > -            for po in self.rpmdb.returnPackages(patterns=patterns,
> > +            rpm_patterns = patterns
> > +            if not showdups:
> > +                # need to find the newest, so strip versions if supplied
> > +                rpm_patterns = [re.sub('-\d.*', '-*', p) for p in 
> > rpm_patterns]
> > +            for po in self.rpmdb.returnPackages(patterns=rpm_patterns,
> >                                                  ignore_case=ic):
> >                  dinst[po.pkgtup] = po
> >                  if showdups:
> 
>  This is the wrong way to try and fix this. Pretty sure the first bug is
> in the available section too.
>  You also can't do that s///, because you are assuming things about pkg
> naming/versioning that aren't true.

 Was a bit short here, trying to do too much at once. Was also wrong, as
bug was in the 'all' section :).

 To give a longer explanation, if you have a _full_ NVR for a package
you can split it fairly easily:

 N-V-R 
  ==
   N, V, R = input.rsplit('-', 2)
  ==
   name: N
   version: V
   release: R

 a-a-a =
   name: a
   version: a
   release: a
 a-a-a-a-a-a =
   name: a-a-a-a
   version: a
   release: a
 a-a-a-a-b-c =
   name: a-a-a-a
   version: b
   release: c
 a-b-c-d-e.f-a =
   name: a-b-c-d
   version: e.f
   release: a

...but if we add wildcards, we are completely screwed because it's
mostly not possible to work out what the * is hiding.
 Eg.

 *-a-a matches the name of "a-a-a-a"  (version b-c) and the
version-release of "a".
 a-*-a matches "a", "a-a-a-a" (version a-a) and "a-b-c-d".

_______________________________________________
Yum-devel mailing list
[email protected]
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to