summaryrefslogtreecommitdiff
path: root/morphlib/app.py
diff options
context:
space:
mode:
authorTiago Gomes <tiago.gomes@codethink.co.uk>2013-06-05 13:31:13 +0000
committerTiago Gomes <tiago.gomes@codethink.co.uk>2013-06-05 16:59:29 +0000
commitb4a633a5229b6c3380cde0cc67da037ea8091008 (patch)
treec5f61a51eedbf5600ac9bcaa0249ce422ead7e6e /morphlib/app.py
parent86cbc1bc8ef84dc9496d7723a15dec9b43eacb73 (diff)
downloadmorph-b4a633a5229b6c3380cde0cc67da037ea8091008.tar.gz
Change the structure of the temporary directory used by morph
Now, inside the temporary directory we will have the following subdirectories: chunks, staging, failed and deployments. The failed directory will contain the staging areas of failed builds.
Diffstat (limited to 'morphlib/app.py')
-rw-r--r--morphlib/app.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/morphlib/app.py b/morphlib/app.py
index 267dab1b..35739a59 100644
--- a/morphlib/app.py
+++ b/morphlib/app.py
@@ -128,7 +128,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_build)
# These cannot be removed just yet because existing morph.conf files
@@ -183,10 +183,21 @@ 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'))
+
if 'MORPH_DUMP_PROCESSED_CONFIG' in os.environ:
self.settings.dump_config(sys.stdout)
sys.exit(0)