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 <teg@jklm.no>
This commit is contained in:
Tom Gundersen 2020-02-13 17:44:54 +01:00 committed by Lars Karlitski
parent 481213a8dd
commit e48c2f178c

View file

@ -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)