@@ -257,23 +257,36 @@ build_rpm_in_chroot_no_install () {
257257 rpmMacros=(-D " with_check $CHECK_DEFINE_NUM " -D " _sourcedir $specDir " -D " dist $PARAM_DIST_TAG " )
258258 builtRpms=" $( rpmspec -q $specPath --builtrpms " ${rpmMacros[@]} " --queryformat=" %{nvra}.rpm\n" ) "
259259
260- # Find all the associated RPMs for the SRPM and check if they are in the chroot RPM directory
261- foundAllRPMs=" false"
262- if [ " $INCREMENTAL_TOOLCHAIN " = " y" ]; then
263- foundAllRPMs=" true"
260+ builtEarlier=false
261+ if grep -qP " ^$1 \$ " $TEMP_BUILT_SPECS_LIST ; then
262+ builtEarlier=true
263+ fi
264+
265+ # If a package was built earlier and we try to build it again,
266+ # it means the earlier builds happened while only a subset of its build-time dependencies were available.
267+ # Later builds are expected to have more/all dependencies available, so we rebuild the package.
268+ #
269+ # If the incremental build skipped the first build, it means the final version of the package
270+ # was present from the beginning, so we skip further build attempts as well.
271+ skipBuild=false
272+ if $builtEarlier ; then
273+ echo " Package '$1 ' was built earlier. Skipping incremental toolchain check and building again."
274+ elif [ " $INCREMENTAL_TOOLCHAIN " = " y" ]; then
275+ # Find all the associated RPMs for the SRPM and check if they are in the chroot RPM directory.
276+ skipBuild=true
264277 for rpm in $builtRpms ; do
265278 rpmPath=$( find $CHROOT_RPMS_DIR -name " $rpm " -print -quit)
266279 if [ -z " $rpmPath " ]; then
267280 echo " Did not find incremental toolchain rpm '$rpm ' in '$CHROOT_RPMS_DIR ', must rebuild."
268- foundAllRPMs= " false"
281+ skipBuild= false
269282 break
270283 else
271284 cp $rpmPath $FINISHED_RPM_DIR
272285 fi
273286 done
274287 fi
275288
276- if [ " $foundAllRPMs " = " false " ] ; then
289+ if ! $skipBuild ; then
277290 echo only building RPM $1 within the chroot
278291 srpmName=$( rpmspec -q $specPath --srpm " ${rpmMacros[@]} " --queryformat %{NAME}-%{VERSION}-%{RELEASE}.src.rpm)
279292 srpmPath=$MARINER_INPUT_SRPMS_DIR /$srpmName
0 commit comments