summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorjbj <devnull@localhost>1998-09-05 20:02:08 +0000
committerjbj <devnull@localhost>1998-09-05 20:02:08 +0000
commite8b7b65b28000640df90a72d920eca7daa3db0aa (patch)
tree8415783005234299add3369d0e0826657d854ea0 /build
parentdd8f00921aa4ec5b45d0db8b3b55b8ea109f1fed (diff)
downloadlibrpm-tizen-e8b7b65b28000640df90a72d920eca7daa3db0aa.tar.gz
librpm-tizen-e8b7b65b28000640df90a72d920eca7daa3db0aa.tar.bz2
librpm-tizen-e8b7b65b28000640df90a72d920eca7daa3db0aa.zip
Start converting variables into macro expansions.
RPMVAR_SOURCEDIR -> %{_sourcedir} RPMVAR_BUILDDIR -> %{_builddir} CVS patchset: 2279 CVS date: 1998/09/05 20:02:08
Diffstat (limited to 'build')
-rw-r--r--build/build.c46
-rw-r--r--build/files.c30
-rw-r--r--build/pack.c8
-rw-r--r--build/parsePreamble.c5
-rw-r--r--build/parsePrep.c31
-rw-r--r--build/parseSpec.c33
-rw-r--r--build/spec.c5
7 files changed, 85 insertions, 73 deletions
diff --git a/build/build.c b/build/build.c
index d10301497..b8578c20c 100644
--- a/build/build.c
+++ b/build/build.c
@@ -18,7 +18,9 @@ static void doRmSource(Spec spec)
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;
@@ -29,7 +31,9 @@ static void doRmSource(Spec spec)
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;
@@ -38,21 +42,34 @@ static void doRmSource(Spec spec)
}
}
+/*
+ * 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);
@@ -79,6 +96,11 @@ static int writeVars(Spec spec, FILE *f)
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;
@@ -129,8 +151,14 @@ int doScript(Spec spec, int what, char *name, StringBuf sb, int test)
}
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);
diff --git a/build/files.c b/build/files.c
index 5be8f7dcc..51c0b82a7 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1065,12 +1065,14 @@ static int processPackageFiles(Spec spec, Package pkg,
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);
@@ -1327,17 +1329,25 @@ int processSourceFiles(Spec spec)
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);
}
}
diff --git a/build/pack.c b/build/pack.c
index 1f7206a4d..b471e6cba 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -362,8 +362,12 @@ static StringBuf addFileToTagAux(Spec spec, char *file, StringBuf sb)
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;
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
index 9b942c98c..3dd07c1b9 100644
--- a/build/parsePreamble.c
+++ b/build/parsePreamble.c
@@ -278,7 +278,10 @@ static int readIcon(Header h, char *file)
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;
diff --git a/build/parsePrep.c b/build/parsePrep.c
index a5b014102..bb165fc80 100644
--- a/build/parsePrep.c
+++ b/build/parsePrep.c
@@ -50,25 +50,22 @@ static char *doPatch(Spec spec, int c, int strip, char *db,
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) {
@@ -120,21 +117,20 @@ static char *doUntar(Spec spec, int c, int quietly)
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)) {
@@ -242,7 +238,8 @@ static int doSetupMacro(Spec spec, char *line)
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 */
@@ -259,7 +256,7 @@ static int doSetupMacro(Spec spec, char *line)
}
/* do the default action */
- if (!createDir && !skipDefaultAction) {
+ if (!createDir && !skipDefaultAction) {
chptr = doUntar(spec, 0, quietly);
if (!chptr) {
return RPMERR_BADSPEC;
diff --git a/build/parseSpec.c b/build/parseSpec.c
index 9aaa6b78e..85036f6ac 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -2,39 +2,6 @@
#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;
diff --git a/build/spec.c b/build/spec.c
index 64afbbf6d..27ebe3fe4 100644
--- a/build/spec.c
+++ b/build/spec.c
@@ -308,7 +308,10 @@ int addSource(Spec spec, Package pkg, char *field, int tag)
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);