diff options
-rw-r--r-- | src/buildstream/_artifactelement.py | 16 | ||||
-rw-r--r-- | src/buildstream/_stream.py | 28 |
2 files changed, 24 insertions, 20 deletions
diff --git a/src/buildstream/_artifactelement.py b/src/buildstream/_artifactelement.py index cfd3c29c8..b8ea4c1e8 100644 --- a/src/buildstream/_artifactelement.py +++ b/src/buildstream/_artifactelement.py @@ -119,6 +119,22 @@ class ArtifactElement(Element): artifact = self._get_artifact() return artifact.get_dependency_refs(deps=scope) + # configure_sandbox() + # + # Configure a sandbox for installing artifacts into + # + # Args: + # sandbox (Sandbox) + # + def configure_sandbox(self, sandbox): + install_root = self.get_variable('install-root') + + # Tell the sandbox to mount the build root and install root + sandbox.mark_directory(install_root) + + # Tell sandbox which directory is preserved in the finished artifact + sandbox.set_output_directory(install_root) + # Override Element._calculate_cache_key def _calculate_cache_key(self, dependencies=None): return self._key diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index 0567b3ceb..ca8ca7863 100644 --- a/src/buildstream/_stream.py +++ b/src/buildstream/_stream.py @@ -29,7 +29,6 @@ import tempfile from contextlib import contextmanager, suppress from fnmatch import fnmatch -from ._artifact import Artifact from ._artifactelement import verify_artifact_ref, ArtifactElement from ._exceptions import StreamError, ImplError, BstError, ArtifactElementError, ArtifactError from ._message import Message, MessageType @@ -559,26 +558,15 @@ class Stream(): self._context.disable_fork() - # Stage deps into a temporary sandbox first - if isinstance(target, ArtifactElement): - try: - key = target._get_cache_key() - artifact = Artifact(target, self._context, strong_key=key) - virdir = artifact.get_files() + try: + with target._prepare_sandbox(scope=scope, directory=None, + integrate=integrate) as sandbox: + # Copy or move the sandbox to the target directory + virdir = sandbox.get_virtual_directory() self._export_artifact(tar, location, compression, target, hardlinks, virdir) - except AttributeError as e: - raise ArtifactError("Artifact reference '{}' seems to be invalid. " - "Note that an Element name can also be used.".format(artifact))from e - else: - try: - with target._prepare_sandbox(scope=scope, directory=None, - integrate=integrate) as sandbox: - # Copy or move the sandbox to the target directory - virdir = sandbox.get_virtual_directory() - self._export_artifact(tar, location, compression, target, hardlinks, virdir) - except BstError as e: - raise StreamError("Error while staging dependencies into a sandbox" - ": '{}'".format(e), detail=e.detail, reason=e.reason) from e + except BstError as e: + raise StreamError("Error while staging dependencies into a sandbox" + ": '{}'".format(e), detail=e.detail, reason=e.reason) from e def _export_artifact(self, tar, location, compression, target, hardlinks, virdir): if not tar: |