stages/assemblers: add tree/untree assembler and stage

In the simplest case we don't need to make an image, a filesystem tree
will do. Also support using such a tree as input for further pipelines
through the untree stage.

Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
Tom Gundersen 2019-06-17 17:44:04 +02:00
parent 6ae19579c1
commit f246ccf11e
2 changed files with 44 additions and 0 deletions

24
assemblers/io.weldr.tree Executable file
View file

@ -0,0 +1,24 @@
#!/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
for name in os.listdir(tree):
srcname = os.path.join(tree, name)
dstname = os.path.join(output_tree, name)
subprocess.run(["cp", "-a", "-T", srcname, dstname], check=True)
if __name__ == '__main__':
args = json.load(sys.stdin)
r = main(args["tree"], args["output_dir"], args["options"])
sys.exit(r)

20
stages/io.weldr.untree Executable file
View file

@ -0,0 +1,20 @@
#!/usr/bin/python3
import json
import os
import subprocess
import sys
def main(tree, input_dir, options):
input_tree = os.path.join(input_dir, options["tree"])
# Initialize the tree from the tree given in the input
for name in os.listdir(input_tree):
srcname = os.path.join(input_tree, name)
dstname = os.path.join(tree, name)
subprocess.run(["cp", "-a", "-T", srcname, dstname], check=True)
if __name__ == '__main__':
args = json.load(sys.stdin)
r = main(args["tree"], args["input_dir"], args["options"])
sys.exit(r)