diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-09-10 20:19:43 -0400 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-09-10 23:02:21 -0400 |
commit | 9270d4214cfb66088dd8cf67123047229a08a541 (patch) | |
tree | 225cc25b37c3e1f0f05efb5588781f8d6743a154 | |
parent | 4780f71105e6494cb63a34e551cba1a4e8c75a37 (diff) | |
download | buildstream-9270d4214cfb66088dd8cf67123047229a08a541.tar.gz |
_frontend/main.py: Changes to the bst shell command
bst shell command is now an optional argument, which
defaults to ['sh', '-i']. This allows one to override
the command including the shell, so one need not invoke
the shell, thus it fixes issue #86.
Instead of an option. This means we can pick up a complete command
line after the '--' token directly from the remaining argument vector,
which makes escaping of things a bit less complicated.
E.g.:
bst shell --scope run <target.bst> -- sh -c "echo Hello World"
Further, the --scope argument is removed in favor of defaulting
to the --scope=run behavior, and adding a --build option
(use `bst shell --build <target>` for build shells, otherwise
juse use `bst shell <target>` for run shells).
Finally, the --builddir has been renamed to --sysroot; which
a bit more accurately describes what it is.
-rw-r--r-- | buildstream/_frontend/main.py | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py index b50e08568..87d89afb4 100644 --- a/buildstream/_frontend/main.py +++ b/buildstream/_frontend/main.py @@ -456,37 +456,38 @@ def show(app, target, variant, deps, except_, order, format): # Shell Command # ################################################################## @cli.command(short_help="Shell into an element's sandbox environment") -@click.option('--builddir', '-b', default=None, +@click.option('--build', '-b', is_flag=True, default=False, + help='Create a build sandbox') +@click.option('--sysroot', '-s', default=None, type=click.Path(exists=True, file_okay=False, readable=True), - help="Existing build directory") -@click.option('--scope', '-s', default=None, - type=click.Choice(['build', 'run']), - help='Specify element scope to stage') -@click.option('--command', '-c', metavar='COMMAND', default=None, type=click.STRING, - help='Specify command to execute') + help="An existing sysroot") @click.option('--variant', help='A variant of the specified target') @click.argument('target', type=click.Path(dir_okay=False, readable=True)) +@click.argument('command', type=click.STRING, nargs=-1) @click.pass_obj -def shell(app, target, variant, builddir, scope, command): - """Shell into an element's sandbox environment +def shell(app, target, variant, sysroot, build, command): + """Run a command in the target element's sandbox environment - This can be used either to debug building or to launch - test and debug successful build results. + This will first stage a temporary sysroot for running + the target element, assuming it has already been built + and all required artifacts are in the local cache. - Use the --builddir option with an existing build directory - or use the --scope option instead to create a new staging - area automatically. - """ - if builddir is None and scope is None: - click.echo("Must specify either --builddir or --scope") - sys.exit(1) + Use the --build option to create a temporary sysroot for + building the element instead. - if scope == "run": - scope = Scope.RUN - elif scope == "build": + Use the --sysroot option with an existing failed build + directory or with a checkout of the given target, in order + to use a specific sysroot. + + If no COMMAND is specified, the default is to attempt + to run an interactive shell with `sh -i`. + """ + if build: scope = Scope.BUILD + else: + scope = Scope.RUN app.initialize(target, variant) @@ -507,7 +508,7 @@ def shell(app, target, variant, builddir, scope, command): sys.exit(-1) try: - exitcode = app.pipeline.target._shell(scope, builddir, command=command) + exitcode = app.pipeline.target._shell(scope, sysroot, command=command) sys.exit(exitcode) except _BstError as e: click.echo("") |