From a6c65e026aa04aba04e2315015e97e3996fb0af0 Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Tue, 28 Nov 2017 16:31:20 +0100 Subject: [PATCH] add ability to specify ostree ref in OSTREE phase It allows specify what ref we want this compose to commit to. New parameter 'ostree_ref' overrides the default value from the treefile json. Relates: https://pagure.io/pungi/issue/777 Signed-off-by: Ondrej Nosek --- doc/configuration.rst | 1 + pungi/checks.py | 2 ++ pungi/ostree/__init__.py | 2 ++ pungi/ostree/tree.py | 8 +++++++- pungi/phases/ostree.py | 4 ++++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/configuration.rst b/doc/configuration.rst index c90ee0d7..f184e8ee 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1228,6 +1228,7 @@ repository with a new commit. :ref:`See how those values are created `. * ``tag_ref`` -- (*bool*, default ``True``) If set to ``False``, a git reference will not be created. + * ``ostree_ref`` -- (*str*) To override value ``ref`` from ``treefile``. Example config diff --git a/pungi/checks.py b/pungi/checks.py index bfacc283..148e78f0 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -890,6 +890,7 @@ def make_schema(): "version": {"type": "string"}, "config_branch": {"type": "string"}, "tag_ref": {"type": "boolean"}, + "ostree_ref": {"type": "string"}, }, "required": ["treefile", "config_url", "repo", "ostree_repo"], "additionalProperties": False, @@ -915,6 +916,7 @@ def make_schema(): "version": {"type": "string"}, "config_branch": {"type": "string"}, "tag_ref": {"type": "boolean"}, + "ostree_ref": {"type": "string"}, }, "required": ["treefile", "config_url", "repo", "ostree_repo"], "additionalProperties": False, diff --git a/pungi/ostree/__init__.py b/pungi/ostree/__init__.py index e113137e..718941a4 100644 --- a/pungi/ostree/__init__.py +++ b/pungi/ostree/__init__.py @@ -40,6 +40,8 @@ def main(args=None): help='version string to be added as versioning metadata') treep.add_argument('--update-summary', action='store_true', help='update summary metadata') + treep.add_argument('--ostree-ref', metavar='PATH', + help='override ref value from treefile') installerp = subparser.add_parser("installer", help="Create an OSTree installer image") installerp.set_defaults(_class=Installer, func='run') diff --git a/pungi/ostree/tree.py b/pungi/ostree/tree.py index 96f0b622..5e985434 100644 --- a/pungi/ostree/tree.py +++ b/pungi/ostree/tree.py @@ -57,7 +57,11 @@ class Tree(OSTree): if not tag_ref: print('Not updating ref as configured') return - ref = get_ref_from_treefile(self.treefile) + # if ostree_ref argument is given, it overrides ref value from treefile + if self.ostree_ref: + ref = self.ostree_ref + else: + ref = get_ref_from_treefile(self.treefile) commitid = get_commitid_from_commitid_file(self.commitid_file) print('Ref: %r, Commit ID: %r' % (ref, commitid)) if ref and commitid: @@ -79,6 +83,8 @@ class Tree(OSTree): self.logdir = self.args.log_dir self.update_summary = self.args.update_summary self.extra_config = self.args.extra_config + self.ostree_ref = self.args.ostree_ref + if self.extra_config: self.extra_config = json.load(open(self.extra_config, 'r')) repos = self.extra_config.get('repo', []) diff --git a/pungi/phases/ostree.py b/pungi/phases/ostree.py index c7575319..c681a330 100644 --- a/pungi/phases/ostree.py +++ b/pungi/phases/ostree.py @@ -122,6 +122,10 @@ class OSTreeThread(WorkerThread): if config.get('update_summary', False): cmd.append('--update-summary') + ostree_ref = config.get('ostree_ref') + if ostree_ref: + cmd.append('--ostree-ref=%s' % ostree_ref) + runroot_channel = compose.conf.get("runroot_channel") runroot_tag = compose.conf["runroot_tag"]