bitbake: utils.py: Allow explode_dep_versions comparisons to have arbitrary whitespace

Refactor the explode_dep_versions to be more lenient on whitespace values.

The required format is:
   foo (= 1.10)
   foo (=1.10)
   foo ( = 1.10)
   foo ( =1.10)
   foo ( = 1.10 )
   foo ( =1.10 )

(Bitbake rev: 39c1c12c58fadd854098cf14ebe92f4d307a36dd)

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Mark Hatle 2012-09-30 00:01:45 +00:00 committed by Richard Purdie
parent e7ba10c1de
commit 9a283519b2
1 changed files with 47 additions and 15 deletions

View File

@ -147,26 +147,58 @@ def explode_dep_versions(s):
r = {} r = {}
l = s.replace(",", "").split() l = s.replace(",", "").split()
lastdep = None lastdep = None
lastcmp = ""
lastver = "" lastver = ""
incmp = False
inversion = False inversion = False
for i in l: for i in l:
if i[0] == '(': if i[0] == '(':
incmp = True
i = i[1:].strip()
if not i:
continue
if incmp:
incmp = False
inversion = True inversion = True
lastver = i[1:] or "" # This list is based on behavior and supported comparisons from deb, opkg and rpm.
#j = [] #
elif inversion and i.endswith(')'): # Even though =<, <<, ==, !=, =>, and >> may not be supported,
inversion = False # we list each possibly valid item.
lastver = lastver + " " + (i[:-1] or "") # The build system is responsible for validation of what it supports.
if lastdep in r and r[lastdep] and r[lastdep] != lastver: if i.startswith(('<=', '=<', '<<', '==', '!=', '>=', '=>', '>>')):
raise ValueError("Error, item %s appeared in dependency string '%s' multiple times with different values. explode_dep_versions cannot cope with this." % (lastdep, s)) lastcmp = i[0:2]
r[lastdep] = lastver i = i[2:]
elif not inversion: elif i.startswith(('<', '>', '=')):
if not (i in r and r[i]): lastcmp = i[0:1]
r[i] = None i = i[1:]
lastdep = i else:
lastver = "" # This is an unsupported case!
elif inversion: lastcmp = (i or "")
lastver = lastver + " " + i i = ""
i.strip()
if not i:
continue
if inversion:
if i.endswith(')'):
i = i[:-1] or ""
inversion = False
if lastver and i:
lastver += " "
if i:
lastver += i
if lastdep in r and r[lastdep] and r[lastdep] != lastver:
raise ValueError("Error, item %s appeared in dependency string '%s' multiple times with different values. explode_dep_versions cannot cope with this." % (lastdep, s))
r[lastdep] = lastcmp + " " + lastver
continue
#if not inversion:
lastdep = i
lastver = ""
lastcmp = ""
if not (i in r and r[i]):
r[lastdep] = None
return r return r