Skip to content

cli: Add --buildtree and --buildroot to bst artifact checkout - #2129

Merged
abderrahim merged 1 commit into
apache:masterfrom
ownik:master
Oct 12, 2026
Merged

abderrahim merged 1 commit into
apache:masterfrom
ownik:master

Conversation

@ownik

@ownik ownik commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds a "--use-buildtrees" option to "bst artifacts checkout", similar to the existing option in "bst shell".

The goal is to make it possible to check out build artifacts from the sandbox build tree when it is available.

Would be okay with adding this functionality, or are there reasons not to expose it through "bst artifacts checkout"? Or is there another way to get build artifacts from sandbox now?

Fixes #1822

@ownik

ownik commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

@BenjaminSchubert @abderrahim @cs-shadow @gtristan @juergbi I've made changes to verify that buildtree exists in the cache, similar to the shell command. Could you please review, please?

@abderrahim

Copy link
Copy Markdown
Contributor

Looks like this is fixing #1822, please link the issue in your PR. Also please add a test for this behaviour.

I'll try to review it today.

@abderrahim

Copy link
Copy Markdown
Contributor

A few things need to be considered in the design of this feature:

  • Someone recently suggested to implement this as a flag to source checkout rather than artifact checkout. It kinda makes sense that the build tree is related to the source, but it's also stored as part of the artifact. Maybe it makes sense to move it to a separate toplevel command? something like bst buildtree checkout?
  • This is currently checking out the buildroot rather than what is traditionally considered a "build tree". This means it can work with both build elements and non-build-elements, but it also means we get a whole sandbox with the dependencies, the build tree, and even the artifact (if the build succeeded) which is probably not what people asking for the build tree are looking for.
  • if we go with a new toplevel command, we might want to expose options to checkout either the build tree or the build root.

@ownik
ownik force-pushed the master branch 2 times, most recently from 79fb228 to fa9662a Compare June 9, 2026 12:35
@ownik

ownik commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@abderrahim Thanks for the feedback! I've reworked the implementation into a new bst buildtree checkout command. By default it checks out the buildtree, and a --buildroot option can be used to export the entire buildroot instead.

I've also added an integration test covering the new command and link the issue in PR.

@ownik ownik changed the title cli: add --use-buildtrees option for artifacts checkout cli: add buildtree checkout command Jun 9, 2026
@ownik

ownik commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

@abderrahim Any chance to review this PR?

@abderrahim abderrahim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contributions. See my comments below.

Comment thread src/buildstream/_stream.py Outdated
Comment on lines +947 to +951
# self.targets contains a list of the loaded target objects
# if we specify --deps build, Stream._load() will return a list
# of build dependency objects, however, we need to prepare a sandbox
# with the target (which has had its appropriate dependencies loaded)
element: Element = self.targets[0]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this make sense for the build tree? Either we're checking out just the buildtree, and then dependencies don't make sense, or we check out the whole buildroot and it already contains the build dependencies.

Am I missing something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delayed response, and thanks for pointing this out.

Yes, you're right. I've changed this to element: Element = elements[0], is it ok?

Comment thread src/buildstream/_stream.py Outdated
Comment thread src/buildstream/_stream.py Outdated
Comment thread tests/integration/buildtree.py Outdated
Comment thread tests/integration/buildtree.py Outdated
@ownik
ownik force-pushed the master branch 2 times, most recently from f2fb37c to a634866 Compare August 10, 2026 07:15
@juergbi

juergbi commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Someone recently suggested to implement this as a flag to source checkout rather than artifact checkout. It kinda makes sense that the build tree is related to the source, but it's also stored as part of the artifact. Maybe it makes sense to move it to a separate toplevel command? something like bst buildtree checkout?

I think bst artifact checkout was actually a reasonable place for this feature. The build tree is part of the artifact. While the source is normally also part of the build tree in BuildStream, the buildtree checkout still operates solely on the artifact and there is no direct involvement of the source (plugin). The build tree is (optionally) pushed/pulled as part of bst artifact push/pull, not bst source push/pull and I assume we also don't intend to add bst buildtree push/pull. Or are there any ideas for further bst buildtree subcommands, which could make the new buildtree command group more useful?

If most people feel a separate top-level command makes sense, I won't object, but I'm not personally convinced so far. While this is not a democracy, feel free to 👍️ on this comment if you prefer this feature to be in bst artifact checkout or 👎️ if you think bst buildtree checkout is a better fit.

@ownik

ownik commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

@juergbi Agreed, I've moved it to bst artifact checkout as --buildtree and --buildroot options and dropped the bst buildtree group. This also lets it reuse the existing --tar/--compression/--hardlinks/--directory handling. --deps and --integrate are rejected with these options, as only the target artifact is used.

Comment thread tests/integration/checkoutbuildtrees.py Outdated
Allow checking out the cached build tree or the whole build root of an
element's artifact. Only the target artifact is pulled, as with
`bst shell --use-buildtree`, the pull-buildtrees configuration is needed
if the build tree is not available locally.

Fixed apache#1822
@ownik ownik changed the title cli: add buildtree checkout command cli: Add --buildtree and --buildroot to bst artifact checkout Oct 11, 2026
@abderrahim
abderrahim merged commit a065012 into apache:master Oct 12, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support checkout for failure buildtrees

3 participants