Skip to content

Commit

Permalink
rpmbuild: Create full build tree after parsing a spec file
Browse files Browse the repository at this point in the history
%_sourcedir and such can use %{name} and that is correct from RPM POV
because that expansion happens only during the actual build. However,
rpmbuild tries to create those directories before parsing spec that
leads to some warnings from RPM even though those macro are re-evaluated
later during the build. It is enough to create %_topdir and %_specdir in
the beginning to support building from tarball and create the rest after
parsing spec. Having any macro that would be populated from spec in
%_topdir and %_specdir is just not going to work anyway.

Signed-off-by: Igor Raits <i.gnatenko.brain@gmail.com>
(cherry picked from commit af74684)
  • Loading branch information
ignatenkobrain authored and pmatilai committed Jun 23, 2020
1 parent e50e0a8 commit ca26c22
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions rpmbuild.c
Expand Up @@ -435,12 +435,11 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
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)) {
const char *rootdir = rpmtsRootDir(ts);
const char *root = !rstreq(rootdir, "/") ? rootdir : NULL;
/* Create minimal build tree if necessary */
if (rpmMkdirs(root, "%{_topdir}:%{_specdir}"))
goto exit;
}

if (buildMode == 't') {
char *srcdir = NULL, *dir;
Expand Down Expand Up @@ -508,6 +507,10 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
goto exit;
}

/* Create build tree if necessary */
if (rpmMkdirs(root, "%{_sourcedir}:%{_builddir}:%{_rpmdir}:%{_srcrpmdir}:%{_buildrootdir}"))
goto exit;

if ((rc = rpmSpecBuild(ts, spec, ba))) {
goto exit;
}
Expand Down

0 comments on commit ca26c22

Please sign in to comment.