diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2015-09-28 21:45:13 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-09-29 14:11:36 +0100 |
commit | 934f8d7b23bfcaf7d06a5fe475f7988ff9240f9d (patch) | |
tree | d9442f754bdb888dab1c393f8e0398b67d6ffa21 /bitbake | |
parent | 340b3983dbced604d6e9affc7fd5ccfdcc379e61 (diff) | |
download | poky-934f8d7b23bfcaf7d06a5fe475f7988ff9240f9d.tar.gz |
bitbake: 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]
(Bitbake rev: f81b48c30a548bee946d34c56aa1872785bcec30)
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>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py index a9909b8e1e..62fff1da34 100644 --- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | |||
@@ -23,9 +23,11 @@ | |||
23 | import os | 23 | import os |
24 | import sys | 24 | import sys |
25 | import re | 25 | import re |
26 | import shutil | ||
26 | from django.db import transaction | 27 | from django.db import transaction |
27 | from django.db.models import Q | 28 | from django.db.models import Q |
28 | from bldcontrol.models import BuildEnvironment, BRLayer, BRVariable, BRTarget, BRBitbake | 29 | from bldcontrol.models import BuildEnvironment, BRLayer, BRVariable, BRTarget, BRBitbake |
30 | from orm.models import CustomImageRecipe, Layer, Layer_Version, ProjectLayer | ||
29 | import subprocess | 31 | import subprocess |
30 | 32 | ||
31 | from toastermain import settings | 33 | from toastermain import settings |
@@ -197,7 +199,7 @@ class LocalhostBEController(BuildEnvironmentController): | |||
197 | return local_checkout_path | 199 | return local_checkout_path |
198 | 200 | ||
199 | 201 | ||
200 | def setLayers(self, bitbakes, layers): | 202 | def setLayers(self, bitbakes, layers, targets): |
201 | """ a word of attention: by convention, the first layer for any build will be poky! """ | 203 | """ a word of attention: by convention, the first layer for any build will be poky! """ |
202 | 204 | ||
203 | assert self.be.sourcedir is not None | 205 | assert self.be.sourcedir is not None |
@@ -299,6 +301,51 @@ class LocalhostBEController(BuildEnvironmentController): | |||
299 | if not os.path.exists(bblayerconf): | 301 | if not os.path.exists(bblayerconf): |
300 | raise BuildSetupException("BE is not consistent: bblayers.conf file missing at %s" % bblayerconf) | 302 | raise BuildSetupException("BE is not consistent: bblayers.conf file missing at %s" % bblayerconf) |
301 | 303 | ||
304 | # 6. create custom layer and add custom recipes to it | ||
305 | layerpath = os.path.join(self.be.sourcedir, "_meta-toaster-custom") | ||
306 | if os.path.isdir(layerpath): | ||
307 | shutil.rmtree(layerpath) # remove leftovers from previous builds | ||
308 | for target in targets: | ||
309 | try: | ||
310 | customrecipe = CustomImageRecipe.objects.get(name=target.target, | ||
311 | project=bitbakes[0].req.project) | ||
312 | except CustomImageRecipe.DoesNotExist: | ||
313 | continue # not a custom recipe, skip | ||
314 | |||
315 | # create directory structure | ||
316 | for name in ("conf", "recipes"): | ||
317 | path = os.path.join(layerpath, name) | ||
318 | if not os.path.isdir(path): | ||
319 | os.makedirs(path) | ||
320 | |||
321 | # create layer.oonf | ||
322 | config = os.path.join(layerpath, "conf", "layer.conf") | ||
323 | if not os.path.isfile(config): | ||
324 | with open(config, "w") as conf: | ||
325 | conf.write('BBPATH .= ":${LAYERDIR}"\nBBFILES += "${LAYERDIR}/recipes/*.bb"\n') | ||
326 | |||
327 | # create recipe | ||
328 | recipe = os.path.join(layerpath, "recipes", "%s.bb" % target.target) | ||
329 | with open(recipe, "w") as recipef: | ||
330 | recipef.write("require %s\n" % customrecipe.base_recipe.recipe.file_path) | ||
331 | packages = [pkg.name for pkg in customrecipe.packages.all()] | ||
332 | if packages: | ||
333 | recipef.write('IMAGE_INSTALL = "%s"\n' % ' '.join(packages)) | ||
334 | |||
335 | # create *Layer* objects needed for build machinery to work | ||
336 | layer = Layer.objects.get_or_create(name="Toaster Custom layer", | ||
337 | summary="Layer for custom recipes", | ||
338 | vcs_url="file://%s" % layerpath)[0] | ||
339 | breq = target.req | ||
340 | lver = Layer_Version.objects.get_or_create(project=breq.project, layer=layer, | ||
341 | dirpath=layerpath, build=breq.build)[0] | ||
342 | ProjectLayer.objects.get_or_create(project=breq.project, layercommit=lver, | ||
343 | optional=False) | ||
344 | BRLayer.objects.get_or_create(req=breq, name=layer.name, dirpath=layerpath, | ||
345 | giturl="file://%s" % layerpath) | ||
346 | if os.path.isdir(layerpath): | ||
347 | layerlist.append(layerpath) | ||
348 | |||
302 | BuildEnvironmentController._updateBBLayers(bblayerconf, layerlist) | 349 | BuildEnvironmentController._updateBBLayers(bblayerconf, layerlist) |
303 | 350 | ||
304 | self.islayerset = True | 351 | self.islayerset = True |
@@ -316,7 +363,7 @@ class LocalhostBEController(BuildEnvironmentController): | |||
316 | 363 | ||
317 | def triggerBuild(self, bitbake, layers, variables, targets): | 364 | def triggerBuild(self, bitbake, layers, variables, targets): |
318 | # set up the buid environment with the needed layers | 365 | # set up the buid environment with the needed layers |
319 | self.setLayers(bitbake, layers) | 366 | self.setLayers(bitbake, layers, targets) |
320 | self.writeConfFile("conf/toaster-pre.conf", variables) | 367 | self.writeConfFile("conf/toaster-pre.conf", variables) |
321 | self.writeConfFile("conf/toaster.conf", raw = "INHERIT+=\"toaster buildhistory\"") | 368 | self.writeConfFile("conf/toaster.conf", raw = "INHERIT+=\"toaster buildhistory\"") |
322 | 369 | ||