`bst artifact checkout --tar` should allow compression

Background

bst artifact checkout --tar is provided as a simple way to produce a tarball output of a BuildStream element - this means that we can retrieve our output in a distributable form without having to create a dedicated element for that. However, if we want to also compress our artifact (as is typical for this sort of thing), we need to run our compression tool separately. This is annoying (although admittedly a very minor thing).

Python allows compressing tarfiles, so this is fairly trivial to achieve. There is a question of reproducibility here, since the details of the compression algorithm will depend on the python version, but given that we already allow python to create a tarfile (whose precise format can change slightly) in the first place this seems to be acceptable.

Task description

We should make BuildStream compress tarfiles when the user wants to do so. I suggest making BuildStream "do what I mean" by default, in other words, if I create a file named "hello.tar.gz", I expect it to be compressed with gzip. We'd mimick GNU-tar's behavior this way, making the --tar option a bit more intuitive at the same time. We should probably also add compression flags to allow users to override BuildStream's detection.

In a nutshell, we should:

  • Make BuildStream compress artifacts checked out using bst artifact checkout --tar according to the file name by default.
  • Add flags to allow users to override the default to the command (stay consistent with GNU tar flags).

hint: The relevant code mostly lives in __frontend/cli.py and _stream.py (line 515 and onwards).

Acceptance Criteria

  • BuildStream provides an interface that allows checking out artifacts as a compressed tarball.

Edited by Tristan Maat
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information