nathanwilliams-ct commented on code in PR #2147:
URL: https://github.com/apache/buildstream/pull/2147#discussion_r3803200104
##########
src/buildstream/element.py:
##########
@@ -2076,6 +2091,17 @@ def _shell(self, scope=None, *, mounts=None,
isolate=False, prompt=None, command
if prompt is not None:
environment["PS1"] = prompt
+ with self.timed_activity("Staging other_targets",
silent_nested=True), self.__collect_overlaps(sandbox):
+ self.stage_dependency_artifacts(sandbox, other_elements)
+
+ if other_elements:
+ # Stage artifacts from other_elements into the sandbox.
+ for element in other_elements:
+ # Stage deps in the sandbox root
+ with element.timed_activity("Integrating sandbox"),
sandbox.batch():
+ for dep in element._dependencies(_Scope.RUN):
+ dep.integrate(sandbox)
Review Comment:
```
$ tox -e venv -- bst --directory tests/integration/project shell
manual/import-file.bst
[--:--:--][ ][ main:core activity ] START
Loading elements
[00:00:00][ ][ main:core activity ] SUCCESS
Loading elements
[--:--:--][ ][ main:core activity ] START
Resolving elements
[00:00:00][ ][ main:core activity ] SUCCESS
Resolving elements
[--:--:--][ ][ main:core activity ] START
Initializing remote caches
[00:00:00][ ][ main:core activity ] SUCCESS
Initializing remote caches
[--:--:--][ ][ main:core activity ] START Query
cache
[00:00:00][ ][ main:core activity ] SUCCESS Query
cache
[--:--:--][dc2422ef][ main:manual/import-file.bst ] START
Staging dependencies
[00:00:00][dc2422ef][ main:manual/import-file.bst ] SUCCESS
Staging dependencies
[--:--:--][dc2422ef][ main:manual/import-file.bst ] START
Integrating sandbox
[00:00:00][dc2422ef][ main:manual/import-file.bst ] SUCCESS
Integrating sandbox
[--:--:--][dc2422ef][ main:manual/import-file.bst ] STATUS
Running command
sh -i
Error launching shell: Staged artifacts do not provide command 'sh'
$ tox -e venv -- bst --directory tests/integration/project shell
manual/import-file.bst --with base/base-alpine.bst
[--:--:--][ ][ main:core activity ] START
Loading elements
/var/home/nathanwilliams/buildstream/tests/integration/project/elements/manual/import-file.bst_tempshwrznrg.bst
manual/import-file.bst_tempshwrznrg.bst
manual/import-file.bst_tempshwrznrg.bst
[00:00:00][ ][ main:core activity ] SUCCESS
Loading elements
[--:--:--][ ][ main:core activity ] START
Resolving elements
[00:00:00][ ][ main:core activity ] SUCCESS
Resolving elements
[--:--:--][ ][ main:core activity ] START
Initializing remote caches
[00:00:00][ ][ main:core activity ] SUCCESS
Initializing remote caches
[--:--:--][ ][ main:core activity ] START Query
cache
[00:00:00][ ][ main:core activity ] SUCCESS Query
cache
[--:--:--][e8d846b7][ build:manual/import-file.bst_tempshwrznrg.bst] START
test/manual-import-file.bst_tempshwrznrg/e8d846b7-build.20260818-111411.log
[--:--:--][e8d846b7][ build:manual/import-file.bst_tempshwrznrg.bst] START
Staging sources
[00:00:00][e8d846b7][ build:manual/import-file.bst_tempshwrznrg.bst]
SUCCESS Staging sources
[--:--:--][e8d846b7][ build:manual/import-file.bst_tempshwrznrg.bst] START
Caching artifact
[00:00:00][e8d846b7][ build:manual/import-file.bst_tempshwrznrg.bst]
SUCCESS Caching artifact
[00:00:00][e8d846b7][ build:manual/import-file.bst_tempshwrznrg.bst]
SUCCESS
test/manual-import-file.bst_tempshwrznrg/e8d846b7-build.20260818-111411.log
[--:--:--][ ][ main:core activity ] START
Loading elements
[00:00:00][ ][ main:core activity ] SUCCESS
Loading elements
[--:--:--][ ][ main:core activity ] START
Resolving elements
[00:00:00][ ][ main:core activity ] SUCCESS
Resolving elements
[--:--:--][ ][ main:core activity ] START
Initializing remote caches
[00:00:00][ ][ main:core activity ] SUCCESS
Initializing remote caches
[--:--:--][ ][ main:core activity ] START Query
cache
[00:00:00][ ][ main:core activity ] SUCCESS Query
cache
[--:--:--][e8d846b7][ main:manual/import-file.bst_tempshwrznrg.bst] START
Staging dependencies
[00:00:00][e8d846b7][ main:manual/import-file.bst_tempshwrznrg.bst]
SUCCESS Staging dependencies
[--:--:--][e8d846b7][ main:manual/import-file.bst_tempshwrznrg.bst] START
Integrating sandbox
[00:00:00][e8d846b7][ main:manual/import-file.bst_tempshwrznrg.bst]
SUCCESS Integrating sandbox
[--:--:--][e8d846b7][ main:manual/import-file.bst_tempshwrznrg.bst]
STATUS Running command
sh -i
[e8d846b7@manual/import-file.bst_tempshwrznrg.bst:/]$ exit
```
hmm, I went down the route of creating a temporary element.
Due to how the element loading works, it makes it almost impossible to
inject additional dependencies in at runtime. Temporary stack element would
have made buildtree ones unhelpful. Solving the overlap problem and dealing
with overlapping sandboxes and integration commands was too complicated and
messy.
The downside of using a temporary element is the shell command needs to
attempt to run a build on the temporary element, before it can shell, to cache
it's build result.
I'll tidy up my prototype with some tests and push it a bit later on.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]