summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-12-05 13:38:30 +0200
committerPanu Matilainen <pmatilai@redhat.com>2008-12-05 13:38:30 +0200
commitcc74d50a6dadfa30914844e6c4c0513287bf7f68 (patch)
treee17b221b3504d1befe7ca4ed68de6deda697da08 /build
parent23c55fa997b66f39a50c34512fb07c78343f1062 (diff)
downloadrpm-cc74d50a6dadfa30914844e6c4c0513287bf7f68.tar.gz
rpm-cc74d50a6dadfa30914844e6c4c0513287bf7f68.tar.bz2
rpm-cc74d50a6dadfa30914844e6c4c0513287bf7f68.zip
Tighten up setting and checking of buildroot (ticket #10)
- expand, set and verify buildroot just once for after main package preamble is parsed to avoid sub-packages from overriding it - spec can still mess with %buildroot by defining it to something else after preamble but that's another issue...
Diffstat (limited to 'build')
-rw-r--r--build/parsePreamble.c21
-rw-r--r--build/parseSpec.c9
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;