More RPMVAR_* conversion to macros.
authorjbj <devnull@localhost>
Sat, 5 Sep 1998 21:54:05 +0000 (21:54 +0000)
committerjbj <devnull@localhost>
Sat, 5 Sep 1998 21:54:05 +0000 (21:54 +0000)
CVS patchset: 2281
CVS date: 1998/09/05 21:54:05

build.c
build/build.c
build/files.c
build/pack.c
build/parsePreamble.c
build/parseSpec.c
build/rpmspec.h
build/spec.c
lib/cpio.c
lib/rpmmacro.h
rpmio/rpmmacro.h

diff --git a/build.c b/build.c
index 97fa829..87697d3 100644 (file)
--- a/build.c
+++ b/build.c
@@ -23,7 +23,11 @@ int buildplatform(char *arg, int buildAmount, char *passPhrase,
     Spec spec = NULL;
 
     if (fromTarball) {
-       specDir = rpmGetVar(RPMVAR_SPECDIR);
+       specDir = alloca(BUFSIZ);
+       strcpy(specDir, "%{_specdir}");
+       /* XXX can't use spec->macros yet */
+       expandMacros(NULL, &globalMacroContext, specDir, BUFSIZ);
+
        tmpSpecFile = alloca(BUFSIZ);
        sprintf(tmpSpecFile, "%s/rpm-spec-file-%d", specDir, (int) getpid());
 
index eab7830..09d3789 100644 (file)
@@ -50,27 +50,27 @@ static char *_preScriptEnvironment =
        "RPM_SOURCE_DIR=\"%{_sourcedir}\"\n"
        "RPM_BUILD_DIR=\"%{_builddir}\"\n"
        "RPM_OPT_FLAGS=\"%{optflags}\"\n"
-       "export  RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS\n"
+       "RPM_ARCH=\"%{arch}\"\n"
+       "RPM_OS=\"%{os}\"\n"
+       "export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS\n"
+       "RPM_DOC_DIR=\"%{_docdir}\"\n"
+       "export RPM_DOC_DIR\n"
+       "RPM_PACKAGE_NAME=\"%{name}\"\n"
+       "RPM_PACKAGE_VERSION=\"%{version}\"\n"
+       "RPM_PACKAGE_RELEASE=\"%{release}\"\n"
+       "export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\n"
 ;
 
 static int writeVars(Spec spec, FILE *f)
 {
-    char *arch, *os, *s;
+    char *s;
     char buf[BUFSIZ];
 
     strcpy(buf, _preScriptEnvironment);
     expandMacros(spec, spec->macros, buf, sizeof(buf));
-    fprintf(f, "%s\n", buf);
+    strcat(buf, "\n");
+    fputs(buf, f);
     
-    rpmGetArchInfo(&arch, NULL);
-    rpmGetOsInfo(&os, NULL);
-
-    fprintf(f, "RPM_DOC_DIR=\"%s\"\n", spec->docDir);
-    fprintf(f, "RPM_ARCH=\"%s\"\n", arch);
-    fprintf(f, "RPM_OS=\"%s\"\n", os);
-
-    fprintf(f, "export RPM_DOC_DIR RPM_ARCH RPM_OS\n");
-
     if (spec->buildRoot) {
        fprintf(f, "RPM_BUILD_ROOT=\"%s\"\n", spec->buildRoot);
        fprintf(f, "export RPM_BUILD_ROOT\n");
@@ -81,6 +81,7 @@ static int writeVars(Spec spec, FILE *f)
        fprintf(f, "fi\n");
     }
 
+#if DEAD
     headerGetEntry(spec->packages->header, RPMTAG_NAME,
                   NULL, (void **)&s, NULL);
     fprintf(f, "RPM_PACKAGE_NAME=\"%s\"\n", s);
@@ -92,6 +93,7 @@ static int writeVars(Spec spec, FILE *f)
     fprintf(f, "RPM_PACKAGE_RELEASE=\"%s\"\n", s);
     fprintf(f, "export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION "
            "RPM_PACKAGE_RELEASE\n");
+#endif
     
     return 0;
 }
index 51c0b82..39bec04 100644 (file)
@@ -666,11 +666,8 @@ static int parseForSimple(Spec spec, Package pkg, char *buf,
            res = 1;
        } else {
        /* XXX FIXME: this is easy to do as macro expansion */
-           headerGetEntry(pkg->header, RPMTAG_NAME, NULL,
-                          (void *) &name, NULL);
-           headerGetEntry(pkg->header, RPMTAG_VERSION, NULL,
-                          (void *) &version, NULL);
-           sprintf(buf, "%s/%s-%s", spec->docDir, name, version);
+           strcpy(buf, "%{_docdir}/%{name}-%{version}");
+           expandMacros(spec, spec->macros, buf, BUFSIZ);
 
            if (! fl->passedSpecialDoc) {
                pkg->specialDoc = newStringBuf();
@@ -1124,7 +1121,10 @@ static int processPackageFiles(Spec spec, Package pkg,
     fl.docDirs[fl.docDirCount++] = strdup("/usr/man");
     fl.docDirs[fl.docDirCount++] = strdup("/usr/info");
     fl.docDirs[fl.docDirCount++] = strdup("/usr/X11R6/man");
-    fl.docDirs[fl.docDirCount++] = strdup(spec->docDir);
+    {  strcpy(buf, "%{_docdir}");
+       expandMacros(spec, spec->macros, buf, sizeof(buf));
+       fl.docDirs[fl.docDirCount++] = strdup(buf);
+    }
     
     fl.fileList = NULL;
     fl.fileListRecsAlloced = 0;
index b471e6c..04ee02d 100644 (file)
@@ -57,7 +57,11 @@ int packageSources(Spec spec)
                   RPM_INT32_TYPE, getBuildTime(), 1);
 
     genSourceRpmName(spec);
-    sprintf(fileName, "%s/%s", rpmGetVar(RPMVAR_SRPMDIR), spec->sourceRpmName);
+
+    /* XXX this should be %_srpmdir */
+    strcpy(fileName, "%{_srcrpmdir}/");
+    expandMacros(spec, spec->macros, fileName, sizeof(fileName));
+    strcat(fileName, spec->sourceRpmName);
 
     /* Add the build restrictions */
     iter = headerInitIterator(spec->buildRestrictions);
@@ -100,16 +104,13 @@ int packageBinaries(Spec spec)
     char *name, fileName[BUFSIZ];
     Package pkg;
 
-    pkg = spec->packages;
-    while (pkg) {
-       if (!pkg->fileList) {
-           pkg = pkg->next;
+    for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
+
+       if (!pkg->fileList)
            continue;
-       }
 
-       if ((rc = processScriptFiles(spec, pkg))) {
+       if ((rc = processScriptFiles(spec, pkg)))
            return rc;
-       }
        
        if (spec->cookie) {
            headerAddEntry(pkg->header, RPMTAG_COOKIE,
@@ -133,14 +134,17 @@ int packageBinaries(Spec spec)
        binFormat = rpmGetVar(RPMVAR_RPMFILENAME);
        binRpm = headerSprintf(pkg->header, binFormat, rpmTagTable,
                               rpmHeaderFormats, &errorString);
-       if (!binRpm) {
+       if (binRpm == NULL) {
            headerGetEntry(pkg->header, RPMTAG_NAME, NULL,
                           (void **)&name, NULL);
            rpmError(RPMERR_BADFILENAME, "Could not generate output "
                     "filename for package %s: %s\n", name, errorString);
            return RPMERR_BADFILENAME;
        }
-       sprintf(fileName, "%s/%s", rpmGetVar(RPMVAR_RPMDIR), binRpm);
+       strcpy(fileName, "%{_rpmdir}/");
+       expandMacros(spec, spec->macros, fileName, sizeof(fileName));
+       strcat(fileName, binRpm);
+
        FREE(binRpm);
 
        memset(csa, 0, sizeof(*csa));
@@ -153,8 +157,6 @@ int packageBinaries(Spec spec)
                            csa, spec->passPhrase, NULL))) {
            return rc;
        }
-       
-       pkg = pkg->next;
     }
     
     return 0;
index 3dd07c1..c479863 100644 (file)
@@ -413,14 +413,14 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, char *macro,
        break;
       case RPMTAG_DOCDIR:
        SINGLE_TOKEN_ONLY;
-       FREE(spec->docDir);
        if (field[0] != '/') {
            rpmError(RPMERR_BADSPEC,
                     "line %d: Docdir must begin with '/': %s",
                     spec->lineNum, spec->line);
            return RPMERR_BADSPEC;
        }
-       spec->docDir = strdup(field);
+       delMacro(&globalMacroContext, "_docdir");
+       addMacro(&globalMacroContext, "_docdir", NULL, field, RMIL_SPEC);
        break;
       case RPMTAG_SERIAL:
        SINGLE_TOKEN_ONLY;
index 85036f6..4b90462 100644 (file)
@@ -232,7 +232,7 @@ int parseSpec(Spec *specp, char *specFile, char *buildRoot,
        spec->gotBuildRoot = 1;
        spec->buildRoot = strdup(buildRoot);
     }
-    spec->docDir = strdup(rpmGetVar(RPMVAR_DEFAULTDOCDIR));
+    addMacro(&globalMacroContext, "_docdir", NULL, "%{_defaultdocdir}", RMIL_SPEC);
     spec->inBuildArchitectures = inBuildArch;
     if (passPhrase) {
        spec->passPhrase = strdup(passPhrase);
index 1bb09b9..c76056e 100644 (file)
@@ -64,8 +64,6 @@ struct SpecStruct {
     char *buildRoot;
     char *buildSubdir;
 
-    char *docDir;
-
     char *passPhrase;
     int timeCheck;
     char *cookie;
index 27ebe3f..7b1afab 100644 (file)
@@ -360,8 +360,6 @@ Spec newSpec(void)
     
     spec->buildSubdir = NULL;
 
-    spec->docDir = NULL;
-
     spec->passPhrase = NULL;
     spec->timeCheck = 0;
     spec->cookie = NULL;
@@ -408,7 +406,6 @@ void freeSpec(Spec spec)
     FREE(spec->buildSubdir);
     FREE(spec->specFile);
     FREE(spec->sourceRpmName);
-    FREE(spec->docDir);
 
     while (spec->readStack) {
        rl = spec->readStack;
index f13d495..eb48063 100644 (file)
@@ -925,7 +925,6 @@ int cpioBuildArchive(CFD_t *cfd, struct cpioFileMapping * mappings,
     if ((rc = padoutfd(cfd, &totalsize, 4)))
        return rc;
 
-fprintf(stderr, "ARCHIVESIZE  total: %d\n", totalsize);
     if (archiveSize) *archiveSize = totalsize;
 
     return 0;
index eedcf2e..02ea6f2 100644 (file)
@@ -24,7 +24,7 @@ extern MacroContext globalMacroContext;
 #define        RMIL_MACROFILES -9
 #define        RMIL_RPMRC      -7
 #define        RMIL_TARBALL    -5
-#define        RMIL_SPEC       -1
+#define        RMIL_SPEC       -3
 #define        RMIL_OLDSPEC    -1
 #define        RMIL_GLOBAL     0
 
index eedcf2e..02ea6f2 100644 (file)
@@ -24,7 +24,7 @@ extern MacroContext globalMacroContext;
 #define        RMIL_MACROFILES -9
 #define        RMIL_RPMRC      -7
 #define        RMIL_TARBALL    -5
-#define        RMIL_SPEC       -1
+#define        RMIL_SPEC       -3
 #define        RMIL_OLDSPEC    -1
 #define        RMIL_GLOBAL     0