diff options
author | Tom Pollard <tom.pollard@codethink.co.uk> | 2019-06-11 10:47:37 +0100 |
---|---|---|
committer | Tom Pollard <tom.pollard@codethink.co.uk> | 2019-06-19 13:33:44 +0100 |
commit | a02cf9c14022b49d26bde7cf73369e11158d3d6b (patch) | |
tree | 66aa97003eb14de9c75577620bb0750b1aea3e65 /src/buildstream | |
parent | 9d593e1f3449dc8f24fb6855264f78882b182e3c (diff) | |
download | buildstream-a02cf9c14022b49d26bde7cf73369e11158d3d6b.tar.gz |
_frontend/cli.py: Tweak 'try' & 'always' bst shell buildtree handling
If the cached Artifact wasn't originally generated with a buildtree,
then there's no need to attempt to find it in remotes by entering
Stream(). In interactive mode we only present the user the option to
attempt the pull with the above assumption on buildtree_exists, so
apply the same to applicable non interactive choices.
This also includes some tweaks in integration/shellbuildtrees.py
to reflect changes and cover cases that were missing.
Diffstat (limited to 'src/buildstream')
-rw-r--r-- | src/buildstream/_frontend/cli.py | 17 | ||||
-rw-r--r-- | src/buildstream/_stream.py | 6 |
2 files changed, 14 insertions, 9 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py index cc8cd5e54..2301fcb78 100644 --- a/src/buildstream/_frontend/cli.py +++ b/src/buildstream/_frontend/cli.py @@ -559,11 +559,20 @@ def shell(app, element, sysroot, mount, isolate, build_, cli_buildtree, command) cached = element._cached_buildtree() buildtree_exists = element._buildtree_exists() + if cli_buildtree in ("always", "try"): - use_buildtree = cli_buildtree - if not cached and buildtree_exists and use_buildtree == "always": - click.echo("WARNING: buildtree is not cached locally, will attempt to pull from available remotes", - err=True) + if buildtree_exists: + use_buildtree = cli_buildtree + if not cached and use_buildtree == "always": + click.echo("WARNING: buildtree is not cached locally, will attempt to pull from available remotes", + err=True) + else: + if cli_buildtree == "always": + # Exit early if it won't be possible to even fetch a buildtree with always option + raise AppError("Artifact was created without buildtree, unable to launch shell with it") + else: + click.echo("WARNING: Artifact created without buildtree, shell will be loaded without it", + err=True) else: # If the value has defaulted to ask and in non interactive mode, don't consider the buildtree, this # being the default behaviour of the command diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index 76a6ba1c0..0606c906a 100644 --- a/src/buildstream/_stream.py +++ b/src/buildstream/_stream.py @@ -180,11 +180,7 @@ class Stream(): buildtree = True if not buildtree: - if element._buildtree_exists(): - message = "Buildtree is not cached locally or in available remotes" - else: - message = "Artifact was created without buildtree" - + message = "Buildtree is not cached locally or in available remotes" if usebuildtree == "always": raise StreamError(message) else: |