diff options
author | Joshua Lock <josh@linux.intel.com> | 2011-07-30 12:19:15 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-08-02 22:31:44 +0100 |
commit | 8c4598a532991424eba401d8b7711ea8b45c27f3 (patch) | |
tree | 751621b7e5d9b5d2b4a271f026ab68fbc79116f8 /bitbake | |
parent | e03114b3521cbefa2c8bafa4bbf2dc4661793c31 (diff) | |
download | poky-8c4598a532991424eba401d8b7711ea8b45c27f3.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]
(Bitbake rev: 1009ca570a750a00b0e60afcc30ead070c7b310a)
Signed-off-by: Joshua Lock <josh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 26 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/hob.py | 15 |
2 files changed, 28 insertions, 13 deletions
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 @@ | |||
20 | 20 | ||
21 | import gobject | 21 | import gobject |
22 | import logging | 22 | import logging |
23 | import tempfile | ||
24 | import datetime | ||
23 | 25 | ||
24 | progress_total = 0 | 26 | progress_total = 0 |
25 | 27 | ||
@@ -75,6 +77,7 @@ class HobHandler(gobject.GObject): | |||
75 | self.generating = False | 77 | self.generating = False |
76 | self.build_queue = [] | 78 | self.build_queue = [] |
77 | self.current_phase = None | 79 | self.current_phase = None |
80 | self.image_dir = None | ||
78 | 81 | ||
79 | self.model = taskmodel | 82 | self.model = taskmodel |
80 | self.server = server | 83 | self.server = server |
@@ -237,7 +240,7 @@ class HobHandler(gobject.GObject): | |||
237 | pmake = "-j %s" % threads | 240 | pmake = "-j %s" % threads |
238 | self.server.runCommand(["setVariable", "BB_NUMBER_THREADS", pmake]) | 241 | self.server.runCommand(["setVariable", "BB_NUMBER_THREADS", pmake]) |
239 | 242 | ||
240 | def build_image(self, image, image_path, configurator): | 243 | def build_image(self, image, configurator): |
241 | targets = [] | 244 | targets = [] |
242 | targets.append(image) | 245 | targets.append(image) |
243 | if self.build_toolchain and self.build_toolchain_headers: | 246 | if self.build_toolchain and self.build_toolchain_headers: |
@@ -248,24 +251,24 @@ class HobHandler(gobject.GObject): | |||
248 | 251 | ||
249 | bbpath_ok = False | 252 | bbpath_ok = False |
250 | bbpath = self.server.runCommand(["getVariable", "BBPATH"]) | 253 | bbpath = self.server.runCommand(["getVariable", "BBPATH"]) |
251 | if image_path in bbpath.split(":"): | 254 | if self.image_dir in bbpath.split(":"): |
252 | bbpath_ok = True | 255 | bbpath_ok = True |
253 | 256 | ||
254 | bbfiles_ok = False | 257 | bbfiles_ok = False |
255 | bbfiles = self.server.runCommand(["getVariable", "BBFILES"]).split(" ") | 258 | bbfiles = self.server.runCommand(["getVariable", "BBFILES"]).split(" ") |
256 | for files in bbfiles: | 259 | for files in bbfiles: |
257 | import re | 260 | import re |
258 | pattern = "%s/\*.bb" % image_path | 261 | pattern = "%s/\*.bb" % self.image_dir |
259 | if re.match(pattern, files): | 262 | if re.match(pattern, files): |
260 | bbfiles_ok = True | 263 | bbfiles_ok = True |
261 | 264 | ||
262 | if not bbpath_ok: | 265 | if not bbpath_ok: |
263 | nbbp = image_path | 266 | nbbp = self.image_dir |
264 | else: | 267 | else: |
265 | nbbp = None | 268 | nbbp = None |
266 | 269 | ||
267 | if not bbfiles_ok: | 270 | if not bbfiles_ok: |
268 | nbbf = "%s/*.bb" % image_path | 271 | nbbf = "%s/*.bb" % self.image_dir |
269 | else: | 272 | else: |
270 | nbbf = None | 273 | nbbf = None |
271 | 274 | ||
@@ -319,3 +322,16 @@ class HobHandler(gobject.GObject): | |||
319 | 322 | ||
320 | def get_image_deploy_dir(self): | 323 | def get_image_deploy_dir(self): |
321 | return self.server.runCommand(["getVariable", "DEPLOY_DIR_IMAGE"]) | 324 | return self.server.runCommand(["getVariable", "DEPLOY_DIR_IMAGE"]) |
325 | |||
326 | def make_temp_dir(self): | ||
327 | self.image_dir = os.path.join(tempfile.gettempdir(), 'hob-images') | ||
328 | bb.utils.mkdirhier(self.image_dir) | ||
329 | |||
330 | def remove_temp_dir(self): | ||
331 | bb.utils.remove(self.image_dir, True) | ||
332 | |||
333 | def get_temp_recipe_path(self, name): | ||
334 | timestamp = datetime.date.today().isoformat() | ||
335 | image_file = "hob-%s-variant-%s.bb" % (name, timestamp) | ||
336 | recipepath = os.path.join(self.image_dir, image_file) | ||
337 | return recipepath | ||
diff --git a/bitbake/lib/bb/ui/hob.py b/bitbake/lib/bb/ui/hob.py index 919c06e151..b5c2342ce2 100644 --- a/bitbake/lib/bb/ui/hob.py +++ b/bitbake/lib/bb/ui/hob.py | |||
@@ -114,6 +114,8 @@ class MainWindow (gtk.Window): | |||
114 | # whilst the busy cursor is set | 114 | # whilst the busy cursor is set |
115 | self.set_busy_cursor(False) | 115 | self.set_busy_cursor(False) |
116 | 116 | ||
117 | self.handler.remove_temp_dir() | ||
118 | |||
117 | gtk.main_quit() | 119 | gtk.main_quit() |
118 | 120 | ||
119 | """ | 121 | """ |
@@ -418,13 +420,10 @@ class MainWindow (gtk.Window): | |||
418 | rep.base_image = "empty" | 420 | rep.base_image = "empty" |
419 | 421 | ||
420 | if build_image: | 422 | if build_image: |
421 | import tempfile, datetime | 423 | self.handler.make_temp_dir() |
422 | 424 | recipepath = self.handler.get_temp_recipe_path(rep.base_image) | |
423 | image_name = "hob-%s-variant-%s" % (rep.base_image, datetime.date.today().isoformat()) | 425 | image_name = recipepath.rstrip(".bb") |
424 | image_file = "%s.bb" % (image_name) | 426 | path, sep, image_name = image_name.rpartition("/") |
425 | image_dir = os.path.join(tempfile.gettempdir(), 'hob-images') | ||
426 | bb.utils.mkdirhier(image_dir) | ||
427 | recipepath = os.path.join(image_dir, image_file) | ||
428 | 427 | ||
429 | rep.writeRecipe(recipepath, self.model) | 428 | rep.writeRecipe(recipepath, self.model) |
430 | # In the case where we saved the file for the purpose of building | 429 | # In the case where we saved the file for the purpose of building |
@@ -433,7 +432,7 @@ class MainWindow (gtk.Window): | |||
433 | if not self.save_path: | 432 | if not self.save_path: |
434 | self.files_to_clean.append(recipepath) | 433 | self.files_to_clean.append(recipepath) |
435 | 434 | ||
436 | self.handler.build_image(image_name, image_dir, self.configurator) | 435 | self.handler.build_image(image_name, self.configurator) |
437 | else: | 436 | else: |
438 | self.handler.build_packages(rep.allpkgs.split(" ")) | 437 | self.handler.build_packages(rep.allpkgs.split(" ")) |
439 | 438 | ||