osbuild: allow reading pipeline from stdin

This commit is contained in:
Lars Karlitski 2019-09-27 17:41:42 +02:00 committed by Tom Gundersen
parent 3a0a480792
commit d42b8113fa

View file

@ -13,7 +13,7 @@ RED = "\033[31m"
def main():
parser = argparse.ArgumentParser(description="Build operating system images")
parser.add_argument("pipeline_path", metavar="PIPELINE",
help="json file containing the pipeline that should be built")
help="json file containing the pipeline that should be built, or a '-' to read from stdin")
parser.add_argument("--build-pipeline", metavar="PIPELINE", type=os.path.abspath,
help="json file containing the pipeline to create a build environment")
parser.add_argument("--store", metavar="DIRECTORY", type=os.path.abspath,
@ -25,8 +25,12 @@ def main():
help="output results in JSON format")
args = parser.parse_args()
with open(args.pipeline_path) as f:
pipeline = osbuild.load(json.load(f))
if args.pipeline_path == "-":
f = sys.stdin
else:
f = open(args.pipeline_path)
pipeline = osbuild.load(json.load(f))
f.close()
if args.build_pipeline:
with open(args.build_pipeline) as f: