summaryrefslogtreecommitdiff
path: root/src/buildstream/_stream.py
diff options
context:
space:
mode:
authorRaoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk>2019-06-13 11:50:39 +0100
committerRaoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk>2019-06-24 11:42:55 +0100
commit86330faf4f0ababde265f1ac3e86733d1908ed44 (patch)
tree327c9a04ca618d555ec963f5692c3895b1b15bcf /src/buildstream/_stream.py
parentc69a6ee7a464bc651567e67217c8c093cc956f88 (diff)
downloadbuildstream-86330faf4f0ababde265f1ac3e86733d1908ed44.tar.gz
_stream/cli: Add pull option to shell
This will fetch artifacts if they're not local or are incomplete. Part of #1044
Diffstat (limited to 'src/buildstream/_stream.py')
-rw-r--r--src/buildstream/_stream.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index 6f6d30f17..8097f451d 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -140,6 +140,7 @@ class Stream():
# isolate (bool): Whether to isolate the environment like we do in builds
# command (list): An argv to launch in the sandbox, or None
# usebuildtree (str): Whether to use a buildtree as the source, given cli option
+ # pull_dependencies ([Element]|None): Elements to attempt to pull
#
# Returns:
# (int): The exit code of the launched shell
@@ -149,20 +150,27 @@ class Stream():
mounts=None,
isolate=False,
command=None,
- usebuildtree=None):
+ usebuildtree=None,
+ pull_dependencies=None):
# Assert we have everything we need built, unless the directory is specified
# in which case we just blindly trust the directory, using the element
# definitions to control the execution environment only.
if directory is None:
missing_deps = [
- dep._get_full_name()
- for dep in self._pipeline.dependencies([element], scope)
+ dep for dep in self._pipeline.dependencies([element], scope)
if not dep._cached()
]
if missing_deps:
- raise StreamError("Elements need to be built or downloaded before staging a shell environment",
- detail="\n".join(missing_deps))
+ if not pull_dependencies:
+ raise StreamError(
+ "Elements need to be built or downloaded before staging a shell environment",
+ detail="\n"
+ .join(list(map(lambda x: x._get_full_name(), missing_deps))))
+ self._message(MessageType.INFO, "Attempting to fetch missing or incomplete artifacts")
+ self._add_queue(PullQueue(self._scheduler))
+ self._enqueue_plan([element] + missing_deps)
+ self._run()
buildtree = False
# Check if we require a pull queue attempt, with given artifact state and context