[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: RPM version comparison



Well,
this was a reply I sent to an enigma-list thread but of course the
original thread should have been here ... (same mistake I've made
before) so - to repeat my reply to Erik/question here ...

> On Sat, 23 Feb 2002 14:24:53 -0500
> "Chuck Moss" <cmrhen@mossc.com> wrote:
> 
>> I am using bash and would prefer to stay with bash as this is part of
>> a larger script.  Inline PERL would be ok if that is possible as well.
> 
> Perl would do a much better job of this as it can call the internal rpm
> version comparison functions (which isn't a trivial algorithm, as
> you've seen).
> 
>> If I split apart the VERSION using "." as a delimiter I can't do a
>> numeric  test because there are characters in the fields.
>> e.g.
>> openssh-2.9p2-12
>> openssh-2.9p2-7
> 
> You need to split on '.' and string-to-alpha changes. If you get
> numbers, compare numbers. If you get strings, compare strings. If
> everything looks the same, the longer one is newer.

Hmmm, I hoped this was the case (playing with dependencies with java)
but then I found in RH7.1 Install CDs:

libgtop-devel provides 1:1.0.10-3 (same as rpm filename but with epoch)
but requires libgtop = 1.0.10

however libgtop provides 1:1.0.10-3 (same as rpm filename but with epoch)

So ... does this mean that "requires = X" actually means "requires >= X" ?
(now that doesn't make sense to me :-)

Also, do you need to split on "-" first, then if each "-" section is the
same then move onto the next one? (just to confuse the issue :-)
Or do you just ignore from the second one (if the require doesn't
have a second or more)

> Finally, don't forget to compare Epochs.

How and when do you compare them? (OK I'm no good at perl or python)
e.g. most "requires" don't have an epoch
(and www.rpm.org is still down if that might have answers :-)

> 
>> Can anyone on the list state the algorythm the rpm code uses to decide
>> if a new RPM is an upgrade?
> 
> See above ;-)
> 
>> Even better, can someone express it in a shell script?
> 
> No. It's possible, but perl would be much easier, and using the python
> or perl RPM bindings would be even better.
> 
> Erik

Java does so well
Totally separate class just for versions
no confusion with anything else when you read the simple code :-)

-- 
-Cheers
-Andrew





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []