All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] toaster: custom image enable layer add, protect pre-cloned layers
@ 2018-10-04  6:10 David Reyna
  2018-10-04  6:10 ` [PATCH 1/1] " David Reyna
  0 siblings, 1 reply; 2+ messages in thread
From: David Reyna @ 2018-10-04  6:10 UTC (permalink / raw)
  To: bitbake-devel

From: David Reyna <David.Reyna@windriver.com>

Fix for Bug 12887:
* When attempting create a custom image in Toaster for a layer not yet added not cloned, two errors were found.
  1) The "Add layer" button did not do anything, due to a missing data structure, easily fixed
  2) If the layer was newly added but not yet cloned, the custom image create just hung. 
     This was because the problems were reported internally but not to the user. This patch adds
     the error return chain plus the helpful error recovery message to the user.

The following changes since commit bdb49647874e18e7d60374b8973a307551b36a14:

  go.bbclass: Add -buildmode=pie for non mips arch (2018-10-01 13:04:50 +0100)

are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib dreyna/toaster/custom_image_protection_12887
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=dreyna/toaster/custom_image_protection_12887

David Reyna (1):
  toaster: custom image enable layer add, protect pre-cloned layers

 lib/toaster/orm/models.py                                | 4 ++--
 lib/toaster/toastergui/api.py                            | 8 +++++++-
 lib/toaster/toastergui/static/js/libtoaster.js           | 3 ++-
 lib/toaster/toastergui/static/js/newcustomimage_modal.js | 7 +++++++
 lib/toaster/toastergui/templates/customise_btn.html      | 6 +++++-
 5 files changed, 23 insertions(+), 5 deletions(-)

-- 
1.9.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 1/1] toaster: custom image enable layer add, protect pre-cloned layers
  2018-10-04  6:10 [PATCH 0/1] toaster: custom image enable layer add, protect pre-cloned layers David Reyna
@ 2018-10-04  6:10 ` David Reyna
  0 siblings, 0 replies; 2+ messages in thread
From: David Reyna @ 2018-10-04  6:10 UTC (permalink / raw)
  To: bitbake-devel

From: David Reyna <David.Reyna@windriver.com>

When creating custom image recipes, the layer add for new layers
needs missing xhrLayerUrl data. Also, code is needed to check
and inform user if the newly added layer has not been cloned yet,
and provide helpful error message instead of the current frozen
dialog.

[YOCTO #12887]

Signed-off-by: David Reyna <David.Reyna@windriver.com>
---
 lib/toaster/orm/models.py                                | 4 ++--
 lib/toaster/toastergui/api.py                            | 8 +++++++-
 lib/toaster/toastergui/static/js/libtoaster.js           | 3 ++-
 lib/toaster/toastergui/static/js/newcustomimage_modal.js | 7 +++++++
 lib/toaster/toastergui/templates/customise_btn.html      | 6 +++++-
 5 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py
index be0bda5..849c22e 100644
--- a/lib/toaster/orm/models.py
+++ b/lib/toaster/orm/models.py
@@ -1750,8 +1750,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: %s" %
-                          base_recipe_path)
+            # Pass back None to trigger error message to user
+            return None
 
         # 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 1bec56d..564d595 100644
--- a/lib/toaster/toastergui/api.py
+++ b/lib/toaster/toastergui/api.py
@@ -677,7 +677,13 @@ class XhrCustomRecipe(View):
         recipe_path = os.path.join(layerpath, "recipes", "%s.bb" %
                                    recipe.name)
         with open(recipe_path, "w") as recipef:
-            recipef.write(recipe.generate_recipe_file_contents())
+            content = recipe.generate_recipe_file_contents()
+            if not content:
+                # Delete this incomplete image recipe object
+                recipe.delete()
+                return error_response("recipe-parent-not-exist")
+            else:
+                recipef.write(recipe.generate_recipe_file_contents())
 
         return JsonResponse(
             {"error": "ok",
diff --git a/lib/toaster/toastergui/static/js/libtoaster.js b/lib/toaster/toastergui/static/js/libtoaster.js
index 2e8863a..f2c45c8 100644
--- a/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/lib/toaster/toastergui/static/js/libtoaster.js
@@ -275,7 +275,8 @@ var libtoaster = (function () {
 
   function _addRmLayer(layerObj, add, doneCb){
     if (layerObj.xhrLayerUrl === undefined){
-      throw("xhrLayerUrl is undefined")
+      alert("ERROR: missing xhrLayerUrl object. Please file a bug.");
+      return;
     }
 
     if (add === true) {
diff --git a/lib/toaster/toastergui/static/js/newcustomimage_modal.js b/lib/toaster/toastergui/static/js/newcustomimage_modal.js
index dace8e3..e55fffc 100644
--- a/lib/toaster/toastergui/static/js/newcustomimage_modal.js
+++ b/lib/toaster/toastergui/static/js/newcustomimage_modal.js
@@ -25,6 +25,8 @@ function newCustomImageModalInit(){
   var duplicateNameMsg = "An image with this name already exists. Image names must be unique.";
   var duplicateImageInProjectMsg = "An image with this name already exists in this project."
   var invalidBaseRecipeIdMsg = "Please select an image to customise.";
+  var missingParentRecipe = "The parent recipe file was not found. Cancel this action, build any target (like 'quilt-native') to force all new layers to clone, and try again";
+  var unknownError = "Unexpected error: ";
 
   // set button to "submit" state and enable text entry so user can
   // enter the custom recipe name
@@ -62,6 +64,7 @@ function newCustomImageModalInit(){
     if (nameInput.val().length > 0) {
       libtoaster.createCustomRecipe(nameInput.val(), baseRecipeId,
       function(ret) {
+        showSubmitState();
         if (ret.error !== "ok") {
           console.warn(ret.error);
           if (ret.error === "invalid-name") {
@@ -73,6 +76,10 @@ function newCustomImageModalInit(){
           } else if (ret.error === "image-already-exists") {
             showNameError(duplicateImageInProjectMsg);
             return;
+          } else if (ret.error === "recipe-parent-not-exist") {
+            showNameError(missingParentRecipe);
+          } else {
+            showNameError(unknownError + ret.error);
           }
         } else {
           imgCustomModal.modal('hide');
diff --git a/lib/toaster/toastergui/templates/customise_btn.html b/lib/toaster/toastergui/templates/customise_btn.html
index 38c258a..ce46240 100644
--- a/lib/toaster/toastergui/templates/customise_btn.html
+++ b/lib/toaster/toastergui/templates/customise_btn.html
@@ -5,7 +5,11 @@
   >
   Customise
 </button>
-<button class="btn btn-default btn-block layer-add-{{data.layer_version.pk}} layerbtn" data-layer='{ "id": {{data.layer_version.pk}}, "name":  "{{data.layer_version.layer.name}}", "layerdetailurl": "{%url 'layerdetails' extra.pid data.layer_version.pk%}"}' data-directive="add"
+<button class="btn btn-default btn-block layer-add-{{data.layer_version.pk}} layerbtn"
+    data-layer='{ "id": {{data.layer_version.pk}}, "name":  "{{data.layer_version.layer.name}}",
+      "layerdetailurl": "{%url 'layerdetails' extra.pid data.layer_version.pk%}",
+      "xhrLayerUrl": "{% url "xhr_layer" extra.pid data.layer_version.pk %}"}'
+    data-directive="add"
     {% if data.layer_version.pk in extra.current_layers %}
     style="display:none;"
     {% endif %}
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-04  6:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-04  6:10 [PATCH 0/1] toaster: custom image enable layer add, protect pre-cloned layers David Reyna
2018-10-04  6:10 ` [PATCH 1/1] " David Reyna

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.