summaryrefslogtreecommitdiff
path: root/lib/spack/spack/spec.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/spack/spec.py')
-rw-r--r--lib/spack/spack/spec.py42
1 files changed, 31 insertions, 11 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 17f206d81b..951e9ae652 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -475,10 +475,10 @@ class FlagMap(HashableMap):
def satisfies(self, other, strict=False):
if strict or (self.spec and self.spec._concrete):
- return all(f in self and set(self[f]) <= set(other[f])
+ return all(f in self and set(self[f]) == set(other[f])
for f in other)
else:
- return all(set(self[f]) <= set(other[f])
+ return all(set(self[f]) == set(other[f])
for f in other if (other[f] != [] and f in self))
def constrain(self, other):
@@ -2209,6 +2209,9 @@ class Spec(object):
${SPACK_PREFIX}/opt
${PREFIX} The package prefix
+ Note these are case-insensitive: for example you can specify either
+ ``${PACKAGE}`` or ``${package}``.
+
Optionally you can provide a width, e.g. ``$20_`` for a 20-wide name.
Like printf, you can provide '-' for left justification, e.g.
``$-20_`` for a left-justified name.
@@ -2299,6 +2302,7 @@ class Spec(object):
"'%s'" % format_string)
named_str += c
continue
+ named_str = named_str.upper()
if named_str == 'PACKAGE':
name = self.name if self.name else ''
write(fmt % self.name, '@')
@@ -2311,7 +2315,7 @@ class Spec(object):
elif named_str == 'COMPILERNAME':
if self.compiler:
write(fmt % self.compiler.name, '%')
- elif named_str == 'COMPILERVER':
+ elif named_str in ['COMPILERVER', 'COMPILERVERSION']:
if self.compiler:
write(fmt % self.compiler.versions, '%')
elif named_str == 'COMPILERFLAGS':
@@ -2392,12 +2396,24 @@ class Spec(object):
def __str__(self):
return self.format() + self.dep_string()
+ def _install_status(self):
+ """Helper for tree to print DB install status."""
+ if not self.concrete:
+ return None
+ try:
+ record = spack.store.db.get_record(self)
+ return record.installed
+ except KeyError:
+ return None
+
def tree(self, **kwargs):
"""Prints out this spec and its dependencies, tree-formatted
with indentation."""
color = kwargs.pop('color', False)
depth = kwargs.pop('depth', False)
- showid = kwargs.pop('ids', False)
+ hashes = kwargs.pop('hashes', True)
+ hlen = kwargs.pop('hashlen', None)
+ install_status = kwargs.pop('install_status', True)
cover = kwargs.pop('cover', 'nodes')
indent = kwargs.pop('indent', 0)
fmt = kwargs.pop('format', '$_$@$%@+$+$=')
@@ -2406,8 +2422,6 @@ class Spec(object):
check_kwargs(kwargs, self.tree)
out = ""
- cur_id = 0
- ids = {}
for d, node in self.traverse(
order='pre', cover=cover, depth=True, deptypes=deptypes):
if prefix is not None:
@@ -2415,11 +2429,17 @@ class Spec(object):
out += " " * indent
if depth:
out += "%-4d" % d
- if not id(node) in ids:
- cur_id += 1
- ids[id(node)] = cur_id
- if showid:
- out += "%-4d" % ids[id(node)]
+ if install_status:
+ status = node._install_status()
+ if status is None:
+ out += " " # Package isn't installed
+ elif status:
+ out += colorize("@g{[+]} ", color=color) # installed
+ else:
+ out += colorize("@r{[-]} ", color=color) # missing
+
+ if hashes:
+ out += colorize('@K{%s} ', color=color) % node.dag_hash(hlen)
out += (" " * d)
if d > 0:
out += "^"