From ffffb87dea7a89ed08ba4025af0c1b2789b56b20 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 2 Jul 2019 22:38:20 +0200 Subject: [PATCH] osbuild.py/pipeline: introduce the concept of a base pipeline This allows one pipline to build on top of another. When the pipeline id of one pipeline is specified in another, the tree is initialized with the output of the given pipeline. The caller must ensure that the base pipeline has alreday been run, and its content is in the content-store. This renders the io.weldr.untree stage and the --input argument both redundant. Signed-off-by: Tom Gundersen --- osbuild.py | 8 +++++++- samples/base-qcow2.json | 9 +-------- samples/base-targz.json | 9 +-------- samples/base-with-grub2.json | 7 +------ samples/base-with-locale.json | 7 +------ samples/base-with-selinux.json | 7 +------ 6 files changed, 12 insertions(+), 35 deletions(-) diff --git a/osbuild.py b/osbuild.py index 7cf7190e..8b799e91 100644 --- a/osbuild.py +++ b/osbuild.py @@ -209,7 +209,8 @@ class Pipeline: m.update(json.dumps(pipeline, sort_keys=True).encode()) self.id = m.hexdigest() - self.stages = pipeline["stages"] + self.base = pipeline.get("base") + self.stages = pipeline.get("stages", []) self.assembler = pipeline.get("assembler") self.objects = objects @@ -220,6 +221,11 @@ class Pipeline: "stages": [] } with BuildRoot() as buildroot, tmpfs() as tree: + if self.base: + input_tree = os.path.join(self.objects, self.base) + + subprocess.run(["cp", "-a", f"{input_tree}/.", tree], check=True) + for i, stage in enumerate(self.stages, start=1): name = stage["name"] options = stage.get("options", {}) diff --git a/samples/base-qcow2.json b/samples/base-qcow2.json index f328531f..161ed603 100644 --- a/samples/base-qcow2.json +++ b/samples/base-qcow2.json @@ -1,13 +1,6 @@ { "name": "base-qcow2", - "stages": [ - { - "name": "io.weldr.untree", - "options": { - "tree": "efc7b094c174d9f5fd66c863db7128415f5df0f073125716f5279554f13a659f" - } - } - ], + "base": "f571638c0a21a7141e2391d476433c1679831e4f21df6555c2ef53c4446b7603", "assembler": { "name": "io.weldr.qcow2", diff --git a/samples/base-targz.json b/samples/base-targz.json index afddb1ff..52f4a949 100644 --- a/samples/base-targz.json +++ b/samples/base-targz.json @@ -1,13 +1,6 @@ { "name": "base-targz", - "stages": [ - { - "name": "io.weldr.untree", - "options": { - "tree": "1f663f817473ffa5b01241b17adbd71bc734962313f5d4eef230073c0ac5884e" - } - } - ], + "base": "1f663f817473ffa5b01241b17adbd71bc734962313f5d4eef230073c0ac5884e" "assembler": { "name": "io.weldr.targz", "options": { diff --git a/samples/base-with-grub2.json b/samples/base-with-grub2.json index ac3461e4..7a898bc7 100644 --- a/samples/base-with-grub2.json +++ b/samples/base-with-grub2.json @@ -1,12 +1,7 @@ { "name": "base-with-grub2", + "base": "1f663f817473ffa5b01241b17adbd71bc734962313f5d4eef230073c0ac5884e", "stages": [ - { - "name": "io.weldr.untree", - "options": { - "tree": "1f663f817473ffa5b01241b17adbd71bc734962313f5d4eef230073c0ac5884e" - } - }, { "name": "io.weldr.grub2", "systemResourcesFromEtc": ["/etc/grub.d"], diff --git a/samples/base-with-locale.json b/samples/base-with-locale.json index b64ba71f..fb1bb261 100644 --- a/samples/base-with-locale.json +++ b/samples/base-with-locale.json @@ -1,12 +1,7 @@ { "name": "base-with-locale", + "base": "1f663f817473ffa5b01241b17adbd71bc734962313f5d4eef230073c0ac5884e", "stages": [ - { - "name": "io.weldr.untree", - "options": { - "tree": "1f663f817473ffa5b01241b17adbd71bc734962313f5d4eef230073c0ac5884e" - } - }, { "name": "io.weldr.locale", "options": { diff --git a/samples/base-with-selinux.json b/samples/base-with-selinux.json index 11fcc9ce..f72dcac0 100644 --- a/samples/base-with-selinux.json +++ b/samples/base-with-selinux.json @@ -1,12 +1,7 @@ { "name": "base-with-selinux", + "base": "1f663f817473ffa5b01241b17adbd71bc734962313f5d4eef230073c0ac5884e", "stages": [ - { - "name": "io.weldr.untree", - "options": { - "tree": "1f663f817473ffa5b01241b17adbd71bc734962313f5d4eef230073c0ac5884e" - } - }, { "name": "io.weldr.selinux", "options": {