summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2015-09-28 21:45:13 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-29 13:44:47 +0100
commitf81b48c30a548bee946d34c56aa1872785bcec30 (patch)
treee9c14129c5762491d55e57ab31ef3ed33bbc0354
parent2f7949caec3c9194328c35b2e075eaae85409efe (diff)
downloadbitbake-f81b48c30a548bee946d34c56aa1872785bcec30.zip
toaster: create custom layer and recipes for Image customisation
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 <ed.bartosh@linux.intel.com> Signed-off-by: brian avery <avery.brian@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/toaster/bldcontrol/localhostbecontroller.py51
1 files changed, 49 insertions, 2 deletions
diff --git a/lib/toaster/bldcontrol/localhostbecontroller.py b/lib/toaster/bldcontrol/localhostbecontroller.py
index a9909b8e..62fff1da 100644
--- a/lib/toaster/bldcontrol/localhostbecontroller.py
+++ b/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\"")