summaryrefslogtreecommitdiffstats
path: root/lib/toaster
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-11-24 11:20:00 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-11-30 15:47:46 +0000
commitba5332d4960d7f4f79aef63136796e2fa67284e3 (patch)
tree72b641dadf021625a4b62febed06d889e8ac63fa /lib/toaster
parentf3e99d820f3798869a2a1d1604709c1c324dbbab (diff)
downloadbitbake-contrib-ba5332d4960d7f4f79aef63136796e2fa67284e3.tar.gz
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. Also rename created flag var to a have a different var for each returned value so that the same value isn't used multiple times. [YOCTO #10220] Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/toaster')
-rw-r--r--lib/toaster/bldcontrol/localhostbecontroller.py25
-rw-r--r--lib/toaster/orm/models.py3
-rw-r--r--lib/toaster/toastergui/api.py16
3 files changed, 30 insertions, 14 deletions
diff --git a/lib/toaster/bldcontrol/localhostbecontroller.py b/lib/toaster/bldcontrol/localhostbecontroller.py
index 11335ac39..18870d961 100644
--- a/lib/toaster/bldcontrol/localhostbecontroller.py
+++ b/lib/toaster/bldcontrol/localhostbecontroller.py
@@ -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
diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py
index b24e9c549..fd15fbe7b 100644
--- a/lib/toaster/orm/models.py
+++ b/lib/toaster/orm/models.py
@@ -1636,7 +1636,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.
diff --git a/lib/toaster/toastergui/api.py b/lib/toaster/toastergui/api.py
index ae1f15077..4851047bf 100644
--- a/lib/toaster/toastergui/api.py
+++ b/lib/toaster/toastergui/api.py
@@ -291,10 +291,13 @@ class XhrCustomRecipe(View):
return error_response("recipe-already-exists")
# create layer 'Custom layer' and verion if needed
- layer = Layer.objects.get_or_create(
+ layer, l_created = 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")
+
+ if l_created:
+ layer.local_source_dir = "toaster_created_layer"
+ layer.save()
# Check if we have a layer version already
# We don't use get_or_create here because the dirpath will change
@@ -303,9 +306,10 @@ class XhrCustomRecipe(View):
Q(layer=layer) &
Q(build=None)).last()
if lver is None:
- lver, created = Layer_Version.objects.get_or_create(
+ lver, lv_created = Layer_Version.objects.get_or_create(
project=params['project'],
layer=layer,
+ layer_source=LayerSource.TYPE_LOCAL,
dirpath="toaster_created_layer")
# Add a dependency on our layer to the base recipe's layer
@@ -319,7 +323,7 @@ class XhrCustomRecipe(View):
optional=False)
# Create the actual recipe
- recipe, created = CustomImageRecipe.objects.get_or_create(
+ recipe, r_created = CustomImageRecipe.objects.get_or_create(
name=request.POST["name"],
base_recipe=params["base"],
project=params["project"],
@@ -329,7 +333,7 @@ class XhrCustomRecipe(View):
# If we created the object then setup these fields. They may get
# overwritten later on and cause the get_or_create to create a
# duplicate if they've changed.
- if created:
+ if r_created:
recipe.file_path = request.POST["name"]
recipe.license = "MIT"
recipe.version = "0.1"