@@ -281,21 +281,30 @@ 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+ max_loops = int (self .config .get ('static_buildrequires_max_loops' ))
287+ for _ in range (max_loops ):
288+ packages_before = self .buildroot .all_chroot_packages ()
289+ rebuilt_srpm = self .rebuild_installed_srpm (spec_path , timeout )
285290
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
291+ # Check if we will have dynamic BuildRequires, but do not allow it
292+ hdr = next (util .yieldSrpmHeaders ((rebuilt_srpm ,)))
293+ # pylint: disable=no-member
294+ requires = {text ._to_text (req ) for req in hdr [rpm .RPMTAG_REQUIRES ]}
295+ dynamic_buildreqs = 'rpmlib(DynamicBuildRequires)' in requires
296+
297+ if dynamic_buildreqs and not self .config .get ('dynamic_buildrequires' ):
298+ raise Error ('DynamicBuildRequires are found but support is disabled.'
299+ ' See "dynamic_buildrequires" in config_opts.' )
291300
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.' )
301+ self .install_external (requires )
302+ # Install the (static) BuildRequires
303+ self .installSrpmDeps (rebuilt_srpm )
304+ packages_after = self .buildroot .all_chroot_packages ()
305+ if packages_after == packages_before :
306+ break
295307
296- self .install_external (requires )
297- # install the (static) BuildRequires
298- self .installSrpmDeps (rebuilt_srpm )
299308 self .state .finish (buildsetup )
300309 buildsetup_finished = True
301310
0 commit comments