From c4da9b949a09f6fcf4091f247a05cea78175571a Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Tue, 10 Feb 2015 18:13:25 +0000 Subject: bitbake: 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]. (Bitbake rev: 408be9cdf2b1e32e64ea488d8051a546fb54c144) Signed-off-by: Paul Eggleton Signed-off-by: Richard Purdie --- bitbake/lib/bb/cooker.py | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) (limited to 'bitbake/lib/bb/cooker.py') diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index f77c6c0532..0bbbc09c33 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py @@ -1096,42 +1096,30 @@ class BBCooker: # Check dependencies and store information for priority calculation deps = self.data.getVar("LAYERDEPENDS_%s" % c, True) if deps: - depnamelist = [] - deplist = deps.split() - for dep in deplist: - depsplit = dep.split(':') - if len(depsplit) > 1: - try: - depver = int(depsplit[1]) - except ValueError: - parselog.error("invalid version value in LAYERDEPENDS_%s: \"%s\"", c, dep) - errors = True - continue - else: - depver = None - dep = depsplit[0] - depnamelist.append(dep) - + try: + deplist = bb.utils.explode_dep_versions2(deps) + except bb.utils.VersionStringException as vse: + bb.fatal('Error parsing LAYERDEPENDS_%s: %s' % (c, str(vse))) + for dep, oplist in deplist.iteritems(): if dep in collection_list: - if depver: + for opstr in oplist: layerver = self.data.getVar("LAYERVERSION_%s" % dep, True) + (op, depver) = opstr.split() if layerver: try: - lver = int(layerver) - except ValueError: - parselog.error("invalid value for LAYERVERSION_%s: \"%s\"", c, layerver) - errors = True - continue - if lver != depver: - parselog.error("Layer '%s' depends on version %d of layer '%s', but version %d is enabled in your configuration", c, depver, dep, lver) + res = bb.utils.vercmp_string_op(layerver, depver, op) + except bb.utils.VersionStringException as vse: + bb.fatal('Error parsing LAYERDEPENDS_%s: %s' % (c, str(vse))) + if not res: + parselog.error("Layer '%s' depends on version %s of layer '%s', but version %s is currently enabled in your configuration. Check that you are using the correct matching versions/branches of these two layers.", c, opstr, dep, layerver) errors = True else: - parselog.error("Layer '%s' depends on version %d of layer '%s', which exists in your configuration but does not specify a version", c, depver, dep) + parselog.error("Layer '%s' depends on version %s of layer '%s', which exists in your configuration but does not specify a version. Check that you are using the correct matching versions/branches of these two layers.", c, opstr, dep) errors = True else: parselog.error("Layer '%s' depends on layer '%s', but this layer is not enabled in your configuration", c, dep) errors = True - collection_depends[c] = depnamelist + collection_depends[c] = deplist.keys() else: collection_depends[c] = [] -- cgit v1.2.3-54-g00ecf