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());
"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");
fprintf(f, "fi\n");
}
+#if DEAD
headerGetEntry(spec->packages->header, RPMTAG_NAME,
NULL, (void **)&s, NULL);
fprintf(f, "RPM_PACKAGE_NAME=\"%s\"\n", s);
fprintf(f, "RPM_PACKAGE_RELEASE=\"%s\"\n", s);
fprintf(f, "export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION "
"RPM_PACKAGE_RELEASE\n");
+#endif
return 0;
}
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();
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;
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);
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,
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));
csa, spec->passPhrase, NULL))) {
return rc;
}
-
- pkg = pkg->next;
}
return 0;
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;
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);
char *buildRoot;
char *buildSubdir;
- char *docDir;
-
char *passPhrase;
int timeCheck;
char *cookie;
spec->buildSubdir = NULL;
- spec->docDir = NULL;
-
spec->passPhrase = NULL;
spec->timeCheck = 0;
spec->cookie = NULL;
FREE(spec->buildSubdir);
FREE(spec->specFile);
FREE(spec->sourceRpmName);
- FREE(spec->docDir);
while (spec->readStack) {
rl = spec->readStack;
if ((rc = padoutfd(cfd, &totalsize, 4)))
return rc;
-fprintf(stderr, "ARCHIVESIZE total: %d\n", totalsize);
if (archiveSize) *archiveSize = totalsize;
return 0;
#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
#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