summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-09-28 21:45:30 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-29 14:11:38 +0100
commite6d967dba254a9d2a53d8b5b9469ac6b672fb1b9 (patch)
tree1d609eea94fe72004a94cd39d2e3d6fafec4f159 /bitbake
parent17fe16bbf4e375f941c44bcef2a205cf2ee6118f (diff)
downloadpoky-e6d967dba254a9d2a53d8b5b9469ac6b672fb1b9.tar.gz
bitbake: toaster: buildinfohelper Create a copy of the built layer and recipe
Create a copy of the built layer and the recipes associated with it. This is so that the user can view the historical information about a build. i.e. a snapshot of the layer version and artifacts produced at that build. (Bitbake rev: 0683d9a2b15e3234a94437aaebac84bfcca1420b) 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 'bitbake')
-rw-r--r--bitbake/lib/bb/ui/buildinfohelper.py54
-rw-r--r--bitbake/lib/toaster/orm/models.py2
2 files changed, 42 insertions, 14 deletions
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index d0efaa9778..e036ef6dbc 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -66,6 +66,7 @@ class ORMWrapper(object):
66 66
67 def __init__(self): 67 def __init__(self):
68 self.layer_version_objects = [] 68 self.layer_version_objects = []
69 self.layer_version_built = []
69 self.task_objects = {} 70 self.task_objects = {}
70 self.recipe_objects = {} 71 self.recipe_objects = {}
71 72
@@ -254,32 +255,59 @@ class ORMWrapper(object):
254 255
255 assert not recipe_information['file_path'].startswith("/") # we should have layer-relative paths at all times 256 assert not recipe_information['file_path'].startswith("/") # we should have layer-relative paths at all times
256 257
257 recipe_object, created = self._cached_get_or_create(Recipe, layer_version=recipe_information['layer_version'], 258
259 def update_recipe_obj(recipe_object):
260 object_changed = False
261 for v in vars(recipe_object):
262 if v in recipe_information.keys():
263 object_changed = True
264 vars(recipe_object)[v] = recipe_information[v]
265
266 if object_changed:
267 recipe_object.save()
268
269 recipe, created = self._cached_get_or_create(Recipe, layer_version=recipe_information['layer_version'],
258 file_path=recipe_information['file_path'], pathflags = recipe_information['pathflags']) 270 file_path=recipe_information['file_path'], pathflags = recipe_information['pathflags'])
259 if created and must_exist:
260 raise NotExisting("Recipe object created when expected to exist", recipe_information)
261 271
262 object_changed = False 272 update_recipe_obj(recipe)
263 for v in vars(recipe_object):
264 if v in recipe_information.keys():
265 object_changed = True
266 vars(recipe_object)[v] = recipe_information[v]
267 273
268 if object_changed: 274 # Create a copy of the recipe for historical puposes and update it
269 recipe_object.save() 275 for built_layer in self.layer_version_built:
276 if built_layer.layer == recipe_information['layer_version'].layer:
277 built_recipe, c = self._cached_get_or_create(Recipe,
278 layer_version=built_layer,
279 file_path=recipe_information['file_path'],
280 pathflags = recipe_information['pathflags'])
281 update_recipe_obj(built_recipe)
282 break
270 283
271 return recipe_object 284
285
286 if created and must_exist:
287 raise NotExisting("Recipe object created when expected to exist", recipe_information)
288
289 return recipe
272 290
273 def get_update_layer_version_object(self, build_obj, layer_obj, layer_version_information): 291 def get_update_layer_version_object(self, build_obj, layer_obj, layer_version_information):
274 if isinstance(layer_obj, Layer_Version): 292 if isinstance(layer_obj, Layer_Version):
275 # We already found our layer version for this build so just 293 # We already found our layer version for this build so just
276 # update it with the new build information 294 # update it with the new build information
277 logger.debug("We found our layer from toaster") 295 logger.debug("We found our layer from toaster")
278 layer_obj.build = build_obj
279 layer_obj.local_path = layer_version_information['local_path'] 296 layer_obj.local_path = layer_version_information['local_path']
280 layer_obj.commit = layer_version_information['commit']
281 layer_obj.save() 297 layer_obj.save()
282 self.layer_version_objects.append(layer_obj) 298 self.layer_version_objects.append(layer_obj)
299
300 # create a new copy of this layer version as a snapshot for
301 # historical purposes
302 layer_copy, c = Layer_Version.objects.get_or_create(build=build_obj,
303 layer=layer_obj.layer,
304 commit=layer_version_information['commit'],
305 local_path = layer_version_information['local_path'],
306 )
307 logger.warning("created new historical layer version %d", layer_copy.pk)
308
309 self.layer_version_built.append(layer_copy)
310
283 return layer_obj 311 return layer_obj
284 312
285 assert isinstance(build_obj, Build) 313 assert isinstance(build_obj, Build)
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index e0b31a92c4..9a052bf7a0 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -194,7 +194,7 @@ class Project(models.Model):
194 if release == None: 194 if release == None:
195 release = self.release 195 release = self.release
196 # layers on the same branch or layers specifically set for this project 196 # layers on the same branch or layers specifically set for this project
197 queryset = Layer_Version.objects.filter((Q(up_branch__name = release.branch_name) & Q(project = None)) | Q(project = self) | Q(build__project = self)) 197 queryset = Layer_Version.objects.filter(((Q(up_branch__name = release.branch_name) & Q(project = None)) | Q(project = self)) & Q(build__isnull=True))
198 198
199 if layer_name is not None: 199 if layer_name is not None:
200 # we select only a layer name 200 # we select only a layer name