summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorLianhao Lu <lianhao.lu@intel.com>2012-04-12 17:28:01 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-04-13 12:04:19 +0100
commit811f7d8ebfe9d55b0244d8284a04b0ef6902adbb (patch)
tree8b55d6ef24a0051ee3378460925a90b52f8a831e /bitbake
parent4997801bad7ae2a43221dd58151c8f2facd03210 (diff)
downloadpoky-811f7d8ebfe9d55b0244d8284a04b0ef6902adbb.tar.gz
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>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/utils.py40
1 files changed, 16 insertions, 24 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 21d3a812d3..1d98bca6ce 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -31,9 +31,6 @@ from contextlib import contextmanager
31 31
32logger = logging.getLogger("BitBake.Util") 32logger = logging.getLogger("BitBake.Util")
33 33
34# Version comparison
35separators = ".-"
36
37# Context used in better_exec, eval 34# Context used in better_exec, eval
38_context = { 35_context = {
39 "os": os, 36 "os": os,
@@ -48,15 +45,18 @@ def explode_version(s):
48 while (s != ''): 45 while (s != ''):
49 if s[0] in string.digits: 46 if s[0] in string.digits:
50 m = numeric_regexp.match(s) 47 m = numeric_regexp.match(s)
51 r.append(int(m.group(1))) 48 r.append((0, int(m.group(1))))
52 s = m.group(2) 49 s = m.group(2)
53 continue 50 continue
54 if s[0] in string.letters: 51 if s[0] in string.letters:
55 m = alpha_regexp.match(s) 52 m = alpha_regexp.match(s)
56 r.append(m.group(1)) 53 r.append((1, m.group(1)))
57 s = m.group(2) 54 s = m.group(2)
58 continue 55 continue
59 r.append(s[0]) 56 if s[0] == '~':
57 r.append((-1, s[0]))
58 else:
59 r.append((2, s[0]))
60 s = s[1:] 60 s = s[1:]
61 return r 61 return r
62 62
@@ -77,33 +77,25 @@ def split_version(s):
77def vercmp_part(a, b): 77def vercmp_part(a, b):
78 va = explode_version(a) 78 va = explode_version(a)
79 vb = explode_version(b) 79 vb = explode_version(b)
80 sa = False
81 sb = False
82 while True: 80 while True:
83 if va == []: 81 if va == []:
84 ca = None 82 (oa, ca) = (0, None)
85 else: 83 else:
86 ca = va.pop(0) 84 (oa, ca) = va.pop(0)
87 if vb == []: 85 if vb == []:
88 cb = None 86 (ob, cb) = (0, None)
89 else: 87 else:
90 cb = vb.pop(0) 88 (ob, cb) = vb.pop(0)
91 if ca == None and cb == None: 89 if (oa, ca) == (0, None) and (ob, cb) == (0, None):
92 return 0 90 return 0
93 91 if oa < ob:
94 if isinstance(ca, basestring):
95 sa = ca in separators
96 if isinstance(cb, basestring):
97 sb = cb in separators
98 if sa and not sb:
99 return -1 92 return -1
100 if not sa and sb: 93 elif oa > ob:
101 return 1 94 return 1
102 95 elif ca < cb:
103 if ca > cb:
104 return 1
105 if ca < cb:
106 return -1 96 return -1
97 elif ca > cb:
98 return 1
107 99
108def vercmp(ta, tb): 100def vercmp(ta, tb):
109 (ea, va, ra) = ta 101 (ea, va, ra) = ta