--- rpm-4.15.1/rpmbuild.c~ 2019-06-26 16:17:31.000000000 +0200 +++ rpm-4.15.1/rpmbuild.c 2020-01-13 23:29:36.442259031 +0100 @@ -435,13 +435,6 @@ if (ba->buildRootOverride) buildRootURL = rpmGenPath(NULL, ba->buildRootOverride, NULL); - /* Create build tree if necessary */ - const char * buildtree = "%{_topdir}:%{_specdir}:%{_sourcedir}:%{_builddir}:%{_rpmdir}:%{_srcrpmdir}:%{_buildrootdir}"; - const char * rootdir = rpmtsRootDir(ts); - if (rpmMkdirs(!rstreq(rootdir, "/") ? rootdir : NULL , buildtree)) { - goto exit; - } - if (buildMode == 't') { char *srcdir = NULL, *dir; @@ -508,6 +501,13 @@ goto exit; } + /* Create build tree if necessary */ + const char * buildtree = "%{_topdir}:%{_specdir}:%{_sourcedir}:%{_builddir}:%{_rpmdir}:%{_srcrpmdir}:%{_buildrootdir}"; + const char * rootdir = rpmtsRootDir(ts); + if (rpmMkdirs(!rstreq(rootdir, "/") ? rootdir : NULL , buildtree)) { + goto exit; + } + if ((rc = rpmSpecBuild(ts, spec, ba))) { goto exit; }