From e48c2f178cb047d3872ea494206788072f13594d Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Thu, 13 Feb 2020 17:44:54 +0100 Subject: [PATCH] osbuild: allow the sources to be passed in on stdin Currently stdin is taken to be the pipeline to be built, this allows it to be instead a map containing the suorces and the pipeline. We would imagine passing around the sources and pipeline together, so this just makes the behavior of osbuild more closely match the intended use and semantics of the sources configuration. This keeps backwards compatibility for now, but that may be dropped as soon as osbuild-composer no longer relies on the old behavior. Disable too-many-{branches,statements} pylint warnings in __main__.py. These do not seem helpful, but could be reenabled if we drop some options in the future. Signed-off-by: Tom Gundersen --- osbuild/__main__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/osbuild/__main__.py b/osbuild/__main__.py index 06ef1dc3..741d8948 100755 --- a/osbuild/__main__.py +++ b/osbuild/__main__.py @@ -29,6 +29,8 @@ def mark_checkpoints(pipeline, checkpoints): return points +# pylint: disable=too-many-branches +# pylint: disable=too-many-statements def main(): parser = argparse.ArgumentParser(description="Build operating system images") parser.add_argument("pipeline_path", metavar="PIPELINE", @@ -54,10 +56,17 @@ def main(): f = sys.stdin else: f = open(args.pipeline_path) - pipeline = json.load(f) + manifest = json.load(f) f.close() - sources_options = {} + if "pipeline" in manifest: + pipeline = manifest["pipeline"] + sources_options = manifest.get("sources", {}) + else: + # backwards compatibility + pipeline = manifest + sources_options = {} + if args.sources: with open(args.sources) as f: sources_options = json.load(f)