From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 331D0E00FC5; Fri, 25 Sep 2015 11:07:48 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.212.170 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id E857EE00FB7 for ; Fri, 25 Sep 2015 11:07:45 -0700 (PDT) Received: by wicge5 with SMTP id ge5so31464640wic.0 for ; Fri, 25 Sep 2015 11:07:44 -0700 (PDT) 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=TJjats5GGy/doSNCmtoQRW+VXVNhHzoZIrefi4ltgLM=; b=Jn5/O4LOk9Pi+SLyIDWCY2kWBq//Y3yAQImaphtG2Dap36JqDfR9tbMl/CSM5ykjjh JUaE6I4Ph7qnYIRbuRRqLdWAvsk/YM4u38yU0jYRmyfO7Wv3ZqvmbMuGVSs30CS5JVKx aVim/K9ia0qSTqPz3xNq6x6bwbYWA13MH1yNLRSRWwFwcPi+grrinU3bcTNHn9fwWbQi pp2FSeVhK2gHu/fUqalJ+fSsn2F+YCiezpBsnhC1hoXIRYbOuXENxv0l2wtQX0I1VpwQ +V130O4aJkyHjtYe2PGMGI7iRZKazvh3HPowuiDAFOZrKu2gbsWqylPa3UXCqAr74Ttd jBOw== X-Gm-Message-State: ALoCoQn5J5dalqPs38342JIkcb7QbNfCajDljwp7j/oWhAbVuD7g4FiFlfNkwPtKLQfRK8F2aTXQ X-Received: by 10.180.182.116 with SMTP id ed20mr2008289wic.19.1443204464513; Fri, 25 Sep 2015 11:07:44 -0700 (PDT) Received: from draco.isw.intel.com ([83.217.123.106]) by smtp.gmail.com with ESMTPSA id uq5sm4511789wjc.3.2015.09.25.11.07.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 Sep 2015 11:07:44 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Fri, 25 Sep 2015 19:07:14 +0100 Message-Id: <1443204452-32244-4-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443204452-32244-1-git-send-email-michael.g.wood@intel.com> References: <1443204452-32244-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 03/21] toaster: create custom layer and recipes for Image customisation 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: Fri, 25 Sep 2015 18:07:48 -0000 From: Ed Bartosh When building customised recipes toaster creates custom layer directory and puts layer.conf and custom recipes to it. [YOCTO #8075] Signed-off-by: Ed Bartosh --- .../toaster/bldcontrol/localhostbecontroller.py | 51 +++++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py index a9909b8..62fff1d 100644 --- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py @@ -23,9 +23,11 @@ import os import sys import re +import shutil from django.db import transaction from django.db.models import Q from bldcontrol.models import BuildEnvironment, BRLayer, BRVariable, BRTarget, BRBitbake +from orm.models import CustomImageRecipe, Layer, Layer_Version, ProjectLayer import subprocess from toastermain import settings @@ -197,7 +199,7 @@ class LocalhostBEController(BuildEnvironmentController): return local_checkout_path - def setLayers(self, bitbakes, layers): + def setLayers(self, bitbakes, layers, targets): """ a word of attention: by convention, the first layer for any build will be poky! """ assert self.be.sourcedir is not None @@ -299,6 +301,51 @@ class LocalhostBEController(BuildEnvironmentController): if not os.path.exists(bblayerconf): raise BuildSetupException("BE is not consistent: bblayers.conf file missing at %s" % bblayerconf) + # 6. create custom layer and add custom recipes to it + layerpath = os.path.join(self.be.sourcedir, "_meta-toaster-custom") + if os.path.isdir(layerpath): + shutil.rmtree(layerpath) # remove leftovers from previous builds + for target in targets: + try: + customrecipe = CustomImageRecipe.objects.get(name=target.target, + project=bitbakes[0].req.project) + 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') + + # create recipe + recipe = os.path.join(layerpath, "recipes", "%s.bb" % target.target) + with open(recipe, "w") as recipef: + recipef.write("require %s\n" % customrecipe.base_recipe.recipe.file_path) + packages = [pkg.name for pkg in customrecipe.packages.all()] + if packages: + recipef.write('IMAGE_INSTALL = "%s"\n' % ' '.join(packages)) + + # create *Layer* objects needed for build machinery to work + layer = Layer.objects.get_or_create(name="Toaster Custom layer", + summary="Layer for custom recipes", + vcs_url="file://%s" % layerpath)[0] + breq = target.req + lver = Layer_Version.objects.get_or_create(project=breq.project, layer=layer, + dirpath=layerpath, build=breq.build)[0] + ProjectLayer.objects.get_or_create(project=breq.project, layercommit=lver, + optional=False) + BRLayer.objects.get_or_create(req=breq, name=layer.name, dirpath=layerpath, + giturl="file://%s" % layerpath) + if os.path.isdir(layerpath): + layerlist.append(layerpath) + BuildEnvironmentController._updateBBLayers(bblayerconf, layerlist) self.islayerset = True @@ -316,7 +363,7 @@ class LocalhostBEController(BuildEnvironmentController): def triggerBuild(self, bitbake, layers, variables, targets): # set up the buid environment with the needed layers - self.setLayers(bitbake, layers) + self.setLayers(bitbake, layers, targets) self.writeConfFile("conf/toaster-pre.conf", variables) self.writeConfFile("conf/toaster.conf", raw = "INHERIT+=\"toaster buildhistory\"") -- 2.1.4