From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 38415E00B23; Wed, 3 Oct 2018 22:59:35 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [147.11.1.11 listed in list.dnswl.org] Received: from mail.windriver.com (mail.windriver.com [147.11.1.11]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 56BABE00ADD for ; Wed, 3 Oct 2018 22:59:34 -0700 (PDT) Received: from ALA-HCA.corp.ad.wrs.com ([147.11.189.40]) by mail.windriver.com (8.15.2/8.15.1) with ESMTPS id w945xX8i019853 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL) for ; Wed, 3 Oct 2018 22:59:33 -0700 (PDT) Received: from ala-dreyna-lx3.corp.ad.wrs.com (147.11.157.217) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 3 Oct 2018 22:59:33 -0700 From: David Reyna To: Date: Wed, 3 Oct 2018 22:56:23 -0700 Message-ID: <1538632583-20497-1-git-send-email-david.reyna@windriver.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [147.11.157.217] Subject: [PATCH] toaster: custom image enable layer add, protect pre-cloned layers X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Oct 2018 05:59:35 -0000 Content-Type: text/plain From: David Reyna 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 --- bitbake/lib/toaster/orm/models.py | 4 ++-- bitbake/lib/toaster/toastergui/api.py | 8 +++++++- bitbake/lib/toaster/toastergui/static/js/libtoaster.js | 3 ++- bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js | 7 +++++++ bitbake/lib/toaster/toastergui/templates/customise_btn.html | 6 +++++- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index be0bda5..849c22e 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/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/bitbake/lib/toaster/toastergui/api.py b/bitbake/lib/toaster/toastergui/api.py index 1bec56d..564d595 100644 --- a/bitbake/lib/toaster/toastergui/api.py +++ b/bitbake/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/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js index 2e8863a..96aaf19 100644 --- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js +++ b/bitbake/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/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js b/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js index dace8e3..e55fffc 100644 --- a/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js +++ b/bitbake/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/bitbake/lib/toaster/toastergui/templates/customise_btn.html b/bitbake/lib/toaster/toastergui/templates/customise_btn.html index 38c258a..c75e629 100644 --- a/bitbake/lib/toaster/toastergui/templates/customise_btn.html +++ b/bitbake/lib/toaster/toastergui/templates/customise_btn.html @@ -5,7 +5,11 @@ > Customise -