summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-11-24 11:20:03 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-11-30 15:48:10 +0000
commit5de7f159a15918526825e99a44cd572c7494f5bf (patch)
tree16477d41c3a9ad56512295fd362ed96dab3f9adc /bitbake/lib
parent6f8df05e6e0640470472bc2e613611229e615dda (diff)
downloadpoky-5de7f159a15918526825e99a44cd572c7494f5bf.tar.gz
bitbake: toaster: bldcontrol Move CustomImageRecipe file creation into own function
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. (Bitbake rev: 15a42b36c01fccd79e5aa0788dea5640b253982b) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/toaster/bldcontrol/localhostbecontroller.py144
1 files changed, 75 insertions, 69 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
index 18870d9612..62e62fe19e 100644
--- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
+++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
@@ -201,82 +201,88 @@ class LocalhostBEController(BuildEnvironmentController):
201 logger.debug("localhostbecontroller: current layer list %s " % pformat(layerlist)) 201 logger.debug("localhostbecontroller: current layer list %s " % pformat(layerlist))
202 202
203 # 5. create custom layer and add custom recipes to it 203 # 5. create custom layer and add custom recipes to it
204 layerpath = os.path.join(self.be.builddir,
205 CustomImageRecipe.LAYER_NAME)
206 for target in targets: 204 for target in targets:
207 try: 205 try:
208 customrecipe = CustomImageRecipe.objects.get(name=target.target, 206 customrecipe = CustomImageRecipe.objects.get(
209 project=bitbake.req.project) 207 name=target.target,
208 project=bitbake.req.project)
209
210 custom_layer_path = self.setup_custom_image_recipe(
211 customrecipe, layers)
212
213 if os.path.isdir(custom_layer_path):
214 layerlist.append(custom_layer_path)
215
210 except CustomImageRecipe.DoesNotExist: 216 except CustomImageRecipe.DoesNotExist:
211 continue # not a custom recipe, skip 217 continue # not a custom recipe, skip
212
213 # create directory structure
214 for name in ("conf", "recipes"):
215 path = os.path.join(layerpath, name)
216 if not os.path.isdir(path):
217 os.makedirs(path)
218
219 # create layer.oonf
220 config = os.path.join(layerpath, "conf", "layer.conf")
221 if not os.path.isfile(config):
222 with open(config, "w") as conf:
223 conf.write('BBPATH .= ":${LAYERDIR}"\nBBFILES += "${LAYERDIR}/recipes/*.bb"\n')
224
225 # Update the Layer_Version dirpath that has our base_recipe in
226 # to be able to read the base recipe to then generate the
227 # custom recipe.
228 br_layer_base_recipe = layers.get(
229 layer_version=customrecipe.base_recipe.layer_version)
230
231 # If the layer is one that we've cloned we know where it lives
232 if br_layer_base_recipe.giturl and br_layer_base_recipe.commit:
233 layer_path = self.getGitCloneDirectory(
234 br_layer_base_recipe.giturl,
235 br_layer_base_recipe.commit)
236 # Otherwise it's a local layer
237 elif br_layer_base_recipe.local_source_dir:
238 layer_path = br_layer_base_recipe.local_source_dir
239 else:
240 logger.error("Unable to workout the dir path for the custom"
241 " image recipe")
242
243 br_layer_base_dirpath = os.path.join(
244 self.be.sourcedir,
245 layer_path,
246 customrecipe.base_recipe.layer_version.dirpath)
247
248 customrecipe.base_recipe.layer_version.dirpath = \
249 br_layer_base_dirpath
250
251 customrecipe.base_recipe.layer_version.save()
252
253 # create recipe
254 recipe_path = \
255 os.path.join(layerpath, "recipes", "%s.bb" % target.target)
256 with open(recipe_path, "w") as recipef:
257 recipef.write(customrecipe.generate_recipe_file_contents())
258
259 # Update the layer and recipe objects
260 customrecipe.layer_version.dirpath = layerpath
261 customrecipe.layer_version.layer.local_source_dir = layerpath
262 customrecipe.layer_version.layer.save()
263 customrecipe.layer_version.save()
264
265 customrecipe.file_path = recipe_path
266 customrecipe.save()
267
268 # create *Layer* objects needed for build machinery to work
269 BRLayer.objects.get_or_create(req=target.req,
270 name=layer.name,
271 dirpath=layerpath,
272 giturl="file://%s" % layerpath)
273 if os.path.isdir(layerpath):
274 layerlist.append(layerpath)
275 218
276 self.islayerset = True
277 layerlist.extend(nongitlayerlist) 219 layerlist.extend(nongitlayerlist)
220 logger.debug("\n\nset layers gives this list \n %s" % ''.join(layerlist))
221 self.islayerset = True
278 return layerlist 222 return layerlist
279 223
224 def setup_custom_image_recipe(self, customrecipe, layers):
225 """ Set up toaster-custom-images layer and recipe files """
226 layerpath = os.path.join(self.be.builddir,
227 CustomImageRecipe.LAYER_NAME)
228
229 # create directory structure
230 for name in ("conf", "recipes"):
231 path = os.path.join(layerpath, name)
232 if not os.path.isdir(path):
233 os.makedirs(path)
234
235 # create layer.conf
236 config = os.path.join(layerpath, "conf", "layer.conf")
237 if not os.path.isfile(config):
238 with open(config, "w") as conf:
239 conf.write('BBPATH .= ":${LAYERDIR}"\nBBFILES += "${LAYERDIR}/recipes/*.bb"\n')
240
241 # Update the Layer_Version dirpath that has our base_recipe in
242 # to be able to read the base recipe to then generate the
243 # custom recipe.
244 br_layer_base_recipe = layers.get(
245 layer_version=customrecipe.base_recipe.layer_version)
246
247 # If the layer is one that we've cloned we know where it lives
248 if br_layer_base_recipe.giturl and br_layer_base_recipe.commit:
249 layer_path = self.getGitCloneDirectory(
250 br_layer_base_recipe.giturl,
251 br_layer_base_recipe.commit)
252 # Otherwise it's a local layer
253 elif br_layer_base_recipe.local_source_dir:
254 layer_path = br_layer_base_recipe.local_source_dir
255 else:
256 logger.error("Unable to workout the dir path for the custom"
257 " image recipe")
258
259 br_layer_base_dirpath = os.path.join(
260 self.be.sourcedir,
261 layer_path,
262 customrecipe.base_recipe.layer_version.dirpath)
263
264 customrecipe.base_recipe.layer_version.dirpath = br_layer_base_dirpath
265
266 customrecipe.base_recipe.layer_version.save()
267
268 # create recipe
269 recipe_path = os.path.join(layerpath, "recipes", "%s.bb" %
270 customrecipe.name)
271 with open(recipe_path, "w") as recipef:
272 recipef.write(customrecipe.generate_recipe_file_contents())
273
274 # Update the layer and recipe objects
275 customrecipe.layer_version.dirpath = layerpath
276 customrecipe.layer_version.layer.local_source_dir = layerpath
277 customrecipe.layer_version.layer.save()
278 customrecipe.layer_version.save()
279
280 customrecipe.file_path = recipe_path
281 customrecipe.save()
282
283 return layerpath
284
285
280 def readServerLogFile(self): 286 def readServerLogFile(self):
281 return open(os.path.join(self.be.builddir, "toaster_server.log"), "r").read() 287 return open(os.path.join(self.be.builddir, "toaster_server.log"), "r").read()
282 288