diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2014-08-10 11:52:17 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2014-08-10 11:52:17 -0700 |
commit | 5a5da817a1041b57cc4ae0f2ee16ee0d75701c57 (patch) | |
tree | 29f6850f765ea3dfbe51a514469222c1e7966658 /lib | |
parent | 7714d08e2e4b1c7accd6113618651b42bdc942c1 (diff) | |
download | spack-5a5da817a1041b57cc4ae0f2ee16ee0d75701c57.tar.gz spack-5a5da817a1041b57cc4ae0f2ee16ee0d75701c57.tar.bz2 spack-5a5da817a1041b57cc4ae0f2ee16ee0d75701c57.tar.xz spack-5a5da817a1041b57cc4ae0f2ee16ee0d75701c57.zip |
Fix SPACK-27 & remove dependence on check_output
- subprocess.check_output is python 2.7 only
- Spack checks for existence of requested prefix, creates it if it does not exist.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/cmd/bootstrap.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/spack/spack/cmd/bootstrap.py b/lib/spack/spack/cmd/bootstrap.py index 31c908d42b..f75b68b00a 100644 --- a/lib/spack/spack/cmd/bootstrap.py +++ b/lib/spack/spack/cmd/bootstrap.py @@ -23,12 +23,13 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## import os -from subprocess import check_call, check_output +from subprocess import check_call import llnl.util.tty as tty -from llnl.util.filesystem import join_path +from llnl.util.filesystem import join_path, mkdirp import spack +from spack.util.executable import which description = "Create a new installation of spack in another prefix" @@ -38,8 +39,10 @@ def setup_parser(subparser): def get_origin_url(): git_dir = join_path(spack.prefix, '.git') - origin_url = check_output( - ['git', '--git-dir=%s' % git_dir, 'config', '--get', 'remote.origin.url']) + git = which('git', required=True) + origin_url = git( + '--git-dir=%s' % git_dir, 'config', '--get', 'remote.origin.url', + return_output=True) return origin_url.strip() @@ -49,6 +52,11 @@ def bootstrap(parser, args): tty.msg("Fetching spack from origin: %s" % origin_url) + if os.path.isfile(prefix): + tty.die("There is already a file at %s" % prefix) + + mkdirp(prefix) + if os.path.exists(join_path(prefix, '.git')): tty.die("There already seems to be a git repository in %s" % prefix) @@ -62,10 +70,11 @@ def bootstrap(parser, args): "%s/lib/spack/..." % prefix) os.chdir(prefix) - check_call(['git', 'init', '--shared', '-q']) - check_call(['git', 'remote', 'add', 'origin', origin_url]) - check_call(['git', 'fetch', 'origin', 'master:refs/remotes/origin/master', '-n', '-q']) - check_call(['git', 'reset', '--hard', 'origin/master', '-q']) + git = which('git', required=True) + git('init', '--shared', '-q') + git('remote', 'add', 'origin', origin_url) + git('fetch', 'origin', 'master:refs/remotes/origin/master', '-n', '-q') + git('reset', '--hard', 'origin/master', '-q') tty.msg("Successfully created a new spack in %s" % prefix, "Run %s/bin/spack to use this installation." % prefix) |