exit 0;
fi
-if [ X"$@" = X ]; then
+if [ X"$@" = X -a "X`uname -s`" = "XLinux" ]; then
./configure --prefix=/usr
else
./configure "$@"
while (*cmd != '/') cmd--;
*cmd = '\0';
- rpmSetVar(RPMVAR_SOURCEDIR, buf);
+ addMacro(&globalMacroContext, "_sourcedir", NULL, buf, RMIL_TARBALL);
} else if (arg[0] == '/') {
specfile = arg;
} else {
p = spec->sources;
while (p) {
if (! (p->flags & RPMBUILD_ISNO)) {
- sprintf(buf, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), p->source);
+ strcpy(buf, "%{_sourcedir}/");
+ expandMacros(spec, spec->macros, buf, sizeof(buf));
+ strcat(buf, p->source);
unlink(buf);
}
p = p->next;
p = pkg->icon;
while (p) {
if (! (p->flags & RPMBUILD_ISNO)) {
- sprintf(buf, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), p->source);
+ strcpy(buf, "%{_sourcedir}/");
+ expandMacros(spec, spec->macros, buf, sizeof(buf));
+ strcat(buf, p->source);
unlink(buf);
}
p = p->next;
}
}
+/*
+ * The _preScript string is expanded to export values to a script environment.
+ */
+
+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"
+;
+
static int writeVars(Spec spec, FILE *f)
{
char *arch, *os, *s;
+ char buf[BUFSIZ];
+
+ strcpy(buf, _preScriptEnvironment);
+ expandMacros(spec, spec->macros, buf, sizeof(buf));
+ fprintf(f, "%s\n", buf);
rpmGetArchInfo(&arch, NULL);
rpmGetOsInfo(&os, NULL);
- fprintf(f, "RPM_SOURCE_DIR=\"%s\"\n", rpmGetVar(RPMVAR_SOURCEDIR));
- fprintf(f, "RPM_BUILD_DIR=\"%s\"\n", rpmGetVar(RPMVAR_BUILDDIR));
fprintf(f, "RPM_DOC_DIR=\"%s\"\n", spec->docDir);
- fprintf(f, "RPM_OPT_FLAGS=\"%s\"\n", rpmGetVar(RPMVAR_OPTFLAGS));
fprintf(f, "RPM_ARCH=\"%s\"\n", arch);
fprintf(f, "RPM_OS=\"%s\"\n", os);
- fprintf(f, "export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_DOC_DIR "
- "RPM_OPT_FLAGS RPM_ARCH RPM_OS\n");
+
+ fprintf(f, "export RPM_DOC_DIR RPM_ARCH RPM_OS\n");
if (spec->buildRoot) {
fprintf(f, "RPM_BUILD_ROOT=\"%s\"\n", spec->buildRoot);
return 0;
}
+static char *_preScriptChdir =
+ "umask 022\n"
+ "cd %{_builddir}\n"
+;
+
int doScript(Spec spec, int what, char *name, StringBuf sb, int test)
{
int fd;
}
fprintf(f, rpmIsVerbose() ? "set -x\n\n" : "exec > /dev/null\n\n");
- fprintf(f, "umask 022\n");
- fprintf(f, "cd %s\n", rpmGetVar(RPMVAR_BUILDDIR));
+
+/* XXX umask 022; cd %{_builddir} */
+ { char buf[BUFSIZ];
+ strcpy(buf, _preScriptChdir);
+ expandMacros(spec, spec->macros, buf, sizeof(buf));
+ fputs(buf, f);
+ }
+
if (what != RPMBUILD_PREP && what != RPMBUILD_RMBUILD) {
if (spec->buildSubdir) {
fprintf(f, "cd %s\n", spec->buildSubdir);
pkg->cpioCount = 0;
if (pkg->fileFile) {
+ strcpy(buf, "%{_builddir}/");
+ expandMacros(spec, spec->macros, buf, sizeof(buf));
if (spec->buildSubdir) {
- sprintf(buf, "%s/%s/%s", rpmGetVar(RPMVAR_BUILDDIR),
- spec->buildSubdir, pkg->fileFile);
- } else {
- sprintf(buf, "%s/%s", rpmGetVar(RPMVAR_BUILDDIR), pkg->fileFile);
+ strcat(buf, spec->buildSubdir);
+ strcat(buf, "/");
}
+ strcat(buf, pkg->fileFile);
+
if ((f = fopen(buf, "r")) == NULL) {
rpmError(RPMERR_BADFILENAME,
"Could not open %%files file: %s", pkg->fileFile);
RPM_INT32_TYPE, &srcPtr->num, 1);
}
}
- sprintf(buf, "%s%s/%s",
- srcPtr->flags & RPMBUILD_ISNO ? "!" : "",
- rpmGetVar(RPMVAR_SOURCEDIR), srcPtr->source);
+
+ { char *s = buf;
+ if (srcPtr->flags & RPMBUILD_ISNO)
+ *s++ = '!';
+ strcpy(s, "%{_sourcedir}/");
+ }
+ expandMacros(spec, spec->macros, buf, sizeof(buf));
+ strcat(buf, srcPtr->source);
appendLineStringBuf(sourceFiles, buf);
}
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
for (srcPtr = pkg->icon; srcPtr != NULL; srcPtr = srcPtr->next) {
- sprintf(buf, "%s%s/%s",
- srcPtr->flags & RPMBUILD_ISNO ? "!" : "",
- rpmGetVar(RPMVAR_SOURCEDIR), srcPtr->source);
+ char *s = buf;
+ if (srcPtr->flags & RPMBUILD_ISNO)
+ *s++ = '!';
+ strcpy(s, "%{_sourcedir}/");
+ expandMacros(spec, spec->macros, buf, sizeof(buf));
+ strcat(buf, srcPtr->source);
appendLineStringBuf(sourceFiles, buf);
}
}
char buf[BUFSIZ];
FILE *f;
- sprintf(buf, "%s/%s/%s", rpmGetVar(RPMVAR_BUILDDIR),
- spec->buildSubdir, file);
+ strcpy(buf, "%{_builddir}/");
+ expandMacros(spec, spec->macros, buf, sizeof(buf));
+ strcat(buf, spec->buildSubdir);
+ strcat(buf, "/");
+ strcat(buf, file);
+
if ((f = fopen(buf, "r")) == NULL) {
freeStringBuf(sb);
return NULL;
struct stat statbuf;
int fd;
- sprintf(buf, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), file);
+ strcpy(buf, "%{_sourcedir}/");
+ expandMacros(NULL, &globalMacroContext, buf, sizeof(buf));
+ strcat(buf, file);
+
if (stat(buf, &statbuf)) {
rpmError(RPMERR_BADSPEC, "Unable to read icon: %s", file);
return RPMERR_BADSPEC;
static char buf[BUFSIZ];
char file[BUFSIZ];
char args[BUFSIZ];
- char *s;
struct Source *sp;
int compressed;
- s = NULL;
- sp = spec->sources;
- while (sp) {
+ for (sp = spec->sources; sp != NULL; sp = sp->next) {
if ((sp->flags & RPMBUILD_ISPATCH) && (sp->num == c)) {
- s = sp->source;
break;
}
- sp = sp->next;
}
- if (! s) {
+ if (sp == NULL) {
rpmError(RPMERR_BADSPEC, "No patch number %d", c);
return NULL;
}
- sprintf(file, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), s);
+ strcpy(file, "%{_sourcedir}/");
+ expandMacros(spec, spec->macros, file, sizeof(file));
+ strcat(file, sp->source);
args[0] = '\0';
if (db) {
struct Source *sp;
int compressed;
- s = NULL;
- sp = spec->sources;
- while (sp) {
+ for (sp = spec->sources; sp != NULL; sp = sp->next) {
if ((sp->flags & RPMBUILD_ISSOURCE) && (sp->num == c)) {
- s = sp->source;
break;
}
- sp = sp->next;
}
- if (! s) {
+ if (sp == NULL) {
rpmError(RPMERR_BADSPEC, "No source number %d", c);
return NULL;
}
- sprintf(file, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), s);
+ strcpy(file, "%{_sourcedir}/");
+ expandMacros(spec, spec->macros, file, sizeof(file));
+ strcat(file, sp->source);
+
taropts = (rpmIsVerbose() && !quietly ? "-xvvf" : "-xf");
if (isCompressed(file, &compressed)) {
poptFreeContext(optCon);
/* cd to the build dir */
- sprintf(buf, "cd %s", rpmGetVar(RPMVAR_BUILDDIR));
+ strcpy(buf, "cd %{_builddir}");
+ expandMacros(spec, spec->macros, buf, sizeof(buf));
appendLineStringBuf(spec->prep, buf);
/* delete any old sources */
}
/* do the default action */
- if (!createDir && !skipDefaultAction) {
+ if (!createDir && !skipDefaultAction) {
chptr = doUntar(spec, 0, quietly);
if (!chptr) {
return RPMERR_BADSPEC;
#include "rpmbuild.h"
-#ifdef DEAD
-#ifdef DYING
-static void setStandardMacros(Spec spec, char *arch, char *os);
-#endif
-
-static void setStandardMacros(Spec spec, char *arch, char *os)
-{
- char buf[BUFSIZ];
- int x;
-
- addMacro(spec->macros, "sourcedir", NULL, rpmGetVar(RPMVAR_SOURCEDIR), RMIL_SPEC);
- addMacro(spec->macros, "builddir", NULL, rpmGetVar(RPMVAR_BUILDDIR), RMIL_SPEC);
- addMacro(spec->macros, "optflags", NULL, rpmGetVar(RPMVAR_OPTFLAGS), RMIL_SPEC);
- addMacro(spec->macros, "buildarch", NULL, arch, RMIL_SPEC);
- addMacro(spec->macros, "buildos", NULL, os, RMIL_SPEC);
-
- x = 0;
- while (arch[x]) {
- buf[x] = tolower(arch[x]);
- x++;
- }
- buf[x] = '\0';
- addMacro(spec->macros, "buildarch_lc", NULL, buf, RMIL_SPEC);
- x = 0;
- while (os[x]) {
- buf[x] = tolower(os[x]);
- x++;
- }
- buf[x] = '\0';
- addMacro(spec->macros, "buildos_lc", NULL, buf, RMIL_SPEC);
-}
-#endif /* DEAD */
-
static struct PartRec {
int part;
int len;
spec->numSources++;
if (tag != RPMTAG_ICON) {
- sprintf(body, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), p->source);
+ strcpy(body, "%{_sourcedir}/");
+ expandMacros(spec, spec->macros, body, sizeof(body)); /* W2DO? */
+ strcat(body, p->source);
+
sprintf(buf, "%s%d",
(flag & RPMBUILD_ISPATCH) ? "PATCH" : "SOURCE", num);
addMacro(spec->macros, buf, NULL, body, RMIL_SPEC);
int firstFree;
} MacroContext;
+extern MacroContext globalMacroContext;
+
/*
* Markers for types of macros added throughout rpm.
*/
#define RMIL_MACROFILES -9
#define RMIL_RPMRC -7
+#define RMIL_TARBALL -5
#define RMIL_SPEC -1
#define RMIL_OLDSPEC -1
#define RMIL_GLOBAL 0
int firstFree;
} MacroContext;
+extern MacroContext globalMacroContext;
+
/*
* Markers for types of macros added throughout rpm.
*/
#define RMIL_MACROFILES -9
#define RMIL_RPMRC -7
+#define RMIL_TARBALL -5
#define RMIL_SPEC -1
#define RMIL_OLDSPEC -1
#define RMIL_GLOBAL 0