bst artifact checkout removes ".bst" from end of directory names

Summary

bst artifact checkout cannot checkout to a directory that ends with ".bst". The ".bst" is stripped off of the end of the directory path, and artifacts are checked out to a directory with the shortened path.

Steps to reproduce

  1. Open a buildstream-2 project (eg the freedesktop-sdk-20.08beta.1-buildstream2/ branch of freedesktop-sdk)
  2. Check out and element, to a directory ending in ".bst", eg:
bst artifact checkout bootstrap/build/base-sdk/symlinks.bst --directory checkout_here.bst

What is the current bug behavior?

Checkout command succesfully checks out the files, but check them out in the wrong directory.

Checking out files in 'checkout_here'

What is the expected correct behavior?

Files should be checked out into the directory name specified (ending with '.bst')

Checking out files in 'checkout_here.bst'

Possible fixes

Other relevant information

  • BuildStream version affected: /milestone %BuildStream_v1.93.4 (and probably earlier).
  • It only seems to happen with '.bst', and only when it's at the end of the directory name.
    • --directory here.bst --> Checking out files in 'here'
    • --directory here --> Checking out files in 'here'
    • --directory here.foo --> Checking out files in 'here.foo'
    • --directory here.bst_ --> Checking out files in 'here.bst_'
    • --directory here.bst.bst --> Checking out files in 'here.bst'