Repository: spack/spack

Issue:
spack can't bootstrap from release tarball
Spack release tarballs don't include `.git` in the top directory like a clone of the repo would. The bootstrap relies on this to bootrstrap a copy from github:

```
[jawestlu@master4-centos71 spack-0.8.17]$ ./bin/spack bootstrap /tmp/
==> Error: command '/bin/git --git-dir=/mnt/lustre/jawestlu/rpmbuild/BUILD/spack-0.8.17/.git config --get remote.origin.url' returned error code 1
[jawestlu@master4-centos71 spack-0.8.17]$ ls -la /mnt/lustre/jawestlu/rpmbuild/BUILD/spack-0.8.17/
total 52
drwxr-xr-x  6 jawestlu jawestlu  4096 Jan 13 15:21 .
drwxr-xr-x 14 jawestlu jawestlu  4096 Jan 13 15:16 ..
-rw-r--r--  1 jawestlu jawestlu   106 Mar 24  2015 .gitignore
-rw-r--r--  1 jawestlu jawestlu 20309 Mar 24  2015 LICENSE
-rw-r--r--  1 jawestlu jawestlu  2894 Mar 24  2015 README.md
drwxr-xr-x  2 jawestlu jawestlu  4096 Mar 24  2015 bin
drwxr-xr-x  3 jawestlu jawestlu  4096 Mar 24  2015 lib
drwxr-xr-x  3 jawestlu jawestlu  4096 Mar 24  2015 share
drwxr-xr-x  3 jawestlu jawestlu  4096 Mar 24  2015 var
```



Discussion:

Resolving patch:
diff --git a/lib/spack/spack/cmd/bootstrap.py b/lib/spack/spack/cmd/bootstrap.py
--- a/lib/spack/spack/cmd/bootstrap.py
+++ b/lib/spack/spack/cmd/bootstrap.py
@@ -23,7 +23,6 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 ##############################################################################
 import os
-from subprocess import check_call
 
 import llnl.util.tty as tty
 from llnl.util.filesystem import join_path, mkdirp
@@ -31,26 +30,49 @@
 import spack
 from spack.util.executable import which
 
+_SPACK_UPSTREAM = 'https://github.com/llnl/spack'
+
 description = "Create a new installation of spack in another prefix"
 
+
 def setup_parser(subparser):
-    subparser.add_argument('prefix', help="names of prefix where we should install spack")
+    subparser.add_argument(
+        '-r', '--remote', action='store', dest='remote',
+        help="name of the remote to bootstrap from", default='origin')
+    subparser.add_argument(
+        'prefix',
+        help="names of prefix where we should install spack")
 
 
-def get_origin_url():
+def get_origin_info(remote):
     git_dir = join_path(spack.prefix, '.git')
     git = which('git', required=True)
-    origin_url = git(
-        '--git-dir=%s' % git_dir, 'config', '--get', 'remote.origin.url',
-        output=str)
-    return origin_url.strip()
+    try:
+        branch = git('symbolic-ref', '--short', 'HEAD', output=str)
+    except ProcessError:
+        branch = 'develop'
+        tty.warn('No branch found; using default branch: %s' % branch)
+    if remote == 'origin' and \
+       branch not in ('master', 'develop'):
+        branch = 'develop'
+        tty.warn('Unknown branch found; using default branch: %s' % branch)
+    try:
+        origin_url = git(
+            '--git-dir=%s' % git_dir,
+            'config', '--get', 'remote.%s.url' % remote,
+            output=str)
+    except ProcessError:
+        origin_url = _SPACK_UPSTREAM
+        tty.warn('No git repository found; '
+                 'using default upstream URL: %s' % origin_url)
+    return (origin_url.strip(), branch.strip())
 
 
 def bootstrap(parser, args):
-    origin_url = get_origin_url()
+    origin_url, branch = get_origin_info(args.remote)
     prefix = args.prefix
 
-    tty.msg("Fetching spack from origin: %s" % origin_url)
+    tty.msg("Fetching spack from '%s': %s" % (args.remote, origin_url))
 
     if os.path.isfile(prefix):
         tty.die("There is already a file at %s" % prefix)
@@ -62,7 +84,8 @@ def bootstrap(parser, args):
 
     files_in_the_way = os.listdir(prefix)
     if files_in_the_way:
-        tty.die("There are already files there!  Delete these files before boostrapping spack.",
+        tty.die("There are already files there! "
+                "Delete these files before boostrapping spack.",
                 *files_in_the_way)
 
     tty.msg("Installing:",
@@ -73,8 +96,10 @@ def bootstrap(parser, args):
     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')
+    git('fetch', 'origin', '%s:refs/remotes/origin/%s' % (branch, branch),
+                           '-n', '-q')
+    git('reset', '--hard', 'origin/%s' % branch, '-q')
+    git('checkout', '-B', branch, 'origin/%s' % branch, '-q')
 
     tty.msg("Successfully created a new spack in %s" % prefix,
             "Run %s/bin/spack to use this installation." % prefix)


Test patch: