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

Re: rpmvercmp is kinda broken, always has been



> From:  Jeff Johnson <jbj@redhat.com>
> Date:  Fri, 3 Jan 2003 12:09:31 -0500
>
> On Fri, Jan 03, 2003 at 11:49:58AM -0500, Jeff Johnson wrote:
> > 
> > Heh, so you want rpm to make the number 503 less than 6? Well I suppose
> > I could do the comparison "modulo 3", that would work ;-)
> > 
> 
> Nah, modulo 3 doesn't work. Neither do any of
> bash$ dc
> 503 2 % p
> 1
> 503 3 % p
> 2
> 503 5 % p
> 3
> 503 7 % p
> 6
> 503 11 % p
> 8
> 503 13 % p
> 9
> 503 17 % p   
> 10
> 503 19 % p
> 9
> 503 23 % p
> 20
> 503 29 % p
> 10
> 503 31 % p
> 7
> 503 37 % p
> 22
> 503 41 % p
> 11
> 503 43 % p
> 30
> 503 47 % p
> 33
> 503 53 % p
> 26
> ...
> 
> Looks like 503 is gonna stay bigger than 6 forever, sigh.
> 
> ;-)

I noticed in his original email he was actually asking about 00503 being less 
than 6, not 503.

Clearly there's a special case that could be defined for version numbers which 
have leading zeros.

Equally clearly, it would be hard to come up with a special case which 
wouldn't break something else.

The only idea that comes to my mind is if one of the numbers has leading 
zeros, then the other number needs to be padded with the same number of 
leading zeros and then they can be compared like strings.

This would mean (00503 cmp 006) instead of (503 <=> 6).  (Pardon the perl syntax.)

I haven't figure out what that would break yet, but I know there's something.

Chris

-- 
Chris Garrigues                 http://www.DeepEddy.Com/~cwg/
virCIO                          http://www.virCIO.Com
716 Congress, Suite 200
Austin, TX  78701		+1 512 374 0500

  World War III:  The Wrong-Doers Vs. the Evil-Doers.



Attachment: pgp00001.pgp
Description: PGP signature


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