Spec rootDir is only relevant for building, eliminate from parseSpec()
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 1 Sep 2010 11:31:49 +0000 (14:31 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 1 Sep 2010 11:31:49 +0000 (14:31 +0300)
- 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
build/parseSpec.c
build/rpmbuild.h
build/rpmspec.h
build/spec.c
python/spec-py.c
rpmbuild.c

index e4e11b4..b1424cd 100644 (file)
@@ -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);
index 9e2b0ef..3fd9e79 100644 (file)
@@ -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)
                {
index 8f0b9d2..36bb1c6 100644 (file)
@@ -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)
index b739149..8a0b425 100644 (file)
@@ -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;
index de224aa..7fae654 100644 (file)
@@ -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)
     {
index f5a4b33..1573ed0 100644 (file)
@@ -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 {
index ee130bd..8ad6c91 100644 (file)
@@ -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;