Stack elements output empty "bst" directory

Summary

Any stack element (with 0 or more dependencies) seems to output a bst directory that is empty, when none of its dependencies are providing that.

Steps to reproduce

# Go to a temporary directory
mkdir test; cd test

# Create a BuildStream project
bst init --project-name test

# Create hello.txt to serve as input
echo hello > hello.txt

# Create our import element
cat >elements/hello.bst <<EOF
kind: import
sources:
- kind: local
  path: hello.txt
EOF

# Create our stack element
cat >elements/target.bst <<EOF
kind: stack
depends:
- hello.bst
EOF

# Build the target
bst build target.bst

What is the current bug behavior?

Checking out target.bst produces a hello.txt as expected, but also contains an empty bst directory.

# Checkout original element to sanity check
$ bst artifact checkout --directory orig hello.bst
$ find orig
orig
orig/hello.txt

# Now, checkout our target
$ bst artifact checkout --directory target target.bst
$ find target
target
target/hello.txt
target/bst

The same bug can also be reproduced with a stack element that has no dependencies, so something like the following also produces the same error:

# Write a test target with no deps
$ cat >elements/newtarget.bst <<EOF
kind: stack
EOF

# Build, checkout
$ bst build newtarget.bst
$ bst artifact checkout --directory newtarget newtarget.bst
$ find newtarget
newtarget
newtarget/bst

What is the expected correct behavior?

The output of stack element should not include the bst directory unless one of the dependencies include it explicitly.

Relevant logs and/or screenshots

Possible fixes

Other relevant information

  • BuildStream version affected: master @ b9eec0ca