diff --git a/osbuild/formats/v1.py b/osbuild/formats/v1.py index 578afe28..2def88cb 100644 --- a/osbuild/formats/v1.py +++ b/osbuild/formats/v1.py @@ -49,7 +49,7 @@ def describe(manifest: Manifest, *, with_id=False) -> Dict: def load_assembler(description: Dict, index: Index, manifest: Manifest): pipeline = manifest["tree"] - build, base, runner = pipeline.build, pipeline.tree_id, pipeline.runner + build, base, runner = pipeline.build, pipeline.id, pipeline.runner name, options = description["name"], description.get("options", {}) # Add a pipeline with one stage for our assembler @@ -93,7 +93,7 @@ def load_pipeline(description: Dict, index: Index, manifest: Manifest, n: int = else: name = "-".join(["build"] * n) - build_id = build_pipeline and build_pipeline.tree_id + build_id = build_pipeline and build_pipeline.id pipeline = manifest.add_pipeline(name, runner, build_id) for s in description.get("stages", []): @@ -128,7 +128,7 @@ def load(description: Dict, index: Index) -> Manifest: def get_ids(manifest: Manifest) -> Tuple[Optional[str], Optional[str]]: pipeline = manifest["tree"] assembler = manifest.get("assembler") - return pipeline.tree_id, assembler and assembler.tree_id + return pipeline.id, assembler and assembler.id def output(manifest: Manifest, res: Dict) -> Dict: diff --git a/osbuild/pipeline.py b/osbuild/pipeline.py index 6c1843d7..fcd13c78 100644 --- a/osbuild/pipeline.py +++ b/osbuild/pipeline.py @@ -122,14 +122,21 @@ class Pipeline: @property def id(self): - return self.tree_id + """ + Pipeline id: corresponds to the `id` of the last stage - @property - def tree_id(self): + In contrast to `name` this identifies the pipeline via + the tree, i.e. the content, it produces. Therefore two + pipelines that produce the same `tree`, i.e. have the + same exact stages and build pipeline, will have the + same `id`; thus the `id`, in contrast to `name` does + not uniquely identify a pipeline. + In case a Pipeline has no stages, its `id` is `None`. + """ return self.stages[-1].id if self.stages else None def add_stage(self, info, options, sources_options=None): - stage = Stage(info, sources_options, self.build, self.tree_id, options or {}) + stage = Stage(info, sources_options, self.build, self.id, options or {}) self.stages.append(stage) if self.assembler: self.assembler.base = stage.id @@ -160,7 +167,7 @@ class Pipeline: # Check if the tree that we are supposed to build does # already exist. If so, short-circuit here - tree = object_store.get(self.tree_id) + tree = object_store.get(self.id) if tree: return results, build_tree, tree @@ -222,7 +229,7 @@ class Pipeline: # tree exists, we return it as well, but we do not care if it is # missing, since it is not a mandatory part of the result and would # usually be needless overhead. - obj = store.get(self.tree_id) + obj = store.get(self.id) if not obj: results, _, obj = self.build_stages(store, monitor, libdir)