osbuild-mpp: Support mpp-pipelines to include all or a subset of the pipelines
This makes a lot of sense, as some include could be built in a way the includer doesn't know about that requires sub-pipelines.
This commit is contained in:
parent
180e853c23
commit
29ecb1df67
1 changed files with 38 additions and 7 deletions
|
|
@ -35,6 +35,25 @@ The parameters for this pre-processor for format version "2" look like this:
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Version "2" also supports including multiple (or all) pipelines from a manifest:
|
||||||
|
|
||||||
|
```
|
||||||
|
...
|
||||||
|
"mpp-import-pipelines": {
|
||||||
|
"path": "./manifest2.json",
|
||||||
|
}
|
||||||
|
...
|
||||||
|
```
|
||||||
|
```
|
||||||
|
...
|
||||||
|
"mpp-import-pipelines": {
|
||||||
|
"path": "./manifest3.json",
|
||||||
|
"ids:" ["build", "image"]
|
||||||
|
}
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Depsolving:
|
Depsolving:
|
||||||
|
|
||||||
|
|
@ -1002,9 +1021,14 @@ class ManifestFileV2(ManifestFile):
|
||||||
raise ValueError(f"Pipeline '{name}' not found in {self.path}")
|
raise ValueError(f"Pipeline '{name}' not found in {self.path}")
|
||||||
|
|
||||||
def _process_import(self, pipeline, search_dirs):
|
def _process_import(self, pipeline, search_dirs):
|
||||||
mpp = self.get_mpp_node(pipeline, "import-pipeline")
|
mpp = self.get_mpp_node(pipeline, "import-pipelines")
|
||||||
if not mpp:
|
if mpp:
|
||||||
return
|
ids = mpp.get("ids")
|
||||||
|
else:
|
||||||
|
mpp = self.get_mpp_node(pipeline, "import-pipeline")
|
||||||
|
if not mpp:
|
||||||
|
return [pipeline] # Not an import
|
||||||
|
ids = [mpp["id"]]
|
||||||
|
|
||||||
path = mpp["path"]
|
path = mpp["path"]
|
||||||
imp = self.load_import(path, search_dirs)
|
imp = self.load_import(path, search_dirs)
|
||||||
|
|
@ -1025,12 +1049,19 @@ class ManifestFileV2(ManifestFile):
|
||||||
items = element_enter(target, "items", {})
|
items = element_enter(target, "items", {})
|
||||||
items.update(desc.get("items", {}))
|
items.update(desc.get("items", {}))
|
||||||
|
|
||||||
target = imp.get_pipeline_by_name(mpp["id"])
|
# Copy order from included file
|
||||||
pipeline.update(target)
|
imp_pipelines = []
|
||||||
|
for imp_pipeline in imp.pipelines:
|
||||||
|
if not ids or imp_pipeline.get("name") in ids:
|
||||||
|
# Merge whatever keys was in the mpp-import-pipelines into the imported pipelines
|
||||||
|
imp_pipelines.append({**pipeline, **imp_pipeline})
|
||||||
|
return imp_pipelines
|
||||||
|
|
||||||
def process_imports(self, search_dirs):
|
def process_imports(self, search_dirs):
|
||||||
for pipeline in self.pipelines:
|
old_pipelines = self.pipelines.copy()
|
||||||
self._process_import(pipeline, search_dirs)
|
self.pipelines.clear()
|
||||||
|
for pipeline in old_pipelines:
|
||||||
|
self.pipelines.extend(self._process_import(pipeline, search_dirs))
|
||||||
|
|
||||||
def _process_depsolve(self, solver, stage, pipeline_name):
|
def _process_depsolve(self, solver, stage, pipeline_name):
|
||||||
if stage.get("type", "") != "org.osbuild.rpm":
|
if stage.get("type", "") != "org.osbuild.rpm":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue