[1.40][PATCH] bitbake: fix version comparison when one of the versions ends in .
From: Alexander Kanavin <[email protected]>
Previously, this would happen:
======================================================================
ERROR: test_vercmpstring (bb.tests.utils.VerCmpString)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/alexander/development/poky/bitbake/lib/bb/tests/utils.py", line 45, in test_vercmpstring
result = bb.utils.vercmp_string('1.', '1.1') File "/home/alexander/development/poky/bitbake/lib/bb/utils.py", line 143, in vercmp_string
return vercmp(ta, tb)
File "/home/alexander/development/poky/bitbake/lib/bb/utils.py", line 135, in vercmp
r = vercmp_part(va, vb)
File "/home/alexander/development/poky/bitbake/lib/bb/utils.py", line 124, in vercmp_part
elif ca < cb:
TypeError: '<' not supported between instances of 'NoneType' and 'int'
----------------------------------------------------------------------
--- lib/bb/tests/utils.py | 4 ++++ lib/bb/utils.py | 4 ++++ 2 files changed, 8 insertions(+)
lib/bb/tests/utils.py +4 -0
@@ -42,6 +42,10 @@ class VerCmpString(unittest.TestCase): self.assertTrue(result < 0) result = bb.utils.vercmp_string('1.1', '1.0+1.1-beta1') self.assertTrue(result > 0) + result = bb.utils.vercmp_string('1.', '1.1') + self.assertTrue(result < 0) + result = bb.utils.vercmp_string('1.1', '1.') + self.assertTrue(result > 0) def test_explode_dep_versions(self): correctresult = {"foo" : ["= 1.10"]}
lib/bb/utils.py +4 -0
@@ -120,6 +120,10 @@ def vercmp_part(a, b): return -1 elif oa > ob: return 1 + elif ca is None: + return -1 + elif cb is None: + return 1 elif ca < cb: return -1 elif ca > cb:
Signature · 1 line
2.17.1
Quoted 9 lines · Martin Jansa
From: Alexander Kanavin <[email protected]>
Previously, this would happen:
======================================================================
ERROR:test_vercmpstring(bb.tests.utils.VerCmpString)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/alexander/development/poky/bitbake/lib/bb/tests/utils.py", line 45, intest_vercmpstring
Quoted 8 lines
result = bb.utils.vercmp_string('1.', '1.1')File "
/home/alexander/development/poky/bitbake/lib/bb/utils.py", line 143, invercmp_string
returnvercmp(ta, tb)
File "/home/alexander/development/poky/bitbake/lib/bb/utils.py", line 135, in vercmp
r =vercmp_part(va, vb)
File "/home/alexander/development/poky/bitbake/lib/bb/utils.py", line 124, invercmp_part
elif ca < cb:
TypeError: '<' not supported between instances of 'NoneType' and 'int'
I was seeing the same error on versions not ending with '.', in my case:
bb.utils.vercmp((0,1.0.2r,r0.0webos22), (0,1.0.2r0webos19,r0.0webos21)
Which lead to do_packagedata failure through buildhistory_emit_pkghistory shown bellow.
Alex's fix works for the above versions as well, should I extend the bb.utils.vercmp selftest with even weirder versions like we're using or leave it as is?
The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
0001:
*** 0002:buildhistory_emit_pkghistory(d)
0003:
File: 'oe-core/meta/classes/buildhistory.bbclass', lineno: 263, function: buildhistory_emit_pkghistory
0259: last_pkge = lastversion.pkge
0260: last_pkgv = lastversion.pkgv
0261: last_pkgr = lastversion.pkgr
0262: bb.warn("bb.utils.vercmp((%s,%s,%s), (%s,%s,%s)" % (pkge, pkgv, pkgr, last_pkge, last_pkgv, last_pkgr))
*** 0263: r = bb.utils.vercmp((pkge, pkgv, pkgr), (last_pkge, last_pkgv, last_pkgr))
0264: if r < 0: 0265: msg = "Package version for package %s went backwards which would break package feeds from (%s:%s-%s to %s:%s-%s)" % (pkg, last_pkge, last_pkgv, last_pkgr, pkge, pkgv, pkgr)
0266: package_qa_handle_error("version-going-backwards", msg, d)
0267:
File: 'bitbake/lib/bb/utils.py', lineno: 134, function: vercmp
0130: (eb, vb, rb) = tb
0131:
0132: r = int(ea or 0) - int(eb or 0)
0133: if (r == 0):
*** 0134: r = vercmp_part(va, vb)
0135: if (r == 0):
0136: r = vercmp_part(ra, rb)
0137: return r
0138:
File: 'bitbake/lib/bb/utils.py', lineno: 123, function: vercmp_part
0119: if oa < ob:
0120: return -1
0121: elif oa > ob:
0122: return 1
*** 0123: elif ca < cb:
0124: return -1
0125: elif ca > cb:
0126: return 1
0127:Exception: TypeError: '<' not supported between instances of 'NoneType' and 'int'
Quoted 43 lines
----------------------------------------------------------------------
Signed-off-by Alexander Kanavin <[email protected]>Signed-off-by Richard Purdie <[email protected]>--- lib/bb/tests/utils.py | 4 ++++ lib/bb/utils.py | 4 ++++ 2 files changed, 8 insertions(+)lib/bb/tests/utils.py +4
-0@@ -42,6 +42,10 @@ class VerCmpString(unittest.TestCase): self.assertTrue(result < 0) result = bb.utils.vercmp_string('1.1', '1.0+1.1-beta1') self.assertTrue(result > 0) + result = bb.utils.vercmp_string('1.', '1.1') + self.assertTrue(result < 0) + result = bb.utils.vercmp_string('1.1', '1.') + self.assertTrue(result > 0) def test_explode_dep_versions(self): correctresult = {"foo" : ["= 1.10"]}lib/bb/utils.py +4
-0@@ -120,6 +120,10 @@ def vercmp_part(a, b): return -1 elif oa > ob: return 1 + elif ca is None: + return -1 + elif cb is None: + return 1 elif ca < cb: return -1 elif ca > cb:Signature · 1 line
2.17.1
Signature · 1 line
Martin 'JaMa' Jansa jabber: [email protected]
Quoted 5 lines · Martin Jansa
I was seeing the same error on versions not ending with '.', in my case:
bb.utils.vercmp((0,1.0.2r,r0.0webos22), (0,1.0.2r0webos19,r0.0webos21)
Quoted 7 lines
Which lead to
do_packagedatafailure throughbuildhistory_emit_pkghistoryshown bellow.Alex's fix works for the above versions as well, should I extend the bb.utils.vercmp selftest with even weirder versions like we're using
or leave it as is?
Adding such examples would be good please!
Cheers,
Richard