toaster: buildinfohelper toaster-custom-images layer
PATCH 1/1 toaster: buildinfohelper toaster-custom-images layer
This fixes the unidentified layers issue by making the toaster-custom-images layer a local layer. By doing this we also fix the git assumptions made for the local layers which stop recipes and other meta data being associated with them. This also removed some of the special casing previously needed when we didn't have the concept of a local (non git) layer.
[YOCTO #10220]
--- bitbake/lib/bb/ui/buildinfohelper.py | 7 +----- .../toaster/bldcontrol/localhostbecontroller.py | 25 ++++++++++++++++------ bitbake/lib/toaster/orm/models.py | 3 ++- bitbake/lib/toaster/toastergui/api.py | 5 +++-- 4 files changed, 24 insertions(+), 16 deletions(-)
bitbake/lib/bb/ui/buildinfohelper.py +1 -6
@@ -42,7 +42,7 @@ from orm.models import Variable, VariableHistory from orm.models import Package, Package_File, Target_Installed_Package, Target_File from orm.models import Task_Dependency, Package_Dependency from orm.models import Recipe_Dependency, Provides -from orm.models import Project, CustomImagePackage, CustomImageRecipe +from orm.models import Project, CustomImagePackage from orm.models import signal_runbuilds from bldcontrol.models import BuildEnvironment, BuildRequest
@@ -361,11 +361,6 @@ class ORMWrapper(object): def get_update_layer_version_object(self, build_obj, layer_obj, layer_version_information): if isinstance(layer_obj, Layer_Version): - # Special case the toaster-custom-images layer which is created - # on the fly so don't update the values which may cause the layer - # to be duplicated on a future get_or_create - if layer_obj.layer.name == CustomImageRecipe.LAYER_NAME: - return layer_obj # We already found our layer version for this build so just # update it with the new build information logger.debug("We found our layer from toaster")
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +18 -7
@@ -228,13 +228,22 @@ class LocalhostBEController(BuildEnvironmentController): br_layer_base_recipe = layers.get( layer_version=customrecipe.base_recipe.layer_version) - br_layer_base_dirpath = \ - os.path.join(self.be.sourcedir, - self.getGitCloneDirectory( - br_layer_base_recipe.giturl, - br_layer_base_recipe.commit), - customrecipe.base_recipe.layer_version.dirpath - ) + # If the layer is one that we've cloned we know where it lives + if br_layer_base_recipe.giturl and br_layer_base_recipe.commit: + layer_path = self.getGitCloneDirectory( + br_layer_base_recipe.giturl, + br_layer_base_recipe.commit) + # Otherwise it's a local layer + elif br_layer_base_recipe.local_source_dir: + layer_path = br_layer_base_recipe.local_source_dir + else: + logger.error("Unable to workout the dir path for the custom" + " image recipe") + + br_layer_base_dirpath = os.path.join( + self.be.sourcedir, + layer_path, + customrecipe.base_recipe.layer_version.dirpath) customrecipe.base_recipe.layer_version.dirpath = \ br_layer_base_dirpath
@@ -249,6 +258,8 @@ class LocalhostBEController(BuildEnvironmentController): # Update the layer and recipe objects customrecipe.layer_version.dirpath = layerpath + customrecipe.layer_version.layer.local_source_dir = layerpath + customrecipe.layer_version.layer.save() customrecipe.layer_version.save() customrecipe.file_path = recipe_path
bitbake/lib/toaster/orm/models.py +2 -1
@@ -1631,7 +1631,8 @@ class CustomImageRecipe(Recipe): if base_recipe_path: base_recipe = open(base_recipe_path, 'r').read() else: - raise IOError("Based on recipe file not found") + raise IOError("Based on recipe file not found: %s" % + base_recipe_path) # Add a special case for when the recipe we have based a custom image # recipe on requires another recipe.
bitbake/lib/toaster/toastergui/api.py +3 -2
@@ -293,8 +293,7 @@ class XhrCustomRecipe(View): # create layer 'Custom layer' and verion if needed layer = Layer.objects.get_or_create( name=CustomImageRecipe.LAYER_NAME, - summary="Layer for custom recipes", - vcs_url="file:///toaster_created_layer")[0] + summary="Layer for custom recipes")[0] # Check if we have a layer version already # We don't use get_or_create here because the dirpath will change
@@ -306,6 +305,8 @@ class XhrCustomRecipe(View): lver, created = Layer_Version.objects.get_or_create( project=params['project'], layer=layer, + layer_source=LayerSource.TYPE_LOCAL, + local_source_dir="toaster_created_layer", dirpath="toaster_created_layer") # Add a dependency on our layer to the base recipe's layer
Signature · 1 line
2.7.4
Hi,
I rebased on master and toaster next, but I'm afraid i may be missing a patch :(
When I hit "create custom image" in the dialog box. th ui hangs and I get the following error in toaster_web.log:
-----
2016-11-05 12:27:12,854 ERROR Internal Server Error:
/toastergui/xhr_customrecipe/
Traceback (most recent call last):
File
"/home/bavery/.local/lib/python3.4/site-packages/django/db/models/options.py", line 552, in get_field
return self.fields_map[field_name]
KeyError: 'local_source_dir'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"/home/bavery/.local/lib/python3.4/site-packages/django/db/models/sql/query.py", line 1368, in names_to_path
field = opts.get_field(name)
File
"/home/bavery/.local/lib/python3.4/site-packages/django/db/models/options.py", line 554, in get_field
raise FieldDoesNotExist('%s has no field named %r' % (self.object_name,field_name))
django.core.exceptions.FieldDoesNotExist: Layer_Version has no field named 'local_source_dir'
During handling of the above exception, another exception occurred:
-----
What did i miss? ,
-b
an intel employee
Quoted 147 lines · Michael Wood
This fixes the unidentified layers issue by making the toaster-custom-images layer a local layer. By doing this we also fix the git assumptions made for the local layers which stop recipes and other meta data being associated with them. This also removed some of the special casing previously needed when we didn't have the concept of a local (non git) layer.
[YOCTO #10220]
Signed-off-by Michael Wood <[email protected]>--- bitbake/lib/bb/ui/buildinfohelper.py | 7 +----- .../toaster/bldcontrol/localhostbecontroller.py | 25 ++++++++++++++++------ bitbake/lib/toaster/orm/models.py | 3 ++- bitbake/lib/toaster/toastergui/api.py | 5 +++-- 4 files changed, 24 insertions(+), 16 deletions(-)bitbake/lib/bb/ui/ renamed from bitbake/lib/bb/ui/buildinfohelper.py +0
-0
buildinfohelper.py
index 5b69660..6d87a4e 100644bitbake/lib/bb/ui/buildinfohelper.py +0
-0@@ -42,7 +42,7 @@ from orm.models import Variable, VariableHistory from orm.models import Package, Package_File, Target_Installed_Package,
Target_File
from orm.models importTask_Dependency,Package_Dependencyfrom orm.models importRecipe_Dependency, Providesbitbake/lib/bb/ui/buildinfohelper.py +1
-1-from orm.models import Project, CustomImagePackage, CustomImageRecipe +from orm.models import Project, CustomImagePackage from orm.models import signal_runbuilds from bldcontrol.models import BuildEnvironment, BuildRequest@@ -361,11 +361,6 @@ class ORMWrapper(object): def get_update_layer_version_object(self, build_obj, layer_obj,
layer_version_information):
ifisinstance(layer_obj, Layer_Version):
- # Special case the toaster-custom-images layer which is
created
- # on the fly so don't update the values which may cause the
layerbitbake/lib/bb/ui/buildinfohelper.py +0
-3- # to be duplicated on a future get_or_create - if layer_obj.layer.name == CustomImageRecipe.LAYER_NAME: - return layer_obj # We already found our layer version for this build so just # update it with the new build information logger.debug("We found our layer from toaster")bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +0
-0@@ -228,13 +228,22 @@ class LocalhostBEController(BuildEnvironmentController):
br_layer_base_recipe = layers.get( layer_version=customrecipe.base_recipe.layer_version)bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +0
-6- br_layer_base_dirpath = \ - os.path.join(self.be.sourcedir, - self.getGitCloneDirectory( - br_layer_base_recipe.giturl, - br_layer_base_recipe.commit), - customrecipe.base_recipe.layer_version.dirpath
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +2
-1- ) + # If the layer is one that we've cloned we know where it lives + if br_layer_base_recipe.giturl andbr_layer_base_recipe.commit:
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +8
-0+ layer_path = self.getGitCloneDirectory( + br_layer_base_recipe.giturl, + br_layer_base_recipe.commit) + # Otherwise it's a local layer + elif br_layer_base_recipe.local_source_dir: + layer_path = br_layer_base_recipe.local_source_dir + else: + logger.error("Unable to workout the dir path for thecustom"
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +6
-0+ " image recipe") + + br_layer_base_dirpath = os.path.join( + self.be.sourcedir, + layer_path, + customrecipe.base_recipe.layer_version.dirpath) customrecipe.base_recipe.layer_version.dirpath = \ br_layer_base_dirpath@@ -249,6 +258,8 @@ class LocalhostBEController(BuildEnvironmentController):
# Update the layer and recipe objects customrecipe.layer_version.dirpath = layerpath
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +2
-0+ customrecipe.layer_version.layer.local_source_dir = layerpath + customrecipe.layer_version.layer.save() customrecipe.layer_version.save() customrecipe.file_path = recipe_pathbitbake/lib/toaster/orm/ renamed from bitbake/lib/toaster/orm/models.py +0
-0
models.py
index 4f8510c..dad8246 100644bitbake/lib/toaster/orm/models.py +2
-1@@ -1631,7 +1631,8 @@ class CustomImageRecipe(Recipe): if base_recipe_path: base_recipe = open(base_recipe_path, 'r').read() else: - raise IOError("Based on recipe file not found") + raise IOError("Based on recipe file not found: %s" % + base_recipe_path) # Add a special case for when the recipe we have based a customimage
# recipe on requires another recipe.bitbake/lib/toaster/ renamed from bitbake/lib/toaster/toastergui/api.py +0
-0
toastergui/api.py
index ae1f150..f816fa4 100644bitbake/lib/toaster/toastergui/api.py +1
-2@@ -293,8 +293,7 @@ class XhrCustomRecipe(View): # create layer 'Custom layer' and verion if needed layer = Layer.objects.get_or_create( name=CustomImageRecipe.LAYER_NAME, - summary="Layer for custom recipes", - vcs_url="file:///toaster_created_layer")[0] + summary="Layer for custom recipes")[0] # Check if we have a layer version already # We don't use get_or_create here because the dirpath willchange
bitbake/lib/toaster/toastergui/api.py +2
-1@@ -306,6 +305,8 @@ class XhrCustomRecipe(View): lver, created = Layer_Version.objects.get_or_create( project=params['project'], layer=layer, + layer_source=LayerSource.TYPE_LOCAL, + local_source_dir="toaster_created_layer", dirpath="toaster_created_layer") # Add a dependency on our layer to the base recipe's layer --2.7.4
--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster