[TriLUG] Filtering RPM versions
Tanner Lovelace
clubjuggler at gmail.com
Tue Dec 21 17:06:54 EST 2004
On Tue, 21 Dec 2004 15:08:56 -0500, David McDowell
<turnpike420 at gmail.com> wrote:
> Can you write a script that uses regex to compare each package name
> and its subsequent version number and if it has more than one, delete
> all other versions with a lower number?
>
> pkg-2.4-5.i386.rpm
> pkg-2.4-6.i386.rpm
> pkg-2.7-1.i386.rpm
>
> it would find "pkg" then the first "-" then the numbering and compare
> which is highest number and ditch the rest...
>
> good luck... my regex fu is non-existent. :)
Well, here's a regex that's used by a script that will automatically
mirror a mandrake distribution and only retrieve the latest version
of rpms. It's somewhat mandrake specific and hard to understand,
but it might get you started:
my $regexp = '^.*\s((?:.*?(?=-\d+\.\d+\.\d+\.\d+mdk))|(?:.*?(?!-\d+\.\d+\.\d+\.\d+mdk)))-((?:\d+\.\d+\.\d+\.\d+m
dk)|(?:[^-]*-[^-]*(?!-)))((?:-1-1mdk\..*\.rpm)|(?:\.[^-]*\.rpm))$';
Good luck.
Cheers,
Tanner
More information about the TriLUG
mailing list