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

Re: dpkg's version comparison algorithm?



On Fri, 9 Jan 1998, David Frey wrote:

> Hello collegues,
> 
> I don't understand dpkg's version compare algorithm:
> (david@eos) /var/debian/unstable/binary-i386/math$dpkg --compare-versions 1.15  lt 1.2-1; echo $?
> 1
> (david@eos) /var/debian/unstable/binary-i386/math$dpkg --compare-versions 1.15  lt 1.20-1; echo $?
> 0
> (david@eos) /var/debian/unstable/binary-i386/math$dpkg --version
> Debian Linux `dpkg' package management program version 1.4.0.19 (i386 elf).
> Copyright 1994-1996 Ian Jackson, Bruce Perens.  This is free software;
> see the GNU General Public Licence version 2 or later for copying
> conditions.  There is NO warranty.  See dpkg --licence for details.
> (david@eos) /var/debian/unstable/binary-i386/math$
> 
> Why is 1.15 > 1.2 ? Is it necessary to fill in trailing zeroes?

Yes. Dpkg splits a version into number and not number compontents, so it
would look at 1.15 as '1' '.' '15' and 1.2 as '1' '.' '2'. It then
compares the number components as numbers and the non numbers as strings
(kinda, there are some special rules for -/.). 

I suspect this is so that:
 1-15 > 1-2
 1.15 > 1.2

Which is more consistant, you would never expect 1-15 < 1-2. Don't think
of the dot as a decimal but mearly as a separator, it doesn't give special
meaning to what follows.

Jason


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: