[bitbake-devel] bb.utils.vercmp() not consistent with debian rules

Lu, Lianhao lianhao.lu at intel.com
Thu Apr 5 14:44:01 UTC 2012


Richard Purdie wrote on 2012-04-05:
> On Thu, 2012-04-05 at 13:18 +0100, Richard Purdie wrote:
>> On Thu, 2012-04-05 at 06:42 +0000, Lu, Lianhao wrote:
>>> Martin Jansa wrote on 2012-04-05:
>>>> On Thu, Apr 05, 2012 at 06:22:00AM +0000, Lu, Lianhao wrote:
>>>>> Hi guys,
>>>>> 
>>>>> When I'm looking at the Yocto bug#2233, I find that the function
>>>>> bb.utils.vercmp() is not consistent with the debian packaging
>>>>> rules(http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-
>>>>> Version).
>>>>> 
>>>>> According to debian rules, "r0" is earlier than "r0-dream", but the bb.utils.vercmp() thinks "r0" is later than "r0-dream".
>>>> 
>>>> And what about something like this:
>>>> 
>>>> Version: 3.2-r10
>>>> is older then
>>>> Version: 3.2-r2-oe0
>>> 
>>> I think this is exactly what the debian rules wants, "3.2-r10">"3.2-r2-oe0". And opkg follows that rule.
>>> 
>>> The problem is that bb.utils.vercmp thinks "3.2-r2">"3.2-r2-oe0" while opkg thinks "3.2-r2"<"3.2-r2-oe0".
>> 
>> All the version comparisons are meant to function the same way and the
>> debian sorting is meant to be used as a guide. If that patch does break
>> things, we should consider removing "-" as the separator and only use
>> ".".
> 
> So just to be clear, we have various version sorting algorithms:
> 
> * opkg
> * opkg-compare-versions (which has a C version and a shell version!)
> * bb.utils.vercmp()
> * bb.utils.vercmp_string()
> 
> and all these functions *need* to be consistent. Consistent is defined
> in this case as following the Debian version policy. This is ignoring
> the other package backends. dpkg should "just work", rpm can be
> programmed to use any algorithm and is probably not consistent with this
> at this point but we should probably ignore that in the equation at this
> point.
> 
> So the question is, which of the above are consistent or inconsistent
> with each other (and dpkg), and how they are inconsistent. We can then
> consider what to do about it.
> 

The difference between those is how to treat "separators" in version compare.
Take 2 examples, v1="3.2-r2-oe0", v1'="3.2-r2"; v2="4.4-r8-oe0", v2'="4.4-r8a"

The Debian version policy says, "...so that all the letters sort earlier than all 
the non-letters and so that a tilde sorts before anything, even the end of a part."
So v1>v1', v2>v2'.

The opkg follows the Debian rules, and reports v1>v1', v2>v2'. dpkg reports the same.

The C version of opkg-compare-versions reports v1>v1', v2<v2'. (The shell version do
NOT have the function of comparison).

The bb.utils.vercmp() reports v1<v1', v2<v2'. It treats all separators(i.e. "." and "-") as tilde
in Debian rules. The bb.utils.vercmp is used both by bitbake internally and bbclass.

The bb.utils.vercmp_string() does NOT accept version string containing segments starting with 
non-digital character. bb.utils.vercmp_string seems never being actually called.

Seems we have nothing consistent here. :-(  

- Lianhao




More information about the bitbake-devel mailing list