debian-forge/assemblers/io.weldr.tree
Tom Gundersen 31a5eed4d9 stages: fix cp usage
We want to copy the contents of a directory to another, the correct
syntax for that is `cp -a src/. dst`. I was not aware of this beauty,
so the previous patch simulated the functionality in python code.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-18 09:48:35 +02:00

21 lines
532 B
Python
Executable file

#!/usr/bin/python3
import json
import os
import shutil
import subprocess
import sys
def main(tree, output_dir, options):
output_tree = os.path.join(output_dir, options["tree"])
shutil.rmtree(output_tree, ignore_errors=True)
os.makedirs(output_tree, mode=0o755)
# Copy the tree to the output directory
subprocess.run(["cp", "-a", f"{tree}/.", output_tree], check=True)
if __name__ == '__main__':
args = json.load(sys.stdin)
r = main(args["tree"], args["output_dir"], args["options"])
sys.exit(r)