summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-01-20 15:07:53 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2015-02-02 11:19:54 -0800
commitde91c95e8e45b8ab066ba3dfc8f89c92da761b5a (patch)
tree58a05c5103fa8c6d97c94a1d9069f09b02c9952c /lib
parentff9cb94f4f92112739f53881bcb0a9a19811684d (diff)
downloadspack-de91c95e8e45b8ab066ba3dfc8f89c92da761b5a.tar.gz
spack-de91c95e8e45b8ab066ba3dfc8f89c92da761b5a.tar.bz2
spack-de91c95e8e45b8ab066ba3dfc8f89c92da761b5a.tar.xz
spack-de91c95e8e45b8ab066ba3dfc8f89c92da761b5a.zip
Ability to ignore files in activate/deactivate for extensions.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/llnl/util/link_tree.py11
-rw-r--r--lib/spack/spack/package.py16
2 files changed, 13 insertions, 14 deletions
diff --git a/lib/spack/llnl/util/link_tree.py b/lib/spack/llnl/util/link_tree.py
index 19c2d46938..2d7126be2c 100644
--- a/lib/spack/llnl/util/link_tree.py
+++ b/lib/spack/llnl/util/link_tree.py
@@ -72,8 +72,7 @@ class LinkTree(object):
order=[pre|post] -- Whether to do pre- or post-order traveral.
- ignore=<container> -- Optional container of root-relative
- paths to ignore.
+ ignore=<predicate> -- Predicate indicating which files to ignore.
follow_nonexisting -- Whether to descend into directories in
src that do not exit in dest.
@@ -85,9 +84,7 @@ class LinkTree(object):
raise ValueError("Order must be 'pre' or 'post'.")
# List of relative paths to ignore under the src root.
- ignore = kwargs.get('ignore', None)
- if isinstance(ignore, basestring):
- ignore = (ignore,)
+ ignore = kwargs.get('ignore', lambda filename: False)
# Whether to descend when dirs dont' exist in dest.
follow_nonexisting = kwargs.get('follow_nonexisting', True)
@@ -98,7 +95,7 @@ class LinkTree(object):
dest_dirpath = os.path.join(dest_root, rel_path)
# Don't descend into ignored directories
- if ignore and dest_dirpath in ignore:
+ if ignore(dest_dirpath):
return
# Don't descend into dirs in dest that do not exist in src.
@@ -118,7 +115,7 @@ class LinkTree(object):
# Ignore particular paths inside the install root.
src_relpath = src_file[len(self._root):]
src_relpath = src_relpath.lstrip(os.path.sep)
- if ignore and src_relpath in ignore:
+ if ignore(src_relpath):
continue
yield (src_file, dest_file)
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index bd63c2e0c0..43b1fcd9c8 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -995,14 +995,15 @@ class Package(object):
always executed.
"""
- ignore_files = set(spack.install_layout.hidden_file_paths)
- ignore_files.update(kwargs.get('ignore', ()))
+ def ignore(filename):
+ return (filename in spack.install_layout.hidden_file_paths or
+ kwargs.get('ignore', lambda f: False)(filename))
tree = LinkTree(extension.prefix)
- conflict = tree.find_conflict(self.prefix, ignore=ignore_files)
+ conflict = tree.find_conflict(self.prefix, ignore=ignore)
if conflict:
raise ExtensionConflictError(conflict)
- tree.merge(self.prefix, ignore=ignore_files)
+ tree.merge(self.prefix, ignore=ignore)
def do_deactivate(self):
@@ -1026,11 +1027,12 @@ class Package(object):
always executed.
"""
- ignore_files = set(spack.install_layout.hidden_file_paths)
- ignore_files.update(kwargs.get('ignore', ()))
+ def ignore(filename):
+ return (filename in spack.install_layout.hidden_file_paths or
+ kwargs.get('ignore', lambda f: False)(filename))
tree = LinkTree(extension.prefix)
- tree.unmerge(self.prefix, ignore=ignore_files)
+ tree.unmerge(self.prefix, ignore=ignore)
def do_clean(self):