Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id F3CEFE00CE0; Mon, 21 Nov 2016 06:55:32 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no * trust * [74.125.83.53 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-pg0-f53.google.com (mail-pg0-f53.google.com [74.125.83.53]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id AE5E1E00CE1 for ; Mon, 21 Nov 2016 06:55:29 -0800 (PST) Received: by mail-pg0-f53.google.com with SMTP id f188so130911419pgc.3 for ; Mon, 21 Nov 2016 06:55:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GOenspjjjMF+jBqbYXvTYD3XCb4lyXYa6O/7gigFRww=; b=2DN2tOhyX2IDEZ3v2/tP6VV7QGAAjJelIl2y2XSzf9pNfkn+H4dgtAterSMM9WBMeI WArcUwgoHCLui45Zh4v08vq+aOZzIwcdiOxk+frmhmCjpE9EeRvg8LGfGyVglZsj3YCQ 7OnawnjH/HVXtPgamgSTUWcznDD4TvRL1pgDiGBPNk4lLP2W7MiBClg0N6M5mLQnRLZj zW1d+dctVjKjHQWe8ZMNL49ZmHZ0J2njSUdCf69BPUyZChJfh5i8Qi9w4yKdS7Fm8Qs8 gatIVudxkKKr2x5042ArSgft3tykfLXJ3FrL/Xq9N4bctNqw8e3hclFcfeqj8iKW5Tzg x/Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GOenspjjjMF+jBqbYXvTYD3XCb4lyXYa6O/7gigFRww=; b=WZMyoQmE47wtkxqzUBUwJTDJBi/z6M5revB5Nk5WNqj2+y2VOxkpfzJaZDorw3DI/S cHNMO7T9KJBT82x+2KJAg5SRuTF7V1ngJhEbv0NedFGUNigN/JOtGgdaIeLMM/Ywqzvs 61PwKWn411MFg/F/gJbdyMe5IioWNcOYFKGeFtkk5gesmxANDa0WlkxC3S9pwlLuyH5u M1wr9e+7O0BrwFCe+NcZz5TCFI7IucBZkVDA8m7LkIfyrC7ixtUM/WgXbJ1vwoFDgDkP oQeIzkFAnWwojF9lZhwSpXRca7S6UNTj//XAfnwmvE5+LWs+1JFjfhj7AUcdJp1v57Lf AvRg== X-Gm-Message-State: AKaTC00Vty3UW19U3YC21mQaxQ06UZNo3vSdDWTu3FcZRw2RIOgDxb32xsCjCmfdZuX2nG1E X-Received: by 10.99.204.81 with SMTP id q17mr33145884pgi.168.1479740128781; Mon, 21 Nov 2016 06:55:28 -0800 (PST) Received: from orion.ger.corp.intel.com ([192.55.54.44]) by smtp.gmail.com with ESMTPSA id n25sm38332994pfi.33.2016.11.21.06.55.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Nov 2016 06:55:28 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Mon, 21 Nov 2016 14:55:12 +0000 Message-Id: <1479740115-5985-5-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479740115-5985-1-git-send-email-michael.g.wood@intel.com> References: <1479740115-5985-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 4/7] toaster: bldcontrol Move CustomImageRecipe file creation into own function 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: Mon, 21 Nov 2016 14:55:33 -0000 Move the custom image file creation (i.e. create the layer file structure, conf and recipe file) into it's own function and remove the creation of the BRLayer as this is done at schedule_build just like all the other layers. Fix a bug where the toaster-custom-images layer was always being appened to the layer list if the directory exists. Signed-off-by: Michael Wood --- .../toaster/bldcontrol/localhostbecontroller.py | 144 +++++++++++---------- 1 file changed, 75 insertions(+), 69 deletions(-) diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py index 7d90999..cb0ad24 100644 --- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py @@ -201,82 +201,88 @@ class LocalhostBEController(BuildEnvironmentController): logger.debug("localhostbecontroller: current layer list %s " % pformat(layerlist)) # 5. create custom layer and add custom recipes to it - layerpath = os.path.join(self.be.builddir, - CustomImageRecipe.LAYER_NAME) for target in targets: try: - customrecipe = CustomImageRecipe.objects.get(name=target.target, - project=bitbake.req.project) + customrecipe = CustomImageRecipe.objects.get( + name=target.target, + project=bitbake.req.project) + + custom_layer_path = self.setup_custom_image_recipe( + customrecipe, layers) + + if os.path.isdir(custom_layer_path): + layerlist.append(custom_layer_path) + except CustomImageRecipe.DoesNotExist: - continue # not a custom recipe, skip - - # create directory structure - for name in ("conf", "recipes"): - path = os.path.join(layerpath, name) - if not os.path.isdir(path): - os.makedirs(path) - - # create layer.oonf - config = os.path.join(layerpath, "conf", "layer.conf") - if not os.path.isfile(config): - with open(config, "w") as conf: - conf.write('BBPATH .= ":${LAYERDIR}"\nBBFILES += "${LAYERDIR}/recipes/*.bb"\n') - - # Update the Layer_Version dirpath that has our base_recipe in - # to be able to read the base recipe to then generate the - # custom recipe. - br_layer_base_recipe = layers.get( - layer_version=customrecipe.base_recipe.layer_version) - - # 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 - - customrecipe.base_recipe.layer_version.save() - - # create recipe - recipe_path = \ - os.path.join(layerpath, "recipes", "%s.bb" % target.target) - with open(recipe_path, "w") as recipef: - recipef.write(customrecipe.generate_recipe_file_contents()) - - # 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 - customrecipe.save() - - # create *Layer* objects needed for build machinery to work - BRLayer.objects.get_or_create(req=target.req, - name=layer.name, - dirpath=layerpath, - giturl="file://%s" % layerpath) - if os.path.isdir(layerpath): - layerlist.append(layerpath) + continue # not a custom recipe, skip - self.islayerset = True layerlist.extend(nongitlayerlist) + logger.debug("\n\nset layers gives this list \n %s" % ''.join(layerlist)) + self.islayerset = True return layerlist + def setup_custom_image_recipe(self, customrecipe, layers): + """ Set up toaster-custom-images layer and recipe files """ + layerpath = os.path.join(self.be.builddir, + CustomImageRecipe.LAYER_NAME) + + # create directory structure + for name in ("conf", "recipes"): + path = os.path.join(layerpath, name) + if not os.path.isdir(path): + os.makedirs(path) + + # create layer.conf + config = os.path.join(layerpath, "conf", "layer.conf") + if not os.path.isfile(config): + with open(config, "w") as conf: + conf.write('BBPATH .= ":${LAYERDIR}"\nBBFILES += "${LAYERDIR}/recipes/*.bb"\n') + + # Update the Layer_Version dirpath that has our base_recipe in + # to be able to read the base recipe to then generate the + # custom recipe. + br_layer_base_recipe = layers.get( + layer_version=customrecipe.base_recipe.layer_version) + + # 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 + + customrecipe.base_recipe.layer_version.save() + + # create recipe + recipe_path = os.path.join(layerpath, "recipes", "%s.bb" % + customrecipe.name) + with open(recipe_path, "w") as recipef: + recipef.write(customrecipe.generate_recipe_file_contents()) + + # 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 + customrecipe.save() + + return layerpath + + def readServerLogFile(self): return open(os.path.join(self.be.builddir, "toaster_server.log"), "r").read() -- 2.7.4