From 140744c4701bcac0dd61e11303d008f2ea34fc1b Mon Sep 17 00:00:00 2001 From: Cristiana Voicu Date: Mon, 29 Jul 2013 09:55:06 +0000 Subject: bitbake: hob/bitbake: create a template (a .bb file) from hob through bitbake Modified generateNewImage function from cooker, in order to be used to save a template in Hob. Created a command to ensure that some dirs are created. The templates (recipes) will be saved in {TOPDIR}/recipes/images folder. Called these methods from Hob. [YOCTO #4193] (Bitbake rev: 96ffa00945c7eb09a0132fa47159aef3ef20fb3e) Signed-off-by: Cristiana Voicu Signed-off-by: Richard Purdie --- bitbake/lib/bb/cooker.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'bitbake/lib/bb/cooker.py') diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 49e6345ce4..4a5638fb60 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py @@ -1100,16 +1100,25 @@ class BBCooker: self.configuration.server_register_idlecallback(buildTargetsIdle, rq) - def generateNewImage(self, image, base_image, package_queue): + def generateNewImage(self, image, base_image, package_queue, timestamp): ''' - Create a new image with a "require" base_image statement + Create a new image with a "require"/"inherit" base_image statement ''' - image_name = os.path.splitext(image)[0] - timestr = time.strftime("-%Y%m%d-%H%M%S") - dest = image_name + str(timestr) + ".bb" + if timestamp: + image_name = os.path.splitext(image)[0] + timestr = time.strftime("-%Y%m%d-%H%M%S") + dest = image_name + str(timestr) + ".bb" + else: + if not image.endswith(".bb"): + dest = image + ".bb" + else: + dest = image with open(dest, "w") as imagefile: - imagefile.write("require " + base_image + "\n") + if base_image is None: + imagefile.write("inherit image\n") + else: + imagefile.write("require " + base_image + "\n") package_install = "PACKAGE_INSTALL_forcevariable = \"" for package in package_queue: package_install += str(package) + " " @@ -1117,7 +1126,8 @@ class BBCooker: imagefile.write(package_install) self.state = state.initial - return timestr + if timestamp: + return timestr def updateCache(self): if self.state == state.running: -- cgit v1.2.3-54-g00ecf