From f9740318a81bbb72cdd046a80a38116e2f7be8e4 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 1 Sep 2010 14:31:49 +0300 Subject: [PATCH] Spec rootDir is only relevant for building, eliminate from parseSpec() - The whole rootDir seems dubious for build purposes, but in any case its only relevant during the actual build process, not for spec parsing. Set spec->rootDir from buildSpec() for the duration of the build to avoid having to refactor doScript() and all right now. --- build/build.c | 3 +++ build/parseSpec.c | 5 +---- build/rpmbuild.h | 2 +- build/rpmspec.h | 2 +- build/spec.c | 3 +-- python/spec-py.c | 2 +- rpmbuild.c | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/build/build.c b/build/build.c index e4e11b4..b1424cd 100644 --- a/build/build.c +++ b/build/build.c @@ -219,6 +219,8 @@ static rpmRC buildSpec(BTA_t buildArgs, rpmSpec spec, int what) int test = buildArgs->noBuild; char *cookie = buildArgs->cookie ? xstrdup(buildArgs->cookie) : NULL; + /* XXX TODO: rootDir is only relevant during build, eliminate from spec */ + spec->rootDir = buildArgs->rootdir; if (!spec->recursing && spec->BACount) { int x; /* When iterating over BANames, do the source */ @@ -286,6 +288,7 @@ static rpmRC buildSpec(BTA_t buildArgs, rpmSpec spec, int what) exit: free(cookie); + spec->rootDir = NULL; if (rc != RPMRC_OK && rpmlogGetNrecs() > 0) { rpmlog(RPMLOG_NOTICE, _("\n\nRPM build errors:\n")); rpmlogPrint(NULL); diff --git a/build/parseSpec.c b/build/parseSpec.c index 9e2b0ef..3fd9e79 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -544,9 +544,6 @@ int parseSpec(rpmts ts, const char *specFile, const char *rootDir, spec->anyarch = anyarch; spec->force = force; - if (rootDir) - spec->rootDir = xstrdup(rootDir); - spec->timeCheck = rpmExpandNumeric("%{_timecheck}"); /* All the parse*() functions expect to have a line pre-read */ @@ -632,7 +629,7 @@ int parseSpec(rpmts ts, const char *specFile, const char *rootDir, continue; addMacro(NULL, "_target_cpu", NULL, spec->BANames[x], RMIL_RPMRC); spec->BASpecs[index] = NULL; - if (parseSpec(ts, specFile, spec->rootDir, buildRoot, 1, + if (parseSpec(ts, specFile, NULL, buildRoot, 1, NULL, NULL, anyarch, force) || (spec->BASpecs[index] = rpmtsSetSpec(ts, NULL)) == NULL) { diff --git a/build/rpmbuild.h b/build/rpmbuild.h index 8f0b9d2..36bb1c6 100644 --- a/build/rpmbuild.h +++ b/build/rpmbuild.h @@ -73,7 +73,7 @@ extern int _noDirTokens; * Parse spec file into spec control structure. * @param ts transaction set (spec file control in ts->spec) * @param specFile - * @param rootDir + * @param rootDir (unused) * @param buildRoot * @param recursing parse is recursive? * @param passPhrase (unused) diff --git a/build/rpmspec.h b/build/rpmspec.h index b739149..8a0b425 100644 --- a/build/rpmspec.h +++ b/build/rpmspec.h @@ -44,7 +44,7 @@ struct rpmSpec_s { char * specFile; /*!< Name of the spec file. */ char * buildRoot; char * buildSubdir; - char * rootDir; + const char * rootDir; speclines sl; spectags st; diff --git a/build/spec.c b/build/spec.c index de224aa..7fae654 100644 --- a/build/spec.c +++ b/build/spec.c @@ -266,7 +266,6 @@ rpmSpec freeSpec(rpmSpec spec) spec->buildRoot = _free(spec->buildRoot); spec->buildSubdir = _free(spec->buildSubdir); - spec->rootDir = _free(spec->rootDir); spec->specFile = _free(spec->specFile); closeSpec(spec); @@ -329,7 +328,7 @@ int rpmspecQuery(rpmts ts, QVA_t qva, const char * arg) goto exit; /* FIX: make spec abstract */ - if (parseSpec(ts, arg, "/", buildRoot, recursing, NULL, + if (parseSpec(ts, arg, NULL, buildRoot, recursing, NULL, NULL, anyarch, force) || (spec = rpmtsSetSpec(ts, NULL)) == NULL) { diff --git a/python/spec-py.c b/python/spec-py.c index f5a4b33..1573ed0 100644 --- a/python/spec-py.c +++ b/python/spec-py.c @@ -233,7 +233,7 @@ static PyObject *spec_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) * set to get back the results from parseSpec()... */ ts = rpmtsCreate(); - if (parseSpec(ts, specfile,"/", buildRoot,recursing, passPhrase, + if (parseSpec(ts, specfile, NULL, buildRoot,recursing, passPhrase, cookie, anyarch, force) == 0) { spec = rpmtsSpec(ts); } else { diff --git a/rpmbuild.c b/rpmbuild.c index ee130bd..8ad6c91 100644 --- a/rpmbuild.c +++ b/rpmbuild.c @@ -274,7 +274,7 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba) /* Parse the spec file */ #define _anyarch(_f) \ (((_f)&(RPMBUILD_PREP|RPMBUILD_BUILD|RPMBUILD_INSTALL|RPMBUILD_PACKAGEBINARY)) == 0) - if (parseSpec(ts, specFile, ba->rootdir, buildRootURL, 0, NULL, + if (parseSpec(ts, specFile, NULL, buildRootURL, 0, NULL, NULL, _anyarch(buildAmount), ba->force)) { goto exit; -- 2.7.4