summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-12-22 07:54:25 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2015-12-22 07:54:25 -0800
commit792b03325562e5577d018b188577915ea4dd5e7d (patch)
treecbcac8ea4c85f441388e10069266a2cf7aae511a /lib
parent2ba6bb21fbac14b6eec9b4ba4fb7ea1f11e9df6f (diff)
downloadspack-792b03325562e5577d018b188577915ea4dd5e7d.tar.gz
spack-792b03325562e5577d018b188577915ea4dd5e7d.tar.bz2
spack-792b03325562e5577d018b188577915ea4dd5e7d.tar.xz
spack-792b03325562e5577d018b188577915ea4dd5e7d.zip
Slightly more robust tmp directory search.
- remove getcwd() check (seems arbitrary -- if users set their TMPDIR to this why stop them?) - try a number of common locations and try per-user directories in them first.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/__init__.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py
index ccd7dc25c8..92cb417a85 100644
--- a/lib/spack/spack/__init__.py
+++ b/lib/spack/spack/__init__.py
@@ -24,6 +24,7 @@
##############################################################################
import os
import tempfile
+import getpass
from llnl.util.filesystem import *
# This lives in $prefix/lib/spack/spack/__file__
@@ -111,10 +112,17 @@ use_tmp_stage = True
# that it can create.
tmp_dirs = []
_default_tmp = tempfile.gettempdir()
-if _default_tmp != os.getcwd():
- tmp_dirs = [ join_path(_default_tmp, '%u', 'spack-stage'),
- join_path(_default_tmp, 'spack-stage') ]
-tmp_dirs.append('/nfs/tmp2/%u/spack-stage') # TODO: remove
+_tmp_user = getpass.getuser()
+
+_tmp_candidates = (_default_tmp, '/nfs/tmp2', '/tmp', '/var/tmp')
+for path in _tmp_candidates:
+ # don't add a second username if it's already unique by user.
+ if not _tmp_user in path:
+ tmp_dirs.append(join_path(path, '%u', 'spack-stage'))
+
+for path in _tmp_candidates:
+ if not path in tmp_dirs:
+ tmp_dirs.append(join_path(path, 'spack-stage'))
# Whether spack should allow installation of unsafe versions of
# software. "Unsafe" versions are ones it doesn't have a checksum