Odd version comparison

Alpár Jüttner alpar at cs.elte.hu
Thu Sep 11 22:27:05 PDT 2008


>  
> 
> No version comparison function can work perfectly for all the ways
> people come up with for labeling their software.

Yes, but it could be much better than what pkg-config has now.
IMHO, the current implementation is simply buggy for it would be a
minimum requirement that the version comparison operator is
antisymmetric (i.e if version cmp(A,B) say that A is strictly newer than
version B, then cmp(B,A) should answer the opposite). The requirement
does not hold in the current implementation.

In fact, this bug has been fixed in rpm. At least we should "re-steal"
the new version.
See the comparison function of rpm-4.4.2 attached.

>  If you really want to
> make changes here, I'd recommend enforcing a strict <number>(.<number>)*
> format for versions. That will piss people off, too. But once that is
> done, it will be possible to write a correct version comparison
> function...

It cannot be done, mainly because
      * people want to use "negative versions". Think of versions like
        1.2-RC1.
      * you must very frequently create and install packages which are
        between releases. In this case it is desirable to put the
        version control id into the code. What is worse, the ids are not
        linear in modern distributed version control systems (i.e.
        greater id isn't necessarily means newer code), and e.g. in case
        of HG, it is a hex string.

Best regards,
Alpar

-------------- next part --------------
A non-text attachment was scrubbed...
Name: rpmvercmp.c
Type: text/x-csrc
Size: 3186 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/pkg-config/attachments/20080912/4850ea75/attachment-0001.c 


More information about the pkg-config mailing list