summaryrefslogtreecommitdiffstats
path: root/lib/bb/ui/buildinfohelper.py
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-09-28 21:45:27 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-29 13:44:49 +0100
commit838e77c7c3c4006abd1327343a004590ab652de9 (patch)
treede0390791bbb8dbb94cba4887febdc4d0d7a2fbf /lib/bb/ui/buildinfohelper.py
parent8e36b6848c14f2708e1f87d12fb533ca0b596c65 (diff)
downloadbitbake-838e77c7c3c4006abd1327343a004590ab652de9.tar.gz
toaster: Create a relationship between build information and toaster layers
Previously this layer relationship was done by trying to match path information that came back to the buildinfohelper with trying to query for data in toaster's layers table. This rarely matched due to the lose coupling. Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: brian avery <avery.brian@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/ui/buildinfohelper.py')
-rw-r--r--lib/bb/ui/buildinfohelper.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/bb/ui/buildinfohelper.py b/lib/bb/ui/buildinfohelper.py
index 5098448c9..d0efaa977 100644
--- a/lib/bb/ui/buildinfohelper.py
+++ b/lib/bb/ui/buildinfohelper.py
@@ -94,8 +94,8 @@ class ORMWrapper(object):
created = False
if not key in vars(self)[dictname].keys():
- vars(self)[dictname][key] = clazz.objects.create(**kwargs)
- created = True
+ vars(self)[dictname][key], created = \
+ clazz.objects.get_or_create(**kwargs)
return (vars(self)[dictname][key], created)
@@ -271,6 +271,17 @@ class ORMWrapper(object):
return recipe_object
def get_update_layer_version_object(self, build_obj, layer_obj, layer_version_information):
+ if isinstance(layer_obj, Layer_Version):
+ # We already found our layer version for this build so just
+ # update it with the new build information
+ logger.debug("We found our layer from toaster")
+ layer_obj.build = build_obj
+ layer_obj.local_path = layer_version_information['local_path']
+ layer_obj.commit = layer_version_information['commit']
+ layer_obj.save()
+ self.layer_version_objects.append(layer_obj)
+ return layer_obj
+
assert isinstance(build_obj, Build)
assert isinstance(layer_obj, Layer)
assert 'branch' in layer_version_information
@@ -320,8 +331,15 @@ class ORMWrapper(object):
localdirname = os.path.join(bc.be.sourcedir, localdirname)
#logger.debug(1, "Localdirname %s lcal_path %s" % (localdirname, layer_information['local_path']))
if localdirname.startswith(layer_information['local_path']):
+ # If the build request came from toaster this field
+ # should contain the information from the layer_version
+ # That created this build request.
+ if brl.layer_version:
+ return brl.layer_version
+
# we matched the BRLayer, but we need the layer_version that generated this BR; reverse of the Project.schedule_build()
#logger.debug(1, "Matched %s to BRlayer %s" % (pformat(layer_information["local_path"]), localdirname))
+
for pl in buildrequest.project.projectlayer_set.filter(layercommit__layer__name = brl.name):
if pl.layercommit.layer.vcs_url == brl.giturl :
layer = pl.layercommit.layer
@@ -674,6 +692,7 @@ class BuildInfoHelper(object):
def __init__(self, server, has_build_history = False):
self.internal_state = {}
self.internal_state['taskdata'] = {}
+ self.internal_state['targets'] = []
self.task_order = 0
self.autocommit_step = 1
self.server = server
@@ -752,8 +771,15 @@ class BuildInfoHelper(object):
if not localdirname.startswith("/"):
localdirname = os.path.join(bc.be.sourcedir, localdirname)
if path.startswith(localdirname):
+ # If the build request came from toaster this field
+ # should contain the information from the layer_version
+ # That created this build request.
+ if brl.layer_version:
+ return brl.layer_version
+
#logger.warn("-- managed: matched path %s with layer %s " % (path, localdirname))
# we matched the BRLayer, but we need the layer_version that generated this br
+
for lvo in self.orm_wrapper.layer_version_objects:
if brl.name == lvo.layer.name:
return lvo