| |
@@ -2800,7 +2800,32 @@
|
| |
raise rpkgError('Failed to remove temporary directory'
|
| |
' %s. Reason: %s.' % (tmp_dir, error))
|
| |
|
| |
- def mockbuild(self, mockargs=[], root=None, hashtype=None, shell=None):
|
| |
+ @staticmethod
|
| |
+ def use_local_mock_config(root, force_local):
|
| |
+ """
|
| |
+ Decide if local mock configuration should be used, based on Mock root
|
| |
+ name and command-line arguments.
|
| |
+
|
| |
+ :param str root: mock chroot, the -r <chroot> argument
|
| |
+ :param bool force_local: enforce download of the Mock configuration
|
| |
+ from Kojihub (when False), or enforce local Mock config (when
|
| |
+ True). If None, local configuration is used if the config file
|
| |
+ exists.
|
| |
+ :return: bool, True for local config, False for downloaded config.
|
| |
+ """
|
| |
+ if force_local is not None:
|
| |
+ return force_local
|
| |
+
|
| |
+ chroot_cfg = '/etc/mock/%s.cfg' % root
|
| |
+ home_chroot_cfg = '~/.config/mock/%s.cfg' % root
|
| |
+ home_chroot_cfg = os.path.expanduser(home_chroot_cfg)
|
| |
+ if os.path.exists(chroot_cfg) or os.path.exists(home_chroot_cfg):
|
| |
+ return True
|
| |
+ return False
|
| |
+
|
| |
+
|
| |
+ def mockbuild(self, mockargs=[], root=None, hashtype=None, shell=None,
|
| |
+ force_local_mock_config=None):
|
| |
"""Build the package in mock, using mockargs
|
| |
|
| |
Log the output and returns nothing
|
| |
@@ -2812,6 +2837,9 @@
|
| |
:param str hashtype: used to generate SRPM only if there is no SRPM
|
| |
generated before.
|
| |
:param bool shell: indicate whether to go into chroot.
|
| |
+ :param bool koji_config: enforce download of the Mock configuration
|
| |
+ from Kojihub (True), or enforce local Mock config (False). If
|
| |
+ None local configuration is used if present.
|
| |
|
| |
.. versionadded:: 1.56
|
| |
Parameter shell.
|
| |
@@ -2829,12 +2857,8 @@
|
| |
config_dir = None
|
| |
if not root:
|
| |
root = self.mockconfig
|
| |
- chroot_cfg = '/etc/mock/%s.cfg' % root
|
| |
- home_chroot_cfg = '~/.config/mock/%s.cfg' % root
|
| |
- home_chroot_cfg = os.path.expanduser(home_chroot_cfg)
|
| |
- if not os.path.exists(chroot_cfg) and not os.path.exists(home_chroot_cfg):
|
| |
- self.log.debug('Mock config %s was not found. Going to'
|
| |
- ' request koji to create new one.', chroot_cfg)
|
| |
+ if not self.use_local_mock_config(root, force_local_mock_config):
|
| |
+ self.log.debug('Going to download Mock config from Kojihub')
|
| |
try:
|
| |
config_dir = self._config_dir_basic(root=root)
|
| |
except rpkgError as error:
|
| |
See the commit message.