summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoshua Lock <josh@linux.intel.com>2011-07-30 12:19:15 -0700
committerJoshua Lock <josh@linux.intel.com>2011-07-30 12:21:18 -0700
commit1009ca570a750a00b0e60afcc30ead070c7b310a (patch)
treea145b49f488f23f54252b1a3050e585c6e6aac97 /lib
parent2f7eadfdd710f84a299d6fc7be67ddb089f03ecc (diff)
downloadbitbake-contrib-1009ca570a750a00b0e60afcc30ead070c7b310a.tar.gz
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] Signed-off-by: Joshua Lock <josh@linux.intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/bb/ui/crumbs/hobeventhandler.py26
-rw-r--r--lib/bb/ui/hob.py15
2 files changed, 28 insertions, 13 deletions
diff --git a/lib/bb/ui/crumbs/hobeventhandler.py b/lib/bb/ui/crumbs/hobeventhandler.py
index 0b5b31808..e8265f113 100644
--- a/lib/bb/ui/crumbs/hobeventhandler.py
+++ b/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
diff --git a/lib/bb/ui/hob.py b/lib/bb/ui/hob.py
index 919c06e15..b5c2342ce 100644
--- a/lib/bb/ui/hob.py
+++ b/lib/bb/ui/hob.py
@@ -114,6 +114,8 @@ class MainWindow (gtk.Window):
# whilst the busy cursor is set
self.set_busy_cursor(False)
+ self.handler.remove_temp_dir()
+
gtk.main_quit()
"""
@@ -418,13 +420,10 @@ class MainWindow (gtk.Window):
rep.base_image = "empty"
if build_image:
- import tempfile, datetime
-
- image_name = "hob-%s-variant-%s" % (rep.base_image, datetime.date.today().isoformat())
- image_file = "%s.bb" % (image_name)
- image_dir = os.path.join(tempfile.gettempdir(), 'hob-images')
- bb.utils.mkdirhier(image_dir)
- recipepath = os.path.join(image_dir, image_file)
+ self.handler.make_temp_dir()
+ recipepath = self.handler.get_temp_recipe_path(rep.base_image)
+ image_name = recipepath.rstrip(".bb")
+ path, sep, image_name = image_name.rpartition("/")
rep.writeRecipe(recipepath, self.model)
# In the case where we saved the file for the purpose of building
@@ -433,7 +432,7 @@ class MainWindow (gtk.Window):
if not self.save_path:
self.files_to_clean.append(recipepath)
- self.handler.build_image(image_name, image_dir, self.configurator)
+ self.handler.build_image(image_name, self.configurator)
else:
self.handler.build_packages(rep.allpkgs.split(" "))