Re: rpm scoring script.

seth vidal <skvidal-c/MNwgJ9CEH2fBVCVOL8/[email protected]> Sun, 15 Feb 2004 00:28:54 -0500
Newsgroups gmane.linux.redhat.rpm.python
Message-ID <1076822933.17242.39.camel@binkley>
On Sun, 2004-02-15 at 13:02 +1300, Michael Honeyfield wrote:

> Just wondering if there is a script out there that can scan a folder of
> rpms and move the highest scoring packages to a specific folder. 
> 
> eg: 
> 
> foobar - 0:1.2.3-1
> foobar - 1:2.0.0-10
> foo - 13:10.0-0
> foo - 1:21.0-100
> 

not too hard to do - if you take the code from yum-arch you can do 70%
of this.

1. get a list of all the rpms
2. start going through each one and make a couple of dicts:
 (name, arch) : [(e, v, r), (e, v, r)]
 (name, arch, e, v, r) : pkg filename

3. then go through each (name, arch) in the first dict and if the len of
the list of (e, v, r) is > 1 then compare each (e, v, r) and remove the
one(s) that are older.

4. then go through the second dict using the first and copy out the rpms
that are newest.

-sv