summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/buildinfohelper.py
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-11-24 11:20:04 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-11-30 15:48:10 +0000
commit439f3da1a1737fe111f77b13c8c20718bfe91f49 (patch)
treed4f7f2c058313a528c18b42d2086dbf404146102 /bitbake/lib/bb/ui/buildinfohelper.py
parent5de7f159a15918526825e99a44cd572c7494f5bf (diff)
downloadpoky-439f3da1a1737fe111f77b13c8c20718bfe91f49.tar.gz
bitbake: toaster: buildinfohelper Simplify layer event to toaster layer function
Simplify the layer event information to layer version object in toaster function. Previously this attempted many different methods of trying to obtain the correct layer from toaster by manipulating the data from the event or the data from the known layers to try and match them together. We speed up and simplify this process by making better use of django's orm methods and by working down the most likely matching methods in order of accuracy. [YOCTO #10220] (Bitbake rev: 6935cc06974ea94c9971ede89b6e8f0eae9c195b) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/buildinfohelper.py')
-rw-r--r--bitbake/lib/bb/ui/buildinfohelper.py69
1 files changed, 28 insertions, 41 deletions
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index e96e93440e..43a1411fa0 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -46,6 +46,8 @@ from orm.models import Project, CustomImagePackage
46from orm.models import signal_runbuilds 46from orm.models import signal_runbuilds
47 47
48from bldcontrol.models import BuildEnvironment, BuildRequest 48from bldcontrol.models import BuildEnvironment, BuildRequest
49from bldcontrol.models import BRLayer
50from bldcontrol import bbcontroller
49 51
50from bb.msg import BBLogFormatter as formatter 52from bb.msg import BBLogFormatter as formatter
51from django.db import models 53from django.db import models
@@ -436,48 +438,33 @@ class ORMWrapper(object):
436 else: 438 else:
437 br_id, be_id = brbe.split(":") 439 br_id, be_id = brbe.split(":")
438 440
439 # find layer by checkout path; 441 # Find the layer version by matching the layer event information
440 from bldcontrol import bbcontroller 442 # against the metadata we have in Toaster
441 bc = bbcontroller.getBuildEnvironmentController(pk = be_id)
442
443 # we might have a race condition here, as the project layers may change between the build trigger and the actual build execution
444 # but we can only match on the layer name, so the worst thing can happen is a mis-identification of the layer, not a total failure
445
446 # note that this is different
447 buildrequest = BuildRequest.objects.get(pk = br_id)
448 for brl in buildrequest.brlayer_set.all():
449 if brl.local_source_dir:
450 localdirname = os.path.join(brl.local_source_dir,
451 brl.dirpath)
452 else:
453 localdirname = os.path.join(bc.getGitCloneDirectory(brl.giturl, brl.commit), brl.dirpath)
454 # we get a relative path, unless running in HEAD mode where the path is absolute
455 if not localdirname.startswith("/"):
456 localdirname = os.path.join(bc.be.sourcedir, localdirname)
457 #logger.debug(1, "Localdirname %s lcal_path %s" % (localdirname, layer_information['local_path']))
458 if localdirname.startswith(layer_information['local_path']):
459 # If the build request came from toaster this field
460 # should contain the information from the layer_version
461 # That created this build request.
462 if brl.layer_version:
463 return brl.layer_version
464
465 # This might be a local layer (i.e. no git info) so try
466 # matching local_source_dir
467 if brl.local_source_dir and brl.local_source_dir == layer_information["local_path"]:
468 return brl.layer_version
469
470 # we matched the BRLayer, but we need the layer_version that generated this BR; reverse of the Project.schedule_build()
471 #logger.debug(1, "Matched %s to BRlayer %s" % (pformat(layer_information["local_path"]), localdirname))
472
473 for pl in buildrequest.project.projectlayer_set.filter(layercommit__layer__name = brl.name):
474 if pl.layercommit.layer.vcs_url == brl.giturl :
475 layer = pl.layercommit.layer
476 layer.save()
477 return layer
478
479 raise NotExisting("Unidentified layer %s" % pformat(layer_information))
480 443
444 try:
445 br_layer = BRLayer.objects.get(req=br_id,
446 name=layer_information['name'])
447 return br_layer.layer_version
448 except (BRLayer.MultipleObjectsReturned, BRLayer.DoesNotExist):
449 # There are multiple of the same layer name or the name
450 # hasn't been determined by the toaster.bbclass layer
451 # so let's filter by the local_path
452 bc = bbcontroller.getBuildEnvironmentController(pk=be_id)
453 for br_layer in BRLayer.objects.filter(req=br_id):
454 if br_layer.giturl and \
455 layer_information['local_path'].endswith(
456 bc.getGitCloneDirectory(br_layer.giturl,
457 br_layer.commit)):
458 return br_layer.layer_version
459
460 if br_layer.local_source_dir == \
461 layer_information['local_path']:
462 return br_layer.layer_version
463
464 # We've reached the end of our search and couldn't find the layer
465 # we can continue but some data may be missing
466 raise NotExisting("Unidentified layer %s" %
467 pformat(layer_information))
481 468
482 def save_target_file_information(self, build_obj, target_obj, filedata): 469 def save_target_file_information(self, build_obj, target_obj, filedata):
483 assert isinstance(build_obj, Build) 470 assert isinstance(build_obj, Build)