summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/ui')
-rw-r--r--bitbake/lib/bb/ui/buildinfohelper.py88
-rw-r--r--bitbake/lib/bb/ui/toasterui.py4
2 files changed, 18 insertions, 74 deletions
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index c99a51109b..b2e21ef2a6 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -20,8 +20,6 @@ import datetime
20import sys 20import sys
21import bb 21import bb
22import re 22import re
23import subprocess
24
25 23
26os.environ.setdefault("DJANGO_SETTINGS_MODULE", "toaster.toastermain.settings") 24os.environ.setdefault("DJANGO_SETTINGS_MODULE", "toaster.toastermain.settings")
27 25
@@ -125,10 +123,11 @@ class ORMWrapper(object):
125 123
126 return recipe_object 124 return recipe_object
127 125
128 def get_layer_version_object(self, layer_version_information): 126 def get_update_layer_version_object(self, build_obj, layer_obj, layer_version_information):
129 127
130 layer_version_object = Layer_Version.objects.get_or_create( 128 layer_version_object = Layer_Version.objects.get_or_create(
131 layer = layer_version_information['layer'], 129 build = build_obj,
130 layer = layer_obj,
132 branch = layer_version_information['branch'], 131 branch = layer_version_information['branch'],
133 commit = layer_version_information['commit'], 132 commit = layer_version_information['commit'],
134 priority = layer_version_information['priority'] 133 priority = layer_version_information['priority']
@@ -274,60 +273,6 @@ class BuildInfoHelper(object):
274 ################### 273 ###################
275 ## methods to convert event/external info into objects that the ORM layer uses 274 ## methods to convert event/external info into objects that the ORM layer uses
276 275
277 def _get_layer_dict(self, layer_path):
278
279 layer_info = {}
280 layer_name = layer_path.split('/')[-1]
281 layer_url = 'http://layers.openembedded.org/layerindex/layer/{layer}/'
282 layer_url_name = self._get_url_map_name(layer_name)
283
284 layer_info['name'] = layer_name
285 layer_info['local_path'] = layer_path
286 layer_info['layer_index_url'] = layer_url.format(layer=layer_url_name)
287
288 return layer_info
289
290 def _get_url_map_name(self, layer_name):
291 """ Some layers have a different name on openembedded.org site,
292 this method returns the correct name to use in the URL
293 """
294
295 url_name = layer_name
296 url_mapping = {'meta': 'openembedded-core'}
297
298 for key in url_mapping.keys():
299 if key == layer_name:
300 url_name = url_mapping[key]
301
302 return url_name
303
304 def _get_layer_information(self):
305
306 layer_info = {}
307
308 return layer_info
309
310 def _get_layer_version_information(self, layer_object):
311
312 layer_version_info = {}
313 layer_version_info['build'] = self.internal_state['build']
314 layer_version_info['layer'] = layer_object
315 layer_version_info['branch'] = self._get_git_branch(layer_object.local_path)
316 layer_version_info['commit'] = self._get_git_revision(layer_object.local_path)
317 layer_version_info['priority'] = 0
318
319 return layer_version_info
320
321
322 def _get_git_branch(self, layer_path):
323 branch = subprocess.Popen("git symbolic-ref HEAD 2>/dev/null ", cwd=layer_path, shell=True, stdout=subprocess.PIPE).communicate()[0]
324 branch = branch.replace('refs/heads/', '').rstrip()
325 return branch
326
327 def _get_git_revision(self, layer_path):
328 revision = subprocess.Popen("git rev-parse HEAD 2>/dev/null ", cwd=layer_path, shell=True, stdout=subprocess.PIPE).communicate()[0].rstrip()
329 return revision
330
331 276
332 def _get_build_information(self): 277 def _get_build_information(self):
333 build_info = {} 278 build_info = {}
@@ -366,7 +311,7 @@ class BuildInfoHelper(object):
366 311
367 # Heuristics: we always match recipe to the deepest layer path that 312 # Heuristics: we always match recipe to the deepest layer path that
368 # we can match to the recipe file path 313 # we can match to the recipe file path
369 for bl in sorted(self.internal_state['layer_versions'], reverse=True, key=_slkey): 314 for bl in sorted(Layer_Version.objects.filter(build = self.internal_state['build']), reverse=True, key=_slkey):
370 if (path.startswith(bl.layer.local_path)): 315 if (path.startswith(bl.layer.local_path)):
371 return bl 316 return bl
372 317
@@ -452,12 +397,12 @@ class BuildInfoHelper(object):
452 ################################ 397 ################################
453 ## external available methods to store information 398 ## external available methods to store information
454 399
455 def store_layer_info(self): 400 def store_layer_info(self, event):
456 layers = self.server.runCommand(["getVariable", "BBLAYERS"])[0].strip().split(" ") 401 layerinfos = event.data
457 self.internal_state['layers'] = [] 402 self.internal_state['lvs'] = {}
458 for layer_path in { l for l in layers if len(l) }: 403 for layer in layerinfos:
459 layer_information = self._get_layer_dict(layer_path) 404 self.internal_state['lvs'][self.orm_wrapper.get_update_layer_object(layerinfos[layer])] = layerinfos[layer]['version']
460 self.internal_state['layers'].append(self.orm_wrapper.get_update_layer_object(layer_information)) 405
461 406
462 def store_started_build(self, event): 407 def store_started_build(self, event):
463 408
@@ -466,6 +411,12 @@ class BuildInfoHelper(object):
466 build_obj = self.orm_wrapper.create_build_object(build_information) 411 build_obj = self.orm_wrapper.create_build_object(build_information)
467 self.internal_state['build'] = build_obj 412 self.internal_state['build'] = build_obj
468 413
414 # save layer version information for this build
415 for layer_obj in self.internal_state['lvs']:
416 self.orm_wrapper.get_update_layer_version_object(build_obj, layer_obj, self.internal_state['lvs'][layer_obj])
417
418 del self.internal_state['lvs']
419
469 # create target information 420 # create target information
470 target_information = {} 421 target_information = {}
471 target_information['targets'] = event.getPkgs() 422 target_information['targets'] = event.getPkgs()
@@ -473,13 +424,6 @@ class BuildInfoHelper(object):
473 424
474 self.internal_state['targets'] = self.orm_wrapper.create_target_objects(target_information) 425 self.internal_state['targets'] = self.orm_wrapper.create_target_objects(target_information)
475 426
476 # Load layer information for the build
477 self.internal_state['layer_versions'] = []
478 for layer_object in self.internal_state['layers']:
479 layer_version_information = self._get_layer_version_information(layer_object)
480 self.internal_state['layer_versions'].append(self.orm_wrapper.get_layer_version_object(layer_version_information))
481
482 del self.internal_state['layers']
483 # Save build configuration 427 # Save build configuration
484 self.orm_wrapper.save_build_variables(build_obj, self.server.runCommand(["getAllKeysWithFlags", ["doc", "func"]])[0]) 428 self.orm_wrapper.save_build_variables(build_obj, self.server.runCommand(["getAllKeysWithFlags", ["doc", "func"]])[0])
485 429
diff --git a/bitbake/lib/bb/ui/toasterui.py b/bitbake/lib/bb/ui/toasterui.py
index 8e30a91109..50493e7b0d 100644
--- a/bitbake/lib/bb/ui/toasterui.py
+++ b/bitbake/lib/bb/ui/toasterui.py
@@ -93,7 +93,6 @@ def main(server, eventHandler, params ):
93 taskfailures = [] 93 taskfailures = []
94 94
95 buildinfohelper = BuildInfoHelper(server, build_history_enabled) 95 buildinfohelper = BuildInfoHelper(server, build_history_enabled)
96 buildinfohelper.store_layer_info()
97 96
98 97
99 while True: 98 while True:
@@ -232,12 +231,13 @@ def main(server, eventHandler, params ):
232 warnings = 0 231 warnings = 0
233 taskfailures = [] 232 taskfailures = []
234 buildinfohelper = BuildInfoHelper(server, build_history_enabled) 233 buildinfohelper = BuildInfoHelper(server, build_history_enabled)
235 buildinfohelper.store_layer_info()
236 continue 234 continue
237 235
238 if isinstance(event, bb.event.MetadataEvent): 236 if isinstance(event, bb.event.MetadataEvent):
239 if event.type == "SinglePackageInfo": 237 if event.type == "SinglePackageInfo":
240 buildinfohelper.store_build_package_information(event) 238 buildinfohelper.store_build_package_information(event)
239 if event.type == "LayerInfo":
240 buildinfohelper.store_layer_info(event)
241 continue 241 continue
242 242
243 # ignore 243 # ignore