public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/rpkg] 1.70-1: Backport container-build fix
@ 2026-08-10 21:43 Chenxiong Qi
  0 siblings, 0 replies; only message in thread
From: Chenxiong Qi @ 2026-08-10 21:43 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/rpkg
Branch : 1.70-1
Commit : cb5f767e11e9431c05e4ec2fc29d52c2975083b2
Author : Chenxiong Qi <cqi@redhat.com>
Date   : 2017-08-31T11:21:42+08:00
Stats  : +258/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/rpkg/c/cb5f767e11e9431c05e4ec2fc29d52c2975083b2?branch=1.70-1

Log:
Backport container-build fix

---
diff --git a/0001-Fix-kojiprofile-selection-in-cliClient.container_bui.patch b/0001-Fix-kojiprofile-selection-in-cliClient.container_bui.patch
new file mode 100644
index 0000000..ba46516
--- /dev/null
+++ b/0001-Fix-kojiprofile-selection-in-cliClient.container_bui.patch
@@ -0,0 +1,251 @@
+From 7f8731a89c3154abe845700e900f139eec381e04 Mon Sep 17 00:00:00 2001
+From: Chenxiong Qi <cqi@redhat.com>
+Date: Thu, 24 Aug 2017 22:12:14 +0800
+Subject: [PATCH] Fix kojiprofile selection in cliClient.container_build_koji
+
+kojiprofile or deprecated kojiconfig should be selected according to
+whether current client is compatible with kojiconfig or not. Tests are
+added for command container-build with koji.
+
+Also fix the default value of koji_config_type and add tests to ensure
+_compat_kojiconfig is set correctly.
+
+Signed-off-by: Chenxiong Qi <cqi@redhat.com>
+---
+ pyrpkg/__init__.py                             |   2 +-
+ pyrpkg/cli.py                                  |  27 ++---
+ tests/fixtures/rpkg-deprecated-kojiconfig.conf |  11 ++
+ tests/test_cli.py                              | 139 +++++++++++++++++++++++++
+ 4 files changed, 165 insertions(+), 14 deletions(-)
+ create mode 100644 tests/fixtures/rpkg-deprecated-kojiconfig.conf
+
+diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py
+index 1c80d2e..d5f04ba 100644
+--- a/pyrpkg/__init__.py
++++ b/pyrpkg/__init__.py
+@@ -66,7 +66,7 @@ class Commands(object):
+     def __init__(self, path, lookaside, lookasidehash, lookaside_cgi,
+                  gitbaseurl, anongiturl, branchre, kojiconfig,
+                  build_client,
+-                 koji_config_type='kojiconfig', user=None,
++                 koji_config_type='config', user=None,
+                  dist=None, target=None, quiet=False,
+                  distgit_namespaced=False, realms=None, lookaside_namespaced=False):
+         """Init the object and some configuration details."""
+diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py
+index 35d9878..90874fc 100644
+--- a/pyrpkg/cli.py
++++ b/pyrpkg/cli.py
+@@ -1198,21 +1198,22 @@ see API KEY section of copr-cli(1) man page.
+                   "Using %(option)s from [%(root.section)s]"
+         err_args = {"plugin.section": section_name, "root.section": self.name}
+ 
+-        if self.config.has_option(section_name, "kojiconfig"):
+-            kojiconfig = self.config.get(section_name, "kojiconfig")
+-            kojiprofile = None
+-        else:
+-            err_args["option"] = "kojiconfig"
+-            self.log.debug(err_msg % err_args)
+-            kojiprofile = self.config.get(self.name, "kojiconfig")
++        kojiconfig = kojiprofile = None
+ 
+-        if self.config.has_option(section_name, "kojiprofile"):
+-            kojiconfig = None
+-            kojiprofile = self.config.get(section_name, "kojiprofile")
++        if self.cmd._compat_kojiconfig:
++            if self.config.has_option(section_name, "kojiconfig"):
++                kojiconfig = self.config.get(section_name, "kojiconfig")
++            else:
++                err_args["option"] = "kojiconfig"
++                self.log.debug(err_msg % err_args)
++                kojiconfig = self.config.get(self.name, "kojiconfig")
+         else:
+-            err_args["option"] = "kojiprofile"
+-            self.log.debug(err_msg % err_args)
+-            kojiprofile = self.config.get(self.name, "kojiprofile")
++            if self.config.has_option(section_name, "kojiprofile"):
++                kojiprofile = self.config.get(section_name, "kojiprofile")
++            else:
++                err_args["option"] = "kojiprofile"
++                self.log.debug(err_msg % err_args)
++                kojiprofile = self.config.get(self.name, "kojiprofile")
+ 
+         if self.config.has_option(section_name, "build_client"):
+             build_client = self.config.get(section_name, "build_client")
+diff --git a/tests/fixtures/rpkg-deprecated-kojiconfig.conf b/tests/fixtures/rpkg-deprecated-kojiconfig.conf
+new file mode 100644
+index 0000000..adcd1da
+--- /dev/null
++++ b/tests/fixtures/rpkg-deprecated-kojiconfig.conf
+@@ -0,0 +1,11 @@
++[rpkg]
++lookaside = http://localhost/repo/pkgs
++lookasidehash = md5
++lookaside_cgi = https://localhost/repo/pkgs/upload.cgi
++gitbaseurl = ssh://%(user)s@localhost/%(module)s
++anongiturl = git://localhost/%(module)s
++branchre = f\d$|f\d\d$|el\d$|olpc\d$|master$
++kojiconfig = /path/to/koji.conf
++build_client = koji
++clone_config =
++  bz.default-component %(module)s
+diff --git a/tests/test_cli.py b/tests/test_cli.py
+index f4b44ec..1372411 100644
+--- a/tests/test_cli.py
++++ b/tests/test_cli.py
+@@ -16,6 +16,7 @@ from six.moves import StringIO
+ import git
+ import pyrpkg.cli
+ 
++import utils
+ from mock import patch
+ from utils import CommandTestCase
+ from pyrpkg import rpkgError
+@@ -111,6 +112,144 @@ class TestModuleNameOption(CliTestCase):
+         self.assertEqual(cmd.ns_module_name, 'user/project/foo')
+ 
+ 
++class TestKojiConfigBackwardCompatibility(CliTestCase):
++    """Test backward compatibility of kojiconfig and kojiprofile
++
++    Remove this test case after deprecated kojiconfig is removed eventually.
++    """
++
++    @patch('pyrpkg.Commands._deprecated_read_koji_config')
++    @patch('pyrpkg.koji.read_config')
++    def test_use_deprecated_kojiconfig(self,
++                                       read_config,
++                                       _deprecated_read_koji_config):
++        cli_cmd = ['rpkg', '--path', self.cloned_repo_path, 'build']
++
++        cfg_file = os.path.join(os.path.dirname(__file__),
++                                'fixtures',
++                                'rpkg-deprecated-kojiconfig.conf')
++
++        with patch('sys.argv', new=cli_cmd):
++            cli = self.new_cli(cfg_file)
++
++        cli.cmd.read_koji_config()
++
++        self.assertFalse(hasattr(cli.cmd, 'kojiprofile'))
++        self.assertEqual(utils.kojiconfig, cli.cmd.kojiconfig)
++        self.assertTrue(cli.cmd._compat_kojiconfig)
++
++        read_config.assert_not_called()
++        _deprecated_read_koji_config.assert_called_once()
++
++    @patch('pyrpkg.Commands._deprecated_read_koji_config')
++    @patch('pyrpkg.koji.read_config')
++    def test_use_kojiprofile(self, read_config, _deprecated_read_koji_config):
++        cli_cmd = ['rpkg', '--path', self.cloned_repo_path, 'build']
++
++        with patch('sys.argv', new=cli_cmd):
++            cli = self.new_cli()
++
++        cli.cmd.read_koji_config()
++
++        self.assertFalse(hasattr(cli.cmd, 'kojiconfig'))
++        self.assertEqual(utils.kojiprofile, cli.cmd.kojiprofile)
++        self.assertFalse(cli.cmd._compat_kojiconfig)
++
++        read_config.assert_called_once_with(utils.kojiprofile)
++        _deprecated_read_koji_config.assert_not_called()
++
++
++class TestContainerBuildWithKoji(CliTestCase):
++    """Test container_build with koji"""
++
++    def setUp(self):
++        super(TestContainerBuildWithKoji, self).setUp()
++        self.checkout_branch(git.Repo(self.cloned_repo_path), 'eng-rhel-7')
++
++    @patch('pyrpkg.Commands.container_build_koji')
++    def test_using_kojiprofile(self, container_build_koji):
++        cli_cmd = ['rpkg', '--path', self.cloned_repo_path,
++                   'container-build', '--build-with', 'koji']
++
++        with patch('sys.argv', new=cli_cmd):
++            cli = self.new_cli()
++            cli.container_build()
++
++        container_build_koji.assert_called_once_with(
++            False,
++            opts={
++                'scratch': False,
++                'quiet': False,
++                'yum_repourls': None,
++                'git_branch': 'eng-rhel-7',
++            },
++            kojiconfig=None,
++            kojiprofile='koji',
++            build_client=utils.build_client,
++            koji_task_watcher=cli._watch_koji_tasks,
++            nowait=False
++        )
++
++    @patch('pyrpkg.Commands.container_build_koji')
++    def test_override_target(self, container_build_koji):
++        cli_cmd = ['rpkg', '--path', self.cloned_repo_path, 'container-build',
++                   '--target', 'f25-docker-candidate', '--build-with', 'koji']
++
++        with patch('sys.argv', new=cli_cmd):
++            cli = self.new_cli()
++            cli.container_build()
++
++        self.assertEqual('f25-docker-candidate', cli.cmd._target)
++        container_build_koji.assert_called_once_with(
++            True,
++            opts={
++                'scratch': False,
++                'quiet': False,
++                'yum_repourls': None,
++                'git_branch': 'eng-rhel-7',
++            },
++            kojiconfig=None,
++            kojiprofile='koji',
++            build_client=utils.build_client,
++            koji_task_watcher=cli._watch_koji_tasks,
++            nowait=False
++        )
++
++    @patch('pyrpkg.Commands.container_build_koji')
++    def test_using_deprecated_kojiconfig(self, container_build_koji):
++        """test_build_using_deprecated_kojiconfig
++
++        This is for ensuring container_build works with deprecated kojiconfig.
++        This test can be delete after kojiconfig is removed eventually.
++        """
++        cli_cmd = ['rpkg', '--path', self.cloned_repo_path,
++                   '--module-name', 'mycontainer',
++                   'container-build', '--build-with', 'koji']
++
++        cfg_file = os.path.join(os.path.dirname(__file__),
++                                'fixtures',
++                                'rpkg-deprecated-kojiconfig.conf')
++
++        with patch('sys.argv', new=cli_cmd):
++            cli = self.new_cli(cfg_file)
++            cli.container_build()
++
++        container_build_koji.assert_called_once_with(
++            False,
++            opts={
++                'scratch': False,
++                'quiet': False,
++                'yum_repourls': None,
++                'git_branch': 'eng-rhel-7',
++            },
++            kojiconfig='/path/to/koji.conf',
++            kojiprofile=None,
++            build_client=utils.build_client,
++            koji_task_watcher=cli._watch_koji_tasks,
++            nowait=False
++        )
++
++
+ class TestClog(CliTestCase):
+ 
+     def setUp(self):
+-- 
+2.9.5
+

diff --git a/rpkg.spec b/rpkg.spec
index 6becfad..562c96a 100644
--- a/rpkg.spec
+++ b/rpkg.spec
@@ -3,7 +3,7 @@
 
 Name:           rpkg
 Version:        1.50
-Release:        1%{?dist}
+Release:        2%{?dist}
 
 Summary:        Python library for interacting with rpm+git
 License:        GPLv2+ and LGPLv2
@@ -11,6 +11,7 @@ URL:            https://pagure.io/rpkg
 Source0:        https://pagure.io/releases/rpkg/%{name}-%{version}.tar.gz
 BuildArch:      noarch
 Patch0:         0001-Fix-encoding-in-new-command.patch
+Patch1:         0001-Fix-kojiprofile-selection-in-cliClient.container_bui.patch
 
 
 %description
@@ -68,6 +69,7 @@ A python library for managing RPM package sources in a git repository.
 %prep
 %setup -q
 %patch0 -p1
+%patch1 -p1
 
 
 %build
@@ -106,7 +108,11 @@ rm -rf $RPM_BUILD_ROOT
 %{python_sitelib}/%{name}-%{version}-py?.?.egg-info
 %{_datadir}/%{name}
 
+
 %changelog
+* Thu Aug 31 2017 Chenxiong Qi <cqi@redhat.com> - 1.50-2
+- Backport: Fix kojiprofile selection in cliClient.container_build_koji (cqi)
+
 * Thu Aug 10 2017 Chenxiong Qi <cqi@redhat.com> - 1.50-1
 - Fix PEP8 error (cqi)
 - Spelling fixes (ville.skytta)

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-10 21:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-10 21:43 [rpms/rpkg] 1.70-1: Backport container-build fix Chenxiong Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox