summaryrefslogtreecommitdiffstats
path: root/lib/bb/utils.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-02-10 18:13:25 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-02-16 09:10:30 +0000
commit408be9cdf2b1e32e64ea488d8051a546fb54c144 (patch)
tree535b56ec26cd6bc06212b09f1d04225e4780e44c /lib/bb/utils.py
parent3a9eefe27f29a4593d6298f0427ac5f3e9183377 (diff)
downloadbitbake-408be9cdf2b1e32e64ea488d8051a546fb54c144.tar.gz
cooker: rework LAYERDEPENDS versioning so that it is actually useful
We've had versioned dependency support in LAYERDEPENDS for quite a long time, but I can say with pretty good certainty that almost nobody has used it up to now because it was too strict - the specified version had to exactly match the version in your configuration or you would get an error; there was no "greater than or equal" option, which is usually what you will want given that LAYERVERSION does get bumped from time to time. However, users mismatching layer branches and then having their builds fail later on with some incomprehensible error is still a pretty common problem. We can't simply use the git branch because not everyone is always on a branch and the branch names don't always match up (and that's not an issue). To provide a practical means to address branch mismatching, I have reworked LAYERDEPENDS version specifications to use the more familiar "dependency (>= version)" syntax as used with package dependencies, support non-integer versions, and clarified the error message a little. If we then take care to bump the version on every breaking change, it is at least possible to have layers depend on these changes when they update to match; we can now even support a major.minor scheme to allow retrospectively adding a version limiter to old branches when a new branch is created and yet still allow the old branch minor version to be bumped if needed. Fixes [YOCTO #5991]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/utils.py')
-rw-r--r--lib/bb/utils.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 7ba123457..5ac9bcfbd 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -131,6 +131,28 @@ def vercmp_string(a, b):
tb = split_version(b)
return vercmp(ta, tb)
+def vercmp_string_op(a, b, op):
+ """
+ Compare two versions and check if the specified comparison operator matches the result of the comparison.
+ This function is fairly liberal about what operators it will accept since there are a variety of styles
+ depending on the context.
+ """
+ res = vercmp_string(a, b)
+ if op in ('=', '=='):
+ return res == 0
+ elif op == '<=':
+ return res <= 0
+ elif op == '>=':
+ return res >= 0
+ elif op in ('>', '>>'):
+ return res > 0
+ elif op in ('<', '<<'):
+ return res < 0
+ elif op == '!=':
+ return res != 0
+ else:
+ raise VersionStringException('Unsupported comparison operator "%s"' % op)
+
def explode_deps(s):
"""
Take an RDEPENDS style string of format: