23 lines
582 B
Python
Executable file
23 lines
582 B
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def main(tree, output_dir, options):
|
|
filename = options["filename"]
|
|
compression = options["compression"]
|
|
|
|
if compression not in {"bzip2", "xz", "lzip", "lzma", "lzop", "gzip"}:
|
|
return 1
|
|
|
|
subprocess.run(["tar", f"--{compression}", "-cf", f"{output_dir}/{filename}", "-C", tree, "."],
|
|
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)
|