debian-forge/assemblers/org.osbuild.tar
Ondřej Budai 283281f047 assemblers/tar: Allow creating tar archive without any compression
In tests we often use tar assembler as final stage. This means we
compress the image tree and decompress it right away. For this purposes
it is nice to have option to not have any compression. Actually,
this could very drastically improve CI running time.

A better option would be not to use tar at all and instead let osbuild
just dump the resulting tree. However, we felt this behaviour needs
more discussion and we need a fix asap.
2019-09-10 14:55:40 +02:00

28 lines
673 B
Python
Executable file

#!/usr/bin/python3
import json
import subprocess
import sys
def main(tree, output_dir, options):
filename = options["filename"]
compression = options.get("compression")
command = ["tar", "-cf", f"{output_dir}/{filename}", "-C", tree]
if compression is not None:
if compression not in {"bzip2", "xz", "lzip", "lzma", "lzop", "gzip"}:
return 1
command.append(f"--{compression}")
command.append(".")
subprocess.run(command, stdout=subprocess.DEVNULL, check=True)
return 0
if __name__ == '__main__':
args = json.load(sys.stdin)
r = main(args["tree"], args["output_dir"], args["options"])
sys.exit(r)