From 8c4598a532991424eba401d8b7711ea8b45c27f3 Mon Sep 17 00:00:00 2001 From: Joshua Lock Date: Sat, 30 Jul 2011 12:19:15 -0700 Subject: hob: remove temporary directory on program shutdown Move temp directory handling into the HobEventHandler and clean up the temporary files on program close. Fixes [YOCTO #1307] (Bitbake rev: 1009ca570a750a00b0e60afcc30ead070c7b310a) Signed-off-by: Joshua Lock Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'bitbake/lib/bb/ui/crumbs') diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py index 0b5b31808c..e8265f1136 100644 --- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py +++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py @@ -20,6 +20,8 @@ import gobject import logging +import tempfile +import datetime progress_total = 0 @@ -75,6 +77,7 @@ class HobHandler(gobject.GObject): self.generating = False self.build_queue = [] self.current_phase = None + self.image_dir = None self.model = taskmodel self.server = server @@ -237,7 +240,7 @@ class HobHandler(gobject.GObject): pmake = "-j %s" % threads self.server.runCommand(["setVariable", "BB_NUMBER_THREADS", pmake]) - def build_image(self, image, image_path, configurator): + def build_image(self, image, configurator): targets = [] targets.append(image) if self.build_toolchain and self.build_toolchain_headers: @@ -248,24 +251,24 @@ class HobHandler(gobject.GObject): bbpath_ok = False bbpath = self.server.runCommand(["getVariable", "BBPATH"]) - if image_path in bbpath.split(":"): + if self.image_dir in bbpath.split(":"): bbpath_ok = True bbfiles_ok = False bbfiles = self.server.runCommand(["getVariable", "BBFILES"]).split(" ") for files in bbfiles: import re - pattern = "%s/\*.bb" % image_path + pattern = "%s/\*.bb" % self.image_dir if re.match(pattern, files): bbfiles_ok = True if not bbpath_ok: - nbbp = image_path + nbbp = self.image_dir else: nbbp = None if not bbfiles_ok: - nbbf = "%s/*.bb" % image_path + nbbf = "%s/*.bb" % self.image_dir else: nbbf = None @@ -319,3 +322,16 @@ class HobHandler(gobject.GObject): def get_image_deploy_dir(self): return self.server.runCommand(["getVariable", "DEPLOY_DIR_IMAGE"]) + + def make_temp_dir(self): + self.image_dir = os.path.join(tempfile.gettempdir(), 'hob-images') + bb.utils.mkdirhier(self.image_dir) + + def remove_temp_dir(self): + bb.utils.remove(self.image_dir, True) + + def get_temp_recipe_path(self, name): + timestamp = datetime.date.today().isoformat() + image_file = "hob-%s-variant-%s.bb" % (name, timestamp) + recipepath = os.path.join(self.image_dir, image_file) + return recipepath -- cgit v1.2.3-54-g00ecf