diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-05-14 16:10:50 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-05-29 11:59:43 +0100 |
commit | e3e85bdf7100cc5619d7f184dc8d9e2a77a03364 (patch) | |
tree | a3dcc4abf6973288c0001e7498f8270d6fccdb7e /bitbake/lib/bb/ui | |
parent | a5236be47fd62d41eaea2d4b4f1a394de0aac4a9 (diff) | |
download | poky-e3e85bdf7100cc5619d7f184dc8d9e2a77a03364.tar.gz |
bitbake: toaster logger: refactor recipe and layer file paths
This refactoring brings the "local_path" of the
layer from the Layer object to the Layer_Version object, which
is more appropriate as different checkouts of the same
Layer may live in different directories.
This enables us to store Recipe file paths relative to a Layer_Version
at all times, aleviating the need to store full file paths in the
database. We also turn the prefix of the path (e.g. virtual:native
path name space) into a pathflag field.
In turn, this solves the problem of mis-identification of tasks based
on the recipe file paths, since we can also match the namespace of the
file paths on the recipe files.
[YOCTO #7594]
(Bitbake rev: ec43dc569e370767c709dec225cbee0c99151c19)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui')
-rw-r--r-- | bitbake/lib/bb/ui/buildinfohelper.py | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py index 647d663cb5..6812a52b7b 100644 --- a/bitbake/lib/bb/ui/buildinfohelper.py +++ b/bitbake/lib/bb/ui/buildinfohelper.py | |||
@@ -221,12 +221,12 @@ class ORMWrapper(object): | |||
221 | def get_update_recipe_object(self, recipe_information, must_exist = False): | 221 | def get_update_recipe_object(self, recipe_information, must_exist = False): |
222 | assert 'layer_version' in recipe_information | 222 | assert 'layer_version' in recipe_information |
223 | assert 'file_path' in recipe_information | 223 | assert 'file_path' in recipe_information |
224 | assert 'pathflags' in recipe_information | ||
224 | 225 | ||
225 | if recipe_information['file_path'].startswith(recipe_information['layer_version'].layer.local_path): | 226 | assert not recipe_information['file_path'].startswith("/") # we should have layer-relative paths at all times |
226 | recipe_information['file_path'] = recipe_information['file_path'][len(recipe_information['layer_version'].layer.local_path):].lstrip("/") | ||
227 | 227 | ||
228 | recipe_object, created = self._cached_get_or_create(Recipe, layer_version=recipe_information['layer_version'], | 228 | recipe_object, created = self._cached_get_or_create(Recipe, layer_version=recipe_information['layer_version'], |
229 | file_path=recipe_information['file_path']) | 229 | file_path=recipe_information['file_path'], pathflags = recipe_information['pathflags']) |
230 | if created and must_exist: | 230 | if created and must_exist: |
231 | raise NotExisting("Recipe object created when expected to exist", recipe_information) | 231 | raise NotExisting("Recipe object created when expected to exist", recipe_information) |
232 | 232 | ||
@@ -247,13 +247,15 @@ class ORMWrapper(object): | |||
247 | assert 'branch' in layer_version_information | 247 | assert 'branch' in layer_version_information |
248 | assert 'commit' in layer_version_information | 248 | assert 'commit' in layer_version_information |
249 | assert 'priority' in layer_version_information | 249 | assert 'priority' in layer_version_information |
250 | assert 'local_path' in layer_version_information | ||
250 | 251 | ||
251 | layer_version_object, created = Layer_Version.objects.get_or_create( | 252 | layer_version_object, created = Layer_Version.objects.get_or_create( |
252 | build = build_obj, | 253 | build = build_obj, |
253 | layer = layer_obj, | 254 | layer = layer_obj, |
254 | branch = layer_version_information['branch'], | 255 | branch = layer_version_information['branch'], |
255 | commit = layer_version_information['commit'], | 256 | commit = layer_version_information['commit'], |
256 | priority = layer_version_information['priority'] | 257 | priority = layer_version_information['priority'], |
258 | local_path = layer_version_information['local_path'], | ||
257 | ) | 259 | ) |
258 | 260 | ||
259 | self.layer_version_objects.append(layer_version_object) | 261 | self.layer_version_objects.append(layer_version_object) |
@@ -262,13 +264,11 @@ class ORMWrapper(object): | |||
262 | 264 | ||
263 | def get_update_layer_object(self, layer_information, brbe): | 265 | def get_update_layer_object(self, layer_information, brbe): |
264 | assert 'name' in layer_information | 266 | assert 'name' in layer_information |
265 | assert 'local_path' in layer_information | ||
266 | assert 'layer_index_url' in layer_information | 267 | assert 'layer_index_url' in layer_information |
267 | 268 | ||
268 | if brbe is None: | 269 | if brbe is None: |
269 | layer_object, created = Layer.objects.get_or_create( | 270 | layer_object, created = Layer.objects.get_or_create( |
270 | name=layer_information['name'], | 271 | name=layer_information['name'], |
271 | local_path=layer_information['local_path'], | ||
272 | layer_index_url=layer_information['layer_index_url']) | 272 | layer_index_url=layer_information['layer_index_url']) |
273 | return layer_object | 273 | return layer_object |
274 | else: | 274 | else: |
@@ -297,7 +297,6 @@ class ORMWrapper(object): | |||
297 | for pl in buildrequest.project.projectlayer_set.filter(layercommit__layer__name = brl.name): | 297 | for pl in buildrequest.project.projectlayer_set.filter(layercommit__layer__name = brl.name): |
298 | if pl.layercommit.layer.vcs_url == brl.giturl : | 298 | if pl.layercommit.layer.vcs_url == brl.giturl : |
299 | layer = pl.layercommit.layer | 299 | layer = pl.layercommit.layer |
300 | layer.local_path = layer_information['local_path'] | ||
301 | layer.save() | 300 | layer.save() |
302 | return layer | 301 | return layer |
303 | 302 | ||
@@ -687,12 +686,12 @@ class BuildInfoHelper(object): | |||
687 | if self.brbe is None: | 686 | if self.brbe is None: |
688 | def _slkey_interactive(layer_version): | 687 | def _slkey_interactive(layer_version): |
689 | assert isinstance(layer_version, Layer_Version) | 688 | assert isinstance(layer_version, Layer_Version) |
690 | return len(layer_version.layer.local_path) | 689 | return len(layer_version.local_path) |
691 | 690 | ||
692 | # Heuristics: we always match recipe to the deepest layer path in the discovered layers | 691 | # Heuristics: we always match recipe to the deepest layer path in the discovered layers |
693 | for lvo in sorted(self.orm_wrapper.layer_version_objects, reverse=True, key=_slkey_interactive): | 692 | for lvo in sorted(self.orm_wrapper.layer_version_objects, reverse=True, key=_slkey_interactive): |
694 | # we can match to the recipe file path | 693 | # we can match to the recipe file path |
695 | if path.startswith(lvo.layer.local_path): | 694 | if path.startswith(lvo.local_path): |
696 | return lvo | 695 | return lvo |
697 | 696 | ||
698 | else: | 697 | else: |
@@ -721,7 +720,7 @@ class BuildInfoHelper(object): | |||
721 | logger.warn("Could not match layer version for recipe path %s : %s" % (path, self.orm_wrapper.layer_version_objects)) | 720 | logger.warn("Could not match layer version for recipe path %s : %s" % (path, self.orm_wrapper.layer_version_objects)) |
722 | 721 | ||
723 | #mockup the new layer | 722 | #mockup the new layer |
724 | unknown_layer, created = Layer.objects.get_or_create(name="__FIXME__unidentified_layer", local_path="/", layer_index_url="") | 723 | unknown_layer, created = Layer.objects.get_or_create(name="__FIXME__unidentified_layer", layer_index_url="") |
725 | unknown_layer_version_obj, created = Layer_Version.objects.get_or_create(layer = unknown_layer, build = self.internal_state['build']) | 724 | unknown_layer_version_obj, created = Layer_Version.objects.get_or_create(layer = unknown_layer, build = self.internal_state['build']) |
726 | 725 | ||
727 | # append it so we don't run into this error again and again | 726 | # append it so we don't run into this error again and again |
@@ -731,11 +730,20 @@ class BuildInfoHelper(object): | |||
731 | 730 | ||
732 | def _get_recipe_information_from_taskfile(self, taskfile): | 731 | def _get_recipe_information_from_taskfile(self, taskfile): |
733 | localfilepath = taskfile.split(":")[-1] | 732 | localfilepath = taskfile.split(":")[-1] |
733 | filepath_flags = ":".join(sorted(taskfile.split(":")[:-1])) | ||
734 | layer_version_obj = self._get_layer_version_for_path(localfilepath) | 734 | layer_version_obj = self._get_layer_version_for_path(localfilepath) |
735 | 735 | ||
736 | |||
737 | |||
736 | recipe_info = {} | 738 | recipe_info = {} |
737 | recipe_info['layer_version'] = layer_version_obj | 739 | recipe_info['layer_version'] = layer_version_obj |
738 | recipe_info['file_path'] = taskfile | 740 | recipe_info['file_path'] = localfilepath |
741 | recipe_info['pathflags'] = filepath_flags | ||
742 | |||
743 | if recipe_info['file_path'].startswith(recipe_info['layer_version'].local_path): | ||
744 | recipe_info['file_path'] = recipe_info['file_path'][len(recipe_info['layer_version'].local_path):].lstrip("/") | ||
745 | else: | ||
746 | raise RuntimeError("Recipe file path %s is not under layer version at %s" % (recipe_info['file_path'], recipe_info['layer_version'].local_path)) | ||
739 | 747 | ||
740 | return recipe_info | 748 | return recipe_info |
741 | 749 | ||
@@ -787,6 +795,7 @@ class BuildInfoHelper(object): | |||
787 | for layer in layerinfos: | 795 | for layer in layerinfos: |
788 | try: | 796 | try: |
789 | self.internal_state['lvs'][self.orm_wrapper.get_update_layer_object(layerinfos[layer], self.brbe)] = layerinfos[layer]['version'] | 797 | self.internal_state['lvs'][self.orm_wrapper.get_update_layer_object(layerinfos[layer], self.brbe)] = layerinfos[layer]['version'] |
798 | self.internal_state['lvs'][self.orm_wrapper.get_update_layer_object(layerinfos[layer], self.brbe)]['local_path'] = layerinfos[layer]['local_path'] | ||
790 | except NotExisting as nee: | 799 | except NotExisting as nee: |
791 | logger.warn("buildinfohelper: cannot identify layer exception:%s " % nee) | 800 | logger.warn("buildinfohelper: cannot identify layer exception:%s " % nee) |
792 | 801 | ||
@@ -899,8 +908,8 @@ class BuildInfoHelper(object): | |||
899 | 908 | ||
900 | recipe_information = self._get_recipe_information_from_taskfile(taskfile) | 909 | recipe_information = self._get_recipe_information_from_taskfile(taskfile) |
901 | try: | 910 | try: |
902 | if recipe_information['file_path'].startswith(recipe_information['layer_version'].layer.local_path): | 911 | if recipe_information['file_path'].startswith(recipe_information['layer_version'].local_path): |
903 | recipe_information['file_path'] = recipe_information['file_path'][len(recipe_information['layer_version'].layer.local_path):].lstrip("/") | 912 | recipe_information['file_path'] = recipe_information['file_path'][len(recipe_information['layer_version'].local_path):].lstrip("/") |
904 | 913 | ||
905 | recipe_object = Recipe.objects.get(layer_version = recipe_information['layer_version'], | 914 | recipe_object = Recipe.objects.get(layer_version = recipe_information['layer_version'], |
906 | file_path__endswith = recipe_information['file_path'], | 915 | file_path__endswith = recipe_information['file_path'], |
@@ -1051,8 +1060,9 @@ class BuildInfoHelper(object): | |||
1051 | self.internal_state['recipes'] = {} | 1060 | self.internal_state['recipes'] = {} |
1052 | for pn in event._depgraph['pn']: | 1061 | for pn in event._depgraph['pn']: |
1053 | 1062 | ||
1054 | file_name = event._depgraph['pn'][pn]['filename'] | 1063 | file_name = event._depgraph['pn'][pn]['filename'].split(":")[-1] |
1055 | layer_version_obj = self._get_layer_version_for_path(file_name.split(":")[-1]) | 1064 | pathflags = ":".join(sorted(event._depgraph['pn'][pn]['filename'].split(":")[:-1])) |
1065 | layer_version_obj = self._get_layer_version_for_path(file_name) | ||
1056 | 1066 | ||
1057 | assert layer_version_obj is not None | 1067 | assert layer_version_obj is not None |
1058 | 1068 | ||
@@ -1082,6 +1092,13 @@ class BuildInfoHelper(object): | |||
1082 | recipe_info['bugtracker'] = event._depgraph['pn'][pn]['bugtracker'] | 1092 | recipe_info['bugtracker'] = event._depgraph['pn'][pn]['bugtracker'] |
1083 | 1093 | ||
1084 | recipe_info['file_path'] = file_name | 1094 | recipe_info['file_path'] = file_name |
1095 | recipe_info['pathflags'] = pathflags | ||
1096 | |||
1097 | if recipe_info['file_path'].startswith(recipe_info['layer_version'].local_path): | ||
1098 | recipe_info['file_path'] = recipe_info['file_path'][len(recipe_info['layer_version'].local_path):].lstrip("/") | ||
1099 | else: | ||
1100 | raise RuntimeError("Recipe file path %s is not under layer version at %s" % (recipe_info['file_path'], recipe_info['layer_version'].local_path)) | ||
1101 | |||
1085 | recipe = self.orm_wrapper.get_update_recipe_object(recipe_info) | 1102 | recipe = self.orm_wrapper.get_update_recipe_object(recipe_info) |
1086 | recipe.is_image = False | 1103 | recipe.is_image = False |
1087 | if 'inherits' in event._depgraph['pn'][pn].keys(): | 1104 | if 'inherits' in event._depgraph['pn'][pn].keys(): |