summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-10-10 15:40:41 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-10-11 01:55:33 -0700
commit9c5c8b22c8755a295792e164c7ca9bb141b00f8c (patch)
tree8200595089a262da6517c0ebcdf146d977975416 /lib
parentf0edfa6edf49d7e869f68a949017c5f7d8160d1d (diff)
downloadspack-9c5c8b22c8755a295792e164c7ca9bb141b00f8c.tar.gz
spack-9c5c8b22c8755a295792e164c7ca9bb141b00f8c.tar.bz2
spack-9c5c8b22c8755a295792e164c7ca9bb141b00f8c.tar.xz
spack-9c5c8b22c8755a295792e164c7ca9bb141b00f8c.zip
Fix bug in `spack debug create-db-tarball`
- Fix a bug handling '/' characters in branch names. - Make tarballs use a descriptive name for the top-level directory, not just `opt`.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/debug.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/spack/spack/cmd/debug.py b/lib/spack/spack/cmd/debug.py
index 958eb829b4..757c5bca80 100644
--- a/lib/spack/spack/cmd/debug.py
+++ b/lib/spack/spack/cmd/debug.py
@@ -23,6 +23,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import os
+import re
from datetime import datetime
from glob import glob
@@ -53,8 +54,12 @@ def _debug_tarball_suffix():
if not os.path.isdir('.git'):
return 'nobranch.nogit.%s' % suffix
+ # Get symbolic branch name and strip any special chars (mainly '/')
symbolic = git(
'rev-parse', '--abbrev-ref', '--short', 'HEAD', output=str).strip()
+ symbolic = re.sub(r'[^\w.-]', '-', symbolic)
+
+ # Get the commit hash too.
commit = git(
'rev-parse', '--short', 'HEAD', output=str).strip()
@@ -69,12 +74,23 @@ def create_db_tarball(args):
tarball_name = "spack-db.%s.tar.gz" % _debug_tarball_suffix()
tarball_path = os.path.abspath(tarball_name)
- with working_dir(spack.spack_root):
+ base = os.path.basename(spack.install_path)
+ transform_args = []
+ if 'GNU' in tar('--version', output=str):
+ transform_args = ['--transform', 's/^%s/%s/' % (base, tarball_name)]
+ else:
+ transform_args = ['-s', '/^%s/%s/' % (base, tarball_name)]
+
+ wd = os.path.dirname(spack.install_path)
+ with working_dir(wd):
files = [spack.installed_db._index_path]
- files += glob('%s/*/*/*/.spack/spec.yaml' % spack.install_path)
+ files += glob('%s/*/*/*/.spack/spec.yaml' % base)
files = [os.path.relpath(f) for f in files]
- tar('-czf', tarball_path, *files)
+ args = ['-czf', tarball_path]
+ args += transform_args
+ args += files
+ tar(*args)
tty.msg('Created %s' % tarball_name)