diff options
Diffstat (limited to 'build')
-rw-r--r-- | build/parsePreamble.c | 21 | ||||
-rw-r--r-- | build/parseSpec.c | 9 |
2 files changed, 21 insertions, 9 deletions
diff --git a/build/parsePreamble.c b/build/parsePreamble.c index 09fd88ca8..33091770e 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -874,6 +874,27 @@ int parsePreamble(rpmSpec spec, int initialPackage) } } + /* + * Expand buildroot one more time to get %{version} and the like + * from the main package, validate sanity. The spec->buildRoot could + * still contain unexpanded macros but it cannot be empty or '/', and it + * can't be messed with by anything spec does beyond this point. + */ + if (initialPackage) { + char *buildRoot = rpmGetPath(spec->buildRoot, NULL); + if (*buildRoot == '\0') { + rpmlog(RPMLOG_ERR, _("%%{buildroot} couldn't be empty\n")); + goto exit; + } + if (!strcmp(buildRoot, "/")) { + rpmlog(RPMLOG_ERR, _("%%{buildroot} can not be \"/\"\n")); + goto exit; + } + free(spec->buildRoot); + spec->buildRoot = buildRoot; + addMacro(spec->macros, "buildroot", NULL, spec->buildRoot, RMIL_SPEC); + } + /* XXX Skip valid arch check if not building binary package */ if (!spec->anyarch && checkForValidArchitectures(spec)) { goto exit; diff --git a/build/parseSpec.c b/build/parseSpec.c index 11e0622a5..cf22db353 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -433,15 +433,6 @@ int parseSpec(rpmts ts, const char *specFile, const char *rootDir, } else { spec->buildRoot = rpmGetPath("%{?buildroot:%{buildroot}}", NULL); } - addMacro(spec->macros, "buildroot", NULL, spec->buildRoot, RMIL_SPEC); - if (*spec->buildRoot == '\0') { - rpmlog(RPMLOG_ERR, _("BuildRoot couldn't be empty\n")); - goto errxit; - } - if (!strcmp(spec->buildRoot, "/")) { - rpmlog(RPMLOG_ERR, _("BuildRoot can not be \"/\"\n")); - goto errxit; - } addMacro(NULL, "_docdir", NULL, "%{_defaultdocdir}", RMIL_SPEC); spec->recursing = recursing; spec->anyarch = anyarch; |