From 603c61a0333df56c0a0970c33b833b9c5193227f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= Date: Fri, 19 Aug 2022 23:21:36 +0200 Subject: [PATCH] ostree: Add unified core mode for compose in rpm-ostree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rpm-ostree is moving to unified core composes and this is now working for Silverblue & Kinoite. This is untested for IoT but they should move to os-build with Fedora 37. See: https://github.com/coreos/rpm-ostree/issues/729 Merges: https://pagure.io/pungi/pull-request/1626 Signed-off-by: Timothée Ravier --- doc/configuration.rst | 2 ++ doc/examples.rst | 2 ++ pungi/checks.py | 2 ++ pungi/ostree/__init__.py | 5 +++++ pungi/ostree/tree.py | 4 ++++ pungi/phases/ostree.py | 1 + tests/test_ostree_phase.py | 1 + tests/test_ostree_script.py | 16 ++++++++++++++++ 8 files changed, 33 insertions(+) diff --git a/doc/configuration.rst b/doc/configuration.rst index 4bf64ade..8602a520 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1707,6 +1707,8 @@ repository with a new commit. * ``force_new_commit`` -- (*bool*) Do not use rpm-ostree's built-in change detection. Defaults to ``False``. + * ``unified_core`` -- (*bool*) Use rpm-ostree in unified core mode for composes. + Defaults to ``False``. * ``version`` -- (*str*) Version string to be added as versioning metadata. If this option is set to ``!OSTREE_VERSION_FROM_LABEL_DATE_TYPE_RESPIN``, a value will be generated automatically as ``$VERSION.$RELEASE``. diff --git a/doc/examples.rst b/doc/examples.rst index 0370fa69..aef18e34 100644 --- a/doc/examples.rst +++ b/doc/examples.rst @@ -332,6 +332,8 @@ This is a shortened configuration for Fedora Radhide compose as of 2019-10-14. "tag_ref": False, # Don't use change detection in ostree. "force_new_commit": True, + # Use unified core mode for rpm-ostree composes + "unified_core": True, # This is the location for the repo where new commit will be # created. Note that this is outside of the compose dir. "ostree_repo": "/mnt/koji/compose/ostree/repo/", diff --git a/pungi/checks.py b/pungi/checks.py index 14ad674e..0f339556 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -1027,6 +1027,7 @@ def make_schema(): }, "update_summary": {"type": "boolean"}, "force_new_commit": {"type": "boolean"}, + "unified_core": {"type": "boolean"}, "version": {"type": "string"}, "config_branch": {"type": "string"}, "tag_ref": {"type": "boolean"}, @@ -1061,6 +1062,7 @@ def make_schema(): "failable": {"$ref": "#/definitions/list_of_strings"}, "update_summary": {"type": "boolean"}, "force_new_commit": {"type": "boolean"}, + "unified_core": {"type": "boolean"}, "version": {"type": "string"}, "config_branch": {"type": "string"}, "tag_ref": {"type": "boolean"}, diff --git a/pungi/ostree/__init__.py b/pungi/ostree/__init__.py index 03a02a73..49162692 100644 --- a/pungi/ostree/__init__.py +++ b/pungi/ostree/__init__.py @@ -65,6 +65,11 @@ def main(args=None): action="store_true", help="do not use rpm-ostree's built-in change detection", ) + treep.add_argument( + "--unified-core", + action="store_true", + help="use unified core mode in rpm-ostree", + ) installerp = subparser.add_parser( "installer", help="Create an OSTree installer image" diff --git a/pungi/ostree/tree.py b/pungi/ostree/tree.py index a2ee379d..1ba138b3 100644 --- a/pungi/ostree/tree.py +++ b/pungi/ostree/tree.py @@ -43,6 +43,9 @@ class Tree(OSTree): # because something went wrong. "--touch-if-changed=%s.stamp" % self.commitid_file, ] + if self.unified_core: + # See https://github.com/coreos/rpm-ostree/issues/729 + cmd.append("--unified-core") if self.version: # Add versioning metadata cmd.append("--add-metadata-string=version=%s" % self.version) @@ -121,6 +124,7 @@ class Tree(OSTree): self.extra_config = self.args.extra_config self.ostree_ref = self.args.ostree_ref self.force_new_commit = self.args.force_new_commit + self.unified_core = self.args.unified_core if self.extra_config or self.ostree_ref: if self.extra_config: diff --git a/pungi/phases/ostree.py b/pungi/phases/ostree.py index 2fcfce6c..cbfcd76e 100644 --- a/pungi/phases/ostree.py +++ b/pungi/phases/ostree.py @@ -165,6 +165,7 @@ class OSTreeThread(WorkerThread): ("update-summary", config.get("update_summary", False)), ("ostree-ref", config.get("ostree_ref")), ("force-new-commit", config.get("force_new_commit", False)), + ("unified-core", config.get("unified_core", False)), ] ) packages = ["pungi", "ostree", "rpm-ostree"] diff --git a/tests/test_ostree_phase.py b/tests/test_ostree_phase.py index b214a127..40c99076 100644 --- a/tests/test_ostree_phase.py +++ b/tests/test_ostree_phase.py @@ -325,6 +325,7 @@ class OSTreeThreadTest(helpers.PungiTestCase): "ostree-ref": None, "force-new-commit": False, "version": None, + "unified-core": False, }, channel=None, mounts=[self.topdir, self.repo], diff --git a/tests/test_ostree_script.py b/tests/test_ostree_script.py index c32ce466..b6710e57 100644 --- a/tests/test_ostree_script.py +++ b/tests/test_ostree_script.py @@ -238,6 +238,22 @@ class OstreeTreeScriptTest(helpers.PungiTestCase): self.assertCorrectCall(run, extra_args=["--force-nocache"]) + @mock.patch("kobo.shortcuts.run") + def test_unified_core(self, run): + helpers.touch(os.path.join(self.repo, "initialized")) + + ostree.main( + [ + "tree", + "--repo=%s" % self.repo, + "--log-dir=%s" % os.path.join(self.topdir, "logs", "Atomic"), + "--treefile=%s/fedora-atomic-docker-host.json" % self.topdir, + "--unified-core", + ] + ) + + self.assertCorrectCall(run, extra_args=["--unified-core"]) + @mock.patch("kobo.shortcuts.run") def test_extra_config_with_extra_repos(self, run): configdir = os.path.join(self.topdir, "config")