osbuild: move mark_checkpoints to manifest
Make the checkpoint marking logic a method of the Manifest class.
This commit is contained in:
parent
d25936a028
commit
8d2c7f8160
2 changed files with 28 additions and 28 deletions
|
|
@ -23,33 +23,6 @@ RED = "\033[31m"
|
|||
GREEN = "\033[32m"
|
||||
|
||||
|
||||
def mark_checkpoints(pipeline, checkpoints):
|
||||
points = set(checkpoints)
|
||||
|
||||
def mark_stage(stage):
|
||||
c = stage.id
|
||||
if c in points:
|
||||
stage.checkpoint = True
|
||||
points.remove(c)
|
||||
|
||||
def mark_assembler(assembler):
|
||||
c = assembler.id
|
||||
if c in points:
|
||||
assembler.checkpoint = True
|
||||
points.remove(c)
|
||||
|
||||
def mark_pipeline(pl):
|
||||
for stage in pl.stages:
|
||||
mark_stage(stage)
|
||||
if pl.assembler:
|
||||
mark_assembler(pl.assembler)
|
||||
if pl.build:
|
||||
mark_pipeline(pl.build)
|
||||
|
||||
mark_pipeline(pipeline)
|
||||
return points
|
||||
|
||||
|
||||
def parse_manifest(path):
|
||||
if path == "-":
|
||||
manifest = json.load(sys.stdin)
|
||||
|
|
@ -120,7 +93,7 @@ def osbuild_cli():
|
|||
pipeline = manifest.pipeline
|
||||
|
||||
if args.checkpoint:
|
||||
missed = mark_checkpoints(pipeline, args.checkpoint)
|
||||
missed = manifest.mark_checkpoints(args.checkpoint)
|
||||
if missed:
|
||||
for checkpoint in missed:
|
||||
print(f"Checkpoint {BOLD}{checkpoint}{RESET} not found!")
|
||||
|
|
|
|||
|
|
@ -339,6 +339,33 @@ class Manifest:
|
|||
return self.pipeline.run(store, monitor, libdir, output_directory)
|
||||
|
||||
|
||||
def mark_checkpoints(self, checkpoints):
|
||||
points = set(checkpoints)
|
||||
|
||||
def mark_stage(stage):
|
||||
c = stage.id
|
||||
if c in points:
|
||||
stage.checkpoint = True
|
||||
points.remove(c)
|
||||
|
||||
def mark_assembler(assembler):
|
||||
c = assembler.id
|
||||
if c in points:
|
||||
assembler.checkpoint = True
|
||||
points.remove(c)
|
||||
|
||||
def mark_pipeline(pl):
|
||||
for stage in pl.stages:
|
||||
mark_stage(stage)
|
||||
if pl.assembler:
|
||||
mark_assembler(pl.assembler)
|
||||
if pl.build:
|
||||
mark_pipeline(pl.build)
|
||||
|
||||
mark_pipeline(self.pipeline)
|
||||
return points
|
||||
|
||||
|
||||
def detect_host_runner():
|
||||
"""Use os-release(5) to detect the runner for the host"""
|
||||
osname = osrelease.describe_os(*osrelease.DEFAULT_PATHS)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue