From 9e193963e8b893fac1316f9d0d7412ddef8f13ec Mon Sep 17 00:00:00 2001 From: Ondřej Nosek Date: Apr 02 2021 17:05:44 +0000 Subject: Patch: Add support for side tag suffix Signed-off-by: Ondřej Nosek --- diff --git a/0003-Add-support-for-side-tag-suffix.patch b/0003-Add-support-for-side-tag-suffix.patch new file mode 100644 index 0000000..c1baaa5 --- /dev/null +++ b/0003-Add-support-for-side-tag-suffix.patch @@ -0,0 +1,104 @@ +From c6d5a68627033570995645e574d39ff7d2bbef82 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= +Date: Thu, 25 Feb 2021 14:43:20 +0100 +Subject: [PATCH] Add support for side tag suffix +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This requires changes in the side-tag plugin in Koji. With that it would +be possible to use a set of preconfigured suffixes for the tags. + +JIRA: RHELCMP-4332 +Signed-off-by: Lubomír Sedlář +--- + pyrpkg/__init__.py | 8 ++++++-- + pyrpkg/cli.py | 11 ++++++++++- + tests/test_side_tag.py | 17 +++++++++++++++++ + 3 files changed, 33 insertions(+), 3 deletions(-) + +diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py +index afc525a..a479851 100644 +--- a/pyrpkg/__init__.py ++++ b/pyrpkg/__init__.py +@@ -3214,14 +3214,18 @@ class Commands(object): + def remove_side_tag(self, tag): + self.kojisession.removeSideTag(tag) + +- def request_side_tag(self, base_tag=None): ++ def request_side_tag(self, base_tag=None, suffix=None): + if not base_tag: + build_target = self.kojisession.getBuildTarget(self.target) + if not build_target: + raise rpkgError("Unknown build target: %s" % self.target) + base_tag = build_target["build_tag_name"] + +- return self.kojisession.createSideTag(base_tag) ++ kwargs = {} ++ if suffix: ++ kwargs["suffix"] = suffix ++ ++ return self.kojisession.createSideTag(base_tag, **kwargs) + + def is_retired(self): + """ +diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py +index 55d111c..002a1a0 100644 +--- a/pyrpkg/cli.py ++++ b/pyrpkg/cli.py +@@ -1369,6 +1369,13 @@ class cliClient(object): + "request-side-tag", help="Create a new side tag" + ) + parser.add_argument("--base-tag", help="name of base tag") ++ parser.add_argument( ++ "--suffix", ++ help=( ++ "A suffix to be appended to the side tag name. " ++ "The suffix must be allowed in Koji configuration." ++ ) ++ ) + parser.set_defaults(command=self.request_side_tag) + + def register_retire(self): +@@ -2565,7 +2572,9 @@ class cliClient(object): + print("Tag deleted.") + + def request_side_tag(self): +- tag_info = self.cmd.request_side_tag(base_tag=self.args.base_tag) ++ tag_info = self.cmd.request_side_tag( ++ base_tag=self.args.base_tag, suffix=self.args.suffix ++ ) + print("Side tag '%(name)s' (id %(id)d) created." % tag_info) + print("Use '%s build --target=%s' to use it." % (self.name, tag_info["name"])) + print( +diff --git a/tests/test_side_tag.py b/tests/test_side_tag.py +index e4dbe3a..8507062 100644 +--- a/tests/test_side_tag.py ++++ b/tests/test_side_tag.py +@@ -83,6 +83,23 @@ class RequestSideTagTestCase(BaseCase): + + self.assertIn("a problem", str(ctx.exception)) + ++ def test_suffix(self): ++ cli = self.new_cli( ++ ["request-side-tag", "--base-tag=f30-build", "--suffix=stack-gate"] ++ ) ++ cli.cmd._kojisession.createSideTag.return_value = {"name": "side", "id": 123} ++ with mock.patch("sys.stdout", new_callable=StringIO) as mock_out: ++ cli.request_side_tag() ++ ++ output = mock_out.getvalue() ++ self.assertIn("Side tag 'side' (id 123) created.", output) ++ self.assertIn("Use 'rpkg build --target=side' to use it.", output) ++ ++ self.assertEqual( ++ cli.cmd._kojisession.createSideTag.call_args_list, ++ [mock.call("f30-build", suffix="stack-gate")], ++ ) ++ + + class ListSideTagTestCase(BaseCase): + def test_list_all(self): +-- +2.30.2 + diff --git a/rpkg.spec b/rpkg.spec index 5c2f049..9bf8ee6 100644 --- a/rpkg.spec +++ b/rpkg.spec @@ -1,6 +1,6 @@ Name: rpkg Version: 1.62 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Python library for interacting with rpm+git License: GPLv2+ and LGPLv2 @@ -18,7 +18,8 @@ Source0: https://pagure.io/releases/rpkg/%{name}-%{version}.tar.gz # remove rpm-py-installer for now. Patch0: remove-koji-and-rpm-py-installer-from-requires.patch Patch1: 0001-Do-not-use-pytest-related-dependencies-temporarily.patch -Patch2: 0002-ca-cert-was-removed-on-koji-1.24.0.patch +Patch2: 0002-ca-cert-was-removed-on-koji-1.24.0.patch +Patch3: 0003-Add-support-for-side-tag-suffix.patch # RHEL7 is currently the only release that is built for Python 2. %if 0%{?fedora} || 0%{?rhel} > 7 @@ -47,7 +48,7 @@ BuildRequires: python2-devel # We br these things for man page generation due to imports BuildRequires: rpmlint -BuildRequires: python2-koji >= 1.17 +BuildRequires: python2-koji >= 1.21 BuildRequires: python2-cccolutils BuildRequires: PyYAML BuildRequires: GitPython @@ -63,7 +64,7 @@ Requires: redhat-rpm-config Requires: rpm-build Requires: rpmlint Requires: python2-cccolutils -Requires: python2-koji >= 1.17 +Requires: python2-koji >= 1.21 Requires: PyYAML Requires: GitPython >= 0.2.0 Requires: python-pycurl @@ -98,7 +99,7 @@ Obsoletes: python2-rpkg < %{version}-%{release} BuildRequires: python3-devel BuildRequires: python3-GitPython -BuildRequires: python3-koji >= 1.17 +BuildRequires: python3-koji >= 1.24 %if 0%{?rhel} BuildRequires: python3-gobject-base BuildRequires: libmodulemd @@ -123,7 +124,7 @@ Requires: rpmlint Requires: python3-GitPython >= 0.2.0 Requires: python3-cccolutils -Requires: python3-koji >= 1.17 +Requires: python3-koji >= 1.24 %if 0%{?rhel} Requires: python3-gobject-base Requires: libmodulemd @@ -237,6 +238,9 @@ example_cli_dir=$RPM_BUILD_ROOT%{_datadir}/%{name}/examples/cli %changelog +* Fri Apr 02 2021 Ondřej Nosek - 1.62-4 +- Patch: Add support for side tag suffix + * Wed Feb 24 2021 Ondřej Nosek - 1.62-3 - Patch: ca cert was removed on koji-1.24.0