summaryrefslogtreecommitdiff
path: root/morphlib/app.py
diff options
context:
space:
mode:
authorTiago Gomes <tiago.gomes@codethink.co.uk>2013-06-05 18:38:31 +0100
committerTiago Gomes <tiago.gomes@codethink.co.uk>2013-06-05 18:38:31 +0100
commit710af7e4bc5e3654221ce23d5b3ccbafbd0eae0c (patch)
tree8ef2cd494d0ca0b7bba7daec00171dea7821e756 /morphlib/app.py
parent7e74c354db185291ae9fecb8fef2d7ebb172c3d1 (diff)
parentb4a633a5229b6c3380cde0cc67da037ea8091008 (diff)
downloadmorph-710af7e4bc5e3654221ce23d5b3ccbafbd0eae0c.tar.gz
Merge branch 'baserock/tiagogomes/tmpdir' of git://git.baserock.org/baserock/baserock/morph
I had fixed an conflict and change to use morph_tmp instead of morph as default temp dir. Reviewed by Lars Wirzenius Conflicts: morphlib/app.py
Diffstat (limited to 'morphlib/app.py')
-rw-r--r--morphlib/app.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/morphlib/app.py b/morphlib/app.py
index a278b529..b4d316e8 100644
--- a/morphlib/app.py
+++ b/morphlib/app.py
@@ -121,7 +121,7 @@ class Morph(cliapp.Application):
'this setting can point at a directory in '
'NFS)',
metavar='DIR',
- default=os.environ.get('TMPDIR'),
+ default=None,
group=group_storage)
self.settings.string(['cachedir'],
'cache git repositories and build results in DIR',
@@ -215,19 +215,27 @@ class Morph(cliapp.Application):
self.settings['compiler-cache-dir'] = os.path.join(
self.settings['cachedir'], 'ccache')
if self.settings['tempdir'] is None:
- if 'TMPDIR' in os.environ:
- self.settings['tempdir'] = os.environ['TMPDIR']
- else:
- self.settings['tempdir'] = '/tmp'
+ tmpdir_base = os.environ.get('TMPDIR', '/tmp')
+ tmpdir = os.path.join(tmpdir_base, 'morph_tmp')
+ self.settings['tempdir'] = tmpdir
+
+ def create_dir_if_not_exists(dir):
+ if not os.path.exists(dir):
+ os.makedirs(dir)
+
+ tmpdir = self.settings['tempdir']
+ create_dir_if_not_exists(tmpdir)
+ create_dir_if_not_exists(os.path.join(tmpdir, 'chunks'))
+ create_dir_if_not_exists(os.path.join(tmpdir, 'staging'))
+ create_dir_if_not_exists(os.path.join(tmpdir, 'failed'))
+ create_dir_if_not_exists(os.path.join(tmpdir, 'deployments'))
+
+ create_dir_if_not_exists(self.settings['cachedir'])
+
if 'MORPH_DUMP_PROCESSED_CONFIG' in os.environ:
self.settings.dump_config(sys.stdout)
sys.exit(0)
- for dirconfig in ("cachedir", "tempdir"):
- path = self.settings[dirconfig]
- if not os.path.exists(path):
- os.makedirs(path)
-
cliapp.Application.process_args(self, args)
def setup_plugin_manager(self):