From d32701381503275c13bd78c49e947ca25e2c8dcc Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Wed, 5 Mar 2014 14:59:55 +0000 Subject: [PATCH] bitbake: toasterui: fix task identification This patch adds extra checks when selecting and writing task and recipe objects to the database. The patch fixes several issues where tasks may have been misidentified between virtual-native and target tasks, or spurious task objects may have been created. (Bitbake rev: a6e597e690b3c6c6fa2af6db8cd871c02fc80421) Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/buildinfohelper.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py index f221daca5a..d7b526a2f2 100644 --- a/bitbake/lib/bb/ui/buildinfohelper.py +++ b/bitbake/lib/bb/ui/buildinfohelper.py @@ -105,7 +105,8 @@ class ORMWrapper(object): ) if must_exist and created: - raise Exception("Task object created when expected to exist") + task_information['debug'] = "build id %d, recipe id %d" % (task_information['build'].pk, task_information['recipe'].pk) + raise Exception("Task object created when expected to exist", task_information) for v in vars(task_object): if v in task_information.keys(): @@ -132,7 +133,7 @@ class ORMWrapper(object): return task_object - def get_update_recipe_object(self, recipe_information): + def get_update_recipe_object(self, recipe_information, must_exist = False): assert 'layer_version' in recipe_information assert 'file_path' in recipe_information @@ -140,6 +141,9 @@ class ORMWrapper(object): layer_version=recipe_information['layer_version'], file_path=recipe_information['file_path']) + if must_exist and created: + raise Exception("Recipe object created when expected to exist", recipe_information) + for v in vars(recipe_object): if v in recipe_information.keys(): vars(recipe_object)[v] = recipe_information[v] @@ -539,7 +543,11 @@ class BuildInfoHelper(object): assert localfilepath.startswith("/") recipe_information = self._get_recipe_information_from_taskfile(taskfile) - recipe = self.orm_wrapper.get_update_recipe_object(recipe_information) + try: + recipe = self.orm_wrapper.get_update_recipe_object(recipe_information, True) + except Exception: + # we cannot find the recipe information for the task, we move on to the next task + continue task_information = {} task_information['build'] = self.internal_state['build'] @@ -555,10 +563,18 @@ class BuildInfoHelper(object): assert localfilepath.startswith("/") identifier = event.taskfile + ":" + event.taskname - assert identifier in self.internal_state['taskdata'] + if not identifier in self.internal_state['taskdata']: + if isinstance(event, bb.build.TaskBase): + # we do a bit of guessing + candidates = [x for x in self.internal_state['taskdata'].keys() if x.endswith(identifier)] + if len(candidates) == 1: + identifier = candidates[0] - recipe_information = self._get_recipe_information_from_taskfile(event.taskfile) - recipe = self.orm_wrapper.get_update_recipe_object(recipe_information) + assert identifier in self.internal_state['taskdata'] + identifierlist = identifier.split(":") + realtaskfile = ":".join(identifierlist[0:len(identifierlist)-1]) + recipe_information = self._get_recipe_information_from_taskfile(realtaskfile) + recipe = self.orm_wrapper.get_update_recipe_object(recipe_information, True) task_information = self._get_task_information(event,recipe) task_information['start_time'] = self.internal_state['taskdata'][identifier]['start_time']