Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of stage symlinks #12072

Merged
merged 19 commits into from Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 15 additions & 7 deletions etc/spack/defaults/config.yaml
Expand Up @@ -37,18 +37,26 @@ config:

# Temporary locations Spack can try to use for builds.
#
# Spack will use the first one it finds that exists and is writable.
# You can use $tempdir to refer to the system default temp directory
# (as returned by tempfile.gettempdir()).
# Recommended options are given below.
#
# A value of $spack/var/spack/stage indicates that Spack should run
# builds directly inside its install directory without staging them in
# Builds can be faster in temporary directories on some (e.g., HPC) systems.
# Specifying `$tempdir` will ensure use of the system default temporary
# directory (as returned by `tempfile.gettempdir()`). Spack will append
# `spack-stage` and, if the username is not already in the path, the value
# of `$user` to the path. The latter is used to avoid conflicts between
# users in shared temporary spaces.
#
# Another option that prevents conflicts and potential permission issues is
# to specify `~/.spack/stage`, which ensures each user builds in their home
# directory.
#
# A more traditional path uses the value of `$spack/var/spack/stage`, which
# builds directly inside Spack's instance without staging them in a
# temporary space.
#
# The build stage can be purged with `spack clean --stage`.
build_stage:
- $tempdir
- $spack/var/spack/stage
- $tempdir/spack-stage


# Cache directory for already downloaded source tarballs and archived
Expand Down
16 changes: 11 additions & 5 deletions lib/spack/llnl/util/filesystem.py
Expand Up @@ -347,12 +347,18 @@ def copy_tree(src, dest, symlinks=True, ignore=None, _permissions=False):
else:
tty.debug('Copying {0} to {1}'.format(src, dest))

mkdirp(dest)
abs_src = os.path.abspath(src)
abs_dest = os.path.abspath(dest)

# Stop early to avoid unnecessary recursion if being asked to copy from a
# parent directory.
if abs_dest.startswith(abs_src):
tldahlgren marked this conversation as resolved.
Show resolved Hide resolved
raise ValueError('Cannot copy ancestor directory {0} into {1}'.
format(abs_src, abs_dest))

src = os.path.abspath(src)
dest = os.path.abspath(dest)
mkdirp(dest)

for s, d in traverse_tree(src, dest, order='pre',
for s, d in traverse_tree(abs_src, abs_dest, order='pre',
follow_symlinks=not symlinks,
ignore=ignore,
follow_nonexisting=True):
Expand All @@ -361,7 +367,7 @@ def copy_tree(src, dest, symlinks=True, ignore=None, _permissions=False):
if symlinks:
target = os.readlink(s)
if os.path.isabs(target):
new_target = re.sub(src, dest, target)
new_target = re.sub(abs_src, abs_dest, target)
if new_target != target:
tty.debug("Redirecting link {0} to {1}"
.format(target, new_target))
Expand Down
3 changes: 2 additions & 1 deletion lib/spack/spack/cmd/location.py
Expand Up @@ -14,6 +14,7 @@
import spack.environment
import spack.paths
import spack.repo
import spack.stage

description = "print out locations of packages and spack directories"
section = "basic"
Expand Down Expand Up @@ -76,7 +77,7 @@ def location(parser, args):
print(spack.repo.path.first_repo().root)

elif args.stages:
print(spack.paths.stage_path)
print(spack.stage.get_stage_root())

else:
specs = spack.cmd.parse_specs(args.spec)
Expand Down
3 changes: 2 additions & 1 deletion lib/spack/spack/compilers/clang.py
Expand Up @@ -15,6 +15,7 @@
from spack.compiler import Compiler, UnsupportedCompilerFlag
from spack.util.executable import Executable
from spack.version import ver
import spack.stage
tldahlgren marked this conversation as resolved.
Show resolved Hide resolved


#: compiler symlink mappings for mixed f77 compilers
Expand Down Expand Up @@ -282,7 +283,7 @@ def setup_custom_environment(self, pkg, env):
raise OSError(msg)

real_root = os.path.dirname(os.path.dirname(real_root))
developer_root = os.path.join(spack.paths.stage_path,
developer_root = os.path.join(spack.stage.get_stage_root(),
'xcode-select',
self.name,
str(self.version))
Expand Down
5 changes: 3 additions & 2 deletions lib/spack/spack/config.py
Expand Up @@ -101,6 +101,7 @@
'checksum': True,
'dirty': False,
'build_jobs': min(16, multiprocessing.cpu_count()),
'build_stage': '$spack/var/spack/stage',
tldahlgren marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -439,10 +440,10 @@ def get_config(self, section, scope=None):
scopes = [self._validate_scope(scope)]

merged_section = syaml.syaml_dict()
for scope in scopes:
for scope_ in scopes:
tldahlgren marked this conversation as resolved.
Show resolved Hide resolved
# read potentially cached data from the scope.

data = scope.get_section(section)
data = scope_.get_section(section)

# Skip empty configs
if not data or not isinstance(data, dict):
Expand Down
4 changes: 1 addition & 3 deletions lib/spack/spack/package.py
Expand Up @@ -1756,9 +1756,7 @@ def check_for_unfinished_installation(
else:
partial = True

stage_is_managed_in_spack = self.stage.path.startswith(
spack.paths.stage_path)
if restage and stage_is_managed_in_spack:
if restage and self.stage.managed_by_spack:
self.stage.destroy()
self.stage.create()

Expand Down
4 changes: 3 additions & 1 deletion lib/spack/spack/patch.py
Expand Up @@ -194,9 +194,11 @@ def fetch(self, stage):
fetcher = fs.URLFetchStrategy(self.url, fetch_digest)
mirror = os.path.join(
os.path.dirname(stage.mirror_path),
'mirror-stage',
tldahlgren marked this conversation as resolved.
Show resolved Hide resolved
os.path.basename(self.url))

self.stage = spack.stage.Stage(fetcher, mirror_path=mirror)
self.stage = spack.stage.Stage(fetcher, path=os.path.dirname(mirror),
mirror_path=mirror)
self.stage.create()
self.stage.fetch()
self.stage.check()
Expand Down
1 change: 0 additions & 1 deletion lib/spack/spack/paths.py
Expand Up @@ -38,7 +38,6 @@
test_path = os.path.join(module_path, "test")
hooks_path = os.path.join(module_path, "hooks")
var_path = os.path.join(prefix, "var", "spack")
stage_path = os.path.join(var_path, "stage")
repos_path = os.path.join(var_path, "repos")
share_path = os.path.join(prefix, "share", "spack")

Expand Down