mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 12:49:46 +00:00
bb.utils: Modifed vercmp() to meet Debian rules.
The version compare function vercmp() was not exatcly conforming to Debian rules, e.g. it reported 'r1' > 'r1.1' but the Debian rules says 'r1' < 'r1.1'; it didn't support the "~" either. Modified the vercmp() to meet Debian rules, so that it's compatible to the rules used in opkg. This part of the buf fixing of [YOCTO #2233]. (Bitbake rev: 97b610c54c60b5a40fa7f6a09fa23ce17b38f93a) Signed-off-by: Lianhao Lu <lianhao.lu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
4997801bad
commit
811f7d8ebf
+16
-24
@@ -31,9 +31,6 @@ from contextlib import contextmanager
|
|||||||
|
|
||||||
logger = logging.getLogger("BitBake.Util")
|
logger = logging.getLogger("BitBake.Util")
|
||||||
|
|
||||||
# Version comparison
|
|
||||||
separators = ".-"
|
|
||||||
|
|
||||||
# Context used in better_exec, eval
|
# Context used in better_exec, eval
|
||||||
_context = {
|
_context = {
|
||||||
"os": os,
|
"os": os,
|
||||||
@@ -48,15 +45,18 @@ def explode_version(s):
|
|||||||
while (s != ''):
|
while (s != ''):
|
||||||
if s[0] in string.digits:
|
if s[0] in string.digits:
|
||||||
m = numeric_regexp.match(s)
|
m = numeric_regexp.match(s)
|
||||||
r.append(int(m.group(1)))
|
r.append((0, int(m.group(1))))
|
||||||
s = m.group(2)
|
s = m.group(2)
|
||||||
continue
|
continue
|
||||||
if s[0] in string.letters:
|
if s[0] in string.letters:
|
||||||
m = alpha_regexp.match(s)
|
m = alpha_regexp.match(s)
|
||||||
r.append(m.group(1))
|
r.append((1, m.group(1)))
|
||||||
s = m.group(2)
|
s = m.group(2)
|
||||||
continue
|
continue
|
||||||
r.append(s[0])
|
if s[0] == '~':
|
||||||
|
r.append((-1, s[0]))
|
||||||
|
else:
|
||||||
|
r.append((2, s[0]))
|
||||||
s = s[1:]
|
s = s[1:]
|
||||||
return r
|
return r
|
||||||
|
|
||||||
@@ -77,33 +77,25 @@ def split_version(s):
|
|||||||
def vercmp_part(a, b):
|
def vercmp_part(a, b):
|
||||||
va = explode_version(a)
|
va = explode_version(a)
|
||||||
vb = explode_version(b)
|
vb = explode_version(b)
|
||||||
sa = False
|
|
||||||
sb = False
|
|
||||||
while True:
|
while True:
|
||||||
if va == []:
|
if va == []:
|
||||||
ca = None
|
(oa, ca) = (0, None)
|
||||||
else:
|
else:
|
||||||
ca = va.pop(0)
|
(oa, ca) = va.pop(0)
|
||||||
if vb == []:
|
if vb == []:
|
||||||
cb = None
|
(ob, cb) = (0, None)
|
||||||
else:
|
else:
|
||||||
cb = vb.pop(0)
|
(ob, cb) = vb.pop(0)
|
||||||
if ca == None and cb == None:
|
if (oa, ca) == (0, None) and (ob, cb) == (0, None):
|
||||||
return 0
|
return 0
|
||||||
|
if oa < ob:
|
||||||
if isinstance(ca, basestring):
|
|
||||||
sa = ca in separators
|
|
||||||
if isinstance(cb, basestring):
|
|
||||||
sb = cb in separators
|
|
||||||
if sa and not sb:
|
|
||||||
return -1
|
return -1
|
||||||
if not sa and sb:
|
elif oa > ob:
|
||||||
return 1
|
return 1
|
||||||
|
elif ca < cb:
|
||||||
if ca > cb:
|
|
||||||
return 1
|
|
||||||
if ca < cb:
|
|
||||||
return -1
|
return -1
|
||||||
|
elif ca > cb:
|
||||||
|
return 1
|
||||||
|
|
||||||
def vercmp(ta, tb):
|
def vercmp(ta, tb):
|
||||||
(ea, va, ra) = ta
|
(ea, va, ra) = ta
|
||||||
|
|||||||
Reference in New Issue
Block a user