Skip to content

Commit

Permalink
Check for mock version instead of redhat_release
Browse files Browse the repository at this point in the history
redhat_release is what distro we're _building for_ which is not a good test
for which version of mock is installed.
  • Loading branch information
matyasselmeci committed Oct 3, 2019
1 parent 0a858ab commit ab30c6d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions osgbuild/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ def __init__(self, buildopts, koji_obj):

cfg_path = self._init_get_cfg_path()
self.mock_cmd = ['mock']
mock_version_str = utils.backtick(self.mock_cmd + ["--version"]).strip()
m = re.match(r"(\d+)\.(\d+)\.(\d+)", mock_version_str)
if m:
self.mock_version = (int(m.group(1)), int(m.group(2)), int(m.group(3)))
else:
raise MockError("mock --version returned unexpected output: %s" % mock_version_str)

if cfg_path:
cfg_abspath = os.path.abspath(cfg_path)
cfg_abspath_no_ext = re.sub(r'\.cfg$', '', cfg_abspath)
Expand Down Expand Up @@ -133,13 +140,12 @@ def rebuild(self, resultdir, srpm):
srpm]
if self.target_arch:
rebuild_cmd += ['--arch', self.target_arch]
redhat_release = int(self.buildopts['redhat_release'])
if redhat_release == 6:
# ccache on el6 tries to install the el5 package for ccache and dies
rebuild_cmd += ['--disable-plugin=ccache']
elif redhat_release >= 7:
if self.mock_version >= (1,4,0):
# systemd-nspawn is often broken; don't use it. network is required for maven builds :(
rebuild_cmd += ['--enable-network', '--config-opts=use_nspawn=False']
else:
# ccache on old versions tries to install the el5 package for ccache and dies
rebuild_cmd += ['--disable-plugin=ccache']
ret = utils.unchecked_call(rebuild_cmd)
if ret:
raise MockError('Mock build failed (command was: ' + ' '.join(rebuild_cmd) + ')')
Expand All @@ -149,7 +155,6 @@ def rebuild(self, resultdir, srpm):
return rpms



def clean(self):
"""Clean the mock chroot"""
utils.checked_call(self.mock_cmd + ["clean"])
Expand Down

0 comments on commit ab30c6d

Please sign in to comment.