]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake: toaster: custom image enable layer add, protect pre-cloned layers
authorDavid Reyna <David.Reyna@windriver.com>
Thu, 4 Oct 2018 06:10:51 +0000 (23:10 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 4 Oct 2018 22:00:24 +0000 (23:00 +0100)
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]

(Bitbake rev: b310031972a53d0881a87a627f07bdcf7d9c6b79)

Signed-off-by: David Reyna <David.Reyna@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/toaster/orm/models.py
bitbake/lib/toaster/toastergui/api.py
bitbake/lib/toaster/toastergui/static/js/libtoaster.js
bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js
bitbake/lib/toaster/toastergui/templates/customise_btn.html

index be0bda5b153c90b503edbe6a3d287ceaad37cb16..849c22eede45de837ab2a81a19034a8e4e7d3e54 100644 (file)
@@ -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.
index 1bec56d468a00dcdca273386530401be5ce41fc9..564d595a1cdd4ea996db947fe9dc05fe12ec7cb3 100644 (file)
@@ -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",
index 2e8863af26c0840afe0555a3275c45b36eddba3f..f2c45c833e77d8fb22850b7ba5a7a1464750e77e 100644 (file)
@@ -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) {
index dace8e3258d25051aac25673e35492dc5a899e21..e55fffcef5b1f854d912981023c31cd66136c522 100644 (file)
@@ -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');
index 38c258ac32ebad2e529c4dfe8a4d6101bc0c9f7b..ce462401c7a007327f5bdbf845973c7e4c4cb318 100644 (file)
@@ -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 %}