Skip to content

Commit 4dfaa2a

Browse files
committed
Make sure to install BuildRequires defined by macros
Fix #1652
1 parent a06db88 commit 4dfaa2a

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

mock/py/mockbuild/backend.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -281,21 +281,29 @@ def build(self, srpm, timeout, check=True, spec=None):
281281
spec = self.get_specfile_name(srpm)
282282
spec_path = os.path.join(self.buildroot.builddir, 'SPECS', spec)
283283

284-
rebuilt_srpm = self.rebuild_installed_srpm(spec_path, timeout)
284+
# We need to rebuild the SRPM and install dependencies multiple
285+
# times so that cases like #1652 are covered
286+
for _ in range(5):
287+
packages_before = self.buildroot.all_chroot_packages()
288+
rebuilt_srpm = self.rebuild_installed_srpm(spec_path, timeout)
285289

286-
# Check if we will have dynamic BuildRequires, but do not allow it
287-
hdr = next(util.yieldSrpmHeaders((rebuilt_srpm,)))
288-
# pylint: disable=no-member
289-
requires = {text._to_text(req) for req in hdr[rpm.RPMTAG_REQUIRES]}
290-
dynamic_buildreqs = 'rpmlib(DynamicBuildRequires)' in requires
290+
# Check if we will have dynamic BuildRequires, but do not allow it
291+
hdr = next(util.yieldSrpmHeaders((rebuilt_srpm,)))
292+
# pylint: disable=no-member
293+
requires = {text._to_text(req) for req in hdr[rpm.RPMTAG_REQUIRES]}
294+
dynamic_buildreqs = 'rpmlib(DynamicBuildRequires)' in requires
295+
296+
if dynamic_buildreqs and not self.config.get('dynamic_buildrequires'):
297+
raise Error('DynamicBuildRequires are found but support is disabled.'
298+
' See "dynamic_buildrequires" in config_opts.')
291299

292-
if dynamic_buildreqs and not self.config.get('dynamic_buildrequires'):
293-
raise Error('DynamicBuildRequires are found but support is disabled.'
294-
' See "dynamic_buildrequires" in config_opts.')
300+
self.install_external(requires)
301+
# Install the (static) BuildRequires
302+
self.installSrpmDeps(rebuilt_srpm)
303+
packages_after = self.buildroot.all_chroot_packages()
304+
if packages_after == packages_before:
305+
break
295306

296-
self.install_external(requires)
297-
# install the (static) BuildRequires
298-
self.installSrpmDeps(rebuilt_srpm)
299307
self.state.finish(buildsetup)
300308
buildsetup_finished = True
301309

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Make sure to install `BuildRequires` defined by macros. For example:
2+
3+
```
4+
BuildRequires: selinux-policy
5+
%{?selinux_requires}
6+
```
7+
8+
This now properly installs the `selinux-policy-devel` package.

0 commit comments

Comments
 (0)