reload macros from cmd line when re-reading config files.
CVS patchset: 3479 CVS date: 1999/12/12 21:14:05
This commit is contained in:
parent
292b9f10be
commit
8f481702d8
1
CHANGES
1
CHANGES
|
@ -21,6 +21,7 @@
|
|||
- perform glob on remote ftp query args.
|
||||
- fix: ftpAbort must close the data channel to read abort status.
|
||||
- perform glob on remote ftp install args.
|
||||
- fix: reload macros from cmd line when re-reading config files.
|
||||
|
||||
3.0.2 -> 3.0.3
|
||||
- add --eval to find result of macro expansion.
|
||||
|
|
4
build.c
4
build.c
|
@ -294,7 +294,7 @@ int build(const char *arg, struct rpmBuildArguments *ba, const char *passPhrase,
|
|||
printf(_("Building for target %s\n"), target);
|
||||
|
||||
/* Read in configuration for target. */
|
||||
freeMacros(NULL); /* XXX macros from CLI are destroyed too */
|
||||
rpmFreeMacros(NULL);
|
||||
rpmReadConfigFiles(rcfile, target);
|
||||
rc = buildForTarget(arg, ba, passPhrase, fromTarball, cookie,
|
||||
force, nodeps);
|
||||
|
@ -304,7 +304,7 @@ int build(const char *arg, struct rpmBuildArguments *ba, const char *passPhrase,
|
|||
|
||||
exit:
|
||||
/* Restore original configuration. */
|
||||
freeMacros(NULL); /* XXX macros from CLI are destroyed too */
|
||||
rpmFreeMacros(NULL);
|
||||
rpmReadConfigFiles(rcfile, NULL);
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -1100,62 +1100,10 @@ fprintf(stderr, "*** PBF fileURL %s\n", fileURL);
|
|||
diskURL = rpmGenPath(fl->buildRootURL, NULL, fileURL);
|
||||
|
||||
if (doGlob) {
|
||||
int i;
|
||||
#ifdef DYING
|
||||
const char * diskRoot;
|
||||
const char * globURL;
|
||||
char * globRoot = NULL;
|
||||
glob_t glob_result;
|
||||
size_t maxb, nb;
|
||||
int ut;
|
||||
|
||||
glob_result.gl_pathc = 0;
|
||||
glob_result.gl_pathv = NULL;
|
||||
if (Glob(diskURL, 0, glob_error, &glob_result) ||
|
||||
(glob_result.gl_pathc < 1)) {
|
||||
rpmError(RPMERR_BADSPEC, _("File not found by glob: %s"), diskURL);
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
/* XXX Prepend the diskURL leader for globs that have stripped it off */
|
||||
maxb = 0;
|
||||
for (i = 0; i < glob_result.gl_pathc; i++) {
|
||||
if ((nb = strlen(&(glob_result.gl_pathv[i][0]))) > maxb)
|
||||
maxb = nb;
|
||||
}
|
||||
|
||||
ut = urlPath(diskURL, &diskRoot);
|
||||
nb = ((ut > URL_IS_DASH) ? (diskRoot - diskURL) : 0);
|
||||
maxb += nb;
|
||||
maxb += 1;
|
||||
globURL = globRoot = alloca(maxb);
|
||||
|
||||
switch (ut) {
|
||||
case URL_IS_HTTP:
|
||||
case URL_IS_FTP:
|
||||
case URL_IS_PATH:
|
||||
case URL_IS_DASH:
|
||||
strncpy(globRoot, diskURL, nb);
|
||||
break;
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
globRoot += nb;
|
||||
*globRoot = '\0';
|
||||
if (_debug)
|
||||
fprintf(stderr, "*** GLOB maxb %d diskURL %d %*s globURL %p %s\n", maxb, nb, nb, diskURL, globURL, globURL);
|
||||
|
||||
for (i = 0; rc == 0 && i < glob_result.gl_pathc; i++) {
|
||||
const char * globFile = &(glob_result.gl_pathv[i][0]);
|
||||
if (globRoot > globURL && globRoot[-1] == '/')
|
||||
while (*globFile == '/') globFile++;
|
||||
strcpy(globRoot, globFile);
|
||||
rc = addFile(fl, globURL, NULL);
|
||||
}
|
||||
Globfree(&glob_result);
|
||||
#else
|
||||
int argc = 0;
|
||||
const char ** argv = NULL;
|
||||
int argc = 0;
|
||||
int i;
|
||||
|
||||
rc = rpmGlob(diskURL, &argc, &argv);
|
||||
if (rc == 0) {
|
||||
for (i = 0; i < argc; i++) {
|
||||
|
@ -1164,7 +1112,6 @@ fprintf(stderr, "*** GLOB maxb %d diskURL %d %*s globURL %p %s\n", maxb, nb, nb,
|
|||
}
|
||||
xfree(argv);
|
||||
}
|
||||
#endif /* DYING */
|
||||
} else {
|
||||
rc = addFile(fl, diskURL, NULL);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "buildio.h"
|
||||
|
||||
extern char *specedit;
|
||||
extern MacroContext globalMacroContext;
|
||||
extern MacroContext rpmGlobalMacroContext;
|
||||
|
||||
#define SKIPWHITE(_x) {while(*(_x) && (isspace(*_x) || *(_x) == ',')) (_x)++;}
|
||||
#define SKIPNONWHITE(_x){while(*(_x) &&!(isspace(*_x) || *(_x) == ',')) (_x)++;}
|
||||
|
@ -446,7 +446,7 @@ Spec newSpec(void)
|
|||
spec->force = 0;
|
||||
spec->anyarch = 0;
|
||||
|
||||
spec->macros = &globalMacroContext;
|
||||
spec->macros = &rpmGlobalMacroContext;
|
||||
|
||||
return spec;
|
||||
}
|
||||
|
|
74
lib/macro.c
74
lib/macro.c
|
@ -31,7 +31,7 @@ static int _debug = 0;
|
|||
#define urlPath(_xr, _r) *(_r) = (_xr)
|
||||
|
||||
typedef FILE * FD_t;
|
||||
#define Fopen(_path, _fmode) fopen(_path, "_r");
|
||||
#define Fopen(_path, _fmode) fopen(_path, "r");
|
||||
#define Ferror ferror
|
||||
#define Fstrerror(_fd) strerror(errno)
|
||||
#define Fread fread
|
||||
|
@ -47,7 +47,8 @@ typedef FILE * FD_t;
|
|||
|
||||
#include <rpmmacro.h>
|
||||
|
||||
struct MacroContext globalMacroContext;
|
||||
struct MacroContext rpmGlobalMacroContext;
|
||||
struct MacroContext rpmCLIMacroContext;
|
||||
|
||||
typedef struct MacroBuf {
|
||||
const char *s; /* text to expand */
|
||||
|
@ -85,15 +86,12 @@ compareMacroName(const void *ap, const void *bp)
|
|||
MacroEntry *ame = *((MacroEntry **)ap);
|
||||
MacroEntry *bme = *((MacroEntry **)bp);
|
||||
|
||||
if (ame == NULL && bme == NULL) {
|
||||
if (ame == NULL && bme == NULL)
|
||||
return 0;
|
||||
}
|
||||
if (ame == NULL) {
|
||||
if (ame == NULL)
|
||||
return 1;
|
||||
}
|
||||
if (bme == NULL) {
|
||||
if (bme == NULL)
|
||||
return -1;
|
||||
}
|
||||
return strcmp(ame->name, bme->name);
|
||||
}
|
||||
|
||||
|
@ -132,14 +130,14 @@ sortMacroTable(MacroContext *mc)
|
|||
}
|
||||
|
||||
void
|
||||
dumpMacroTable(MacroContext * mc, FILE * fp)
|
||||
rpmDumpMacroTable(MacroContext * mc, FILE * fp)
|
||||
{
|
||||
int i;
|
||||
int nempty = 0;
|
||||
int nactive = 0;
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &globalMacroContext;
|
||||
mc = &rpmGlobalMacroContext;
|
||||
if (fp == NULL)
|
||||
fp = stderr;
|
||||
|
||||
|
@ -171,7 +169,7 @@ findEntry(MacroContext *mc, const char *name, size_t namelen)
|
|||
char namebuf[1024];
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &globalMacroContext;
|
||||
mc = &rpmGlobalMacroContext;
|
||||
if (! mc->firstFree)
|
||||
return NULL;
|
||||
|
||||
|
@ -1061,7 +1059,7 @@ expandMacro(MacroBuf *mb)
|
|||
}
|
||||
|
||||
if (STREQ("dump", f, fn)) {
|
||||
dumpMacroTable(mb->mc, NULL);
|
||||
rpmDumpMacroTable(mb->mc, NULL);
|
||||
while (iseol(*se))
|
||||
se++;
|
||||
s = se;
|
||||
|
@ -1201,7 +1199,7 @@ expandMacros(void *spec, MacroContext *mc, char *s, size_t slen)
|
|||
if (s == NULL || slen <= 0)
|
||||
return 0;
|
||||
if (mc == NULL)
|
||||
mc = &globalMacroContext;
|
||||
mc = &rpmGlobalMacroContext;
|
||||
|
||||
tbuf = alloca(slen + 1);
|
||||
memset(tbuf, 0, (slen + 1));
|
||||
|
@ -1233,7 +1231,7 @@ addMacro(MacroContext *mc, const char *n, const char *o, const char *b, int leve
|
|||
MacroEntry **mep;
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &globalMacroContext;
|
||||
mc = &rpmGlobalMacroContext;
|
||||
|
||||
/* If new name, expand macro table */
|
||||
if ((mep = findEntry(mc, n, 0)) == NULL) {
|
||||
|
@ -1256,7 +1254,7 @@ delMacro(MacroContext *mc, const char *n)
|
|||
MacroEntry **mep;
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &globalMacroContext;
|
||||
mc = &rpmGlobalMacroContext;
|
||||
/* If name exists, pop entry */
|
||||
if ((mep = findEntry(mc, n, 0)) != NULL) {
|
||||
popMacro(mep);
|
||||
|
@ -1272,20 +1270,40 @@ rpmDefineMacro(MacroContext *mc, const char *macro, int level)
|
|||
MacroBuf macrobuf, *mb = ¯obuf;
|
||||
|
||||
/* XXX just enough to get by */
|
||||
mb->mc = (mc ? mc : &globalMacroContext);
|
||||
mb->mc = (mc ? mc : &rpmGlobalMacroContext);
|
||||
(void)doDefine(mb, macro, level, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Load a macro context into rpmGlobalMacroContext */
|
||||
void
|
||||
initMacros(MacroContext *mc, const char *macrofiles)
|
||||
rpmLoadMacros(MacroContext * mc, int level)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (mc == NULL || mc == &rpmGlobalMacroContext)
|
||||
return;
|
||||
|
||||
for (i = 0; i < mc->firstFree; i++) {
|
||||
MacroEntry **mep, *me;
|
||||
mep = &mc->macroTable[i];
|
||||
me = *mep;
|
||||
|
||||
if (me == NULL) /* XXX this should never happen */
|
||||
continue;
|
||||
addMacro(NULL, me->name, me->opts, me->body, (level - 1));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rpmInitMacros(MacroContext *mc, const char *macrofiles)
|
||||
{
|
||||
char *m, *mfile, *me;
|
||||
|
||||
if (macrofiles == NULL)
|
||||
return;
|
||||
if (mc == NULL)
|
||||
mc = &globalMacroContext;
|
||||
mc = &rpmGlobalMacroContext;
|
||||
|
||||
for (mfile = m = xstrdup(macrofiles); *mfile; mfile = me) {
|
||||
FD_t fd;
|
||||
|
@ -1315,8 +1333,10 @@ initMacros(MacroContext *mc, const char *macrofiles)
|
|||
buf[sizeof(buf)-1] = '\0';
|
||||
|
||||
fd = Fopen(buf, "r.fpio");
|
||||
if (fd == NULL || Ferror(fd))
|
||||
if (fd == NULL || Ferror(fd)) {
|
||||
if (fd) Fclose(fd);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* XXX Assume new fangled macro expansion */
|
||||
max_macro_depth = 16;
|
||||
|
@ -1336,15 +1356,18 @@ initMacros(MacroContext *mc, const char *macrofiles)
|
|||
}
|
||||
if (m)
|
||||
free(m);
|
||||
|
||||
/* Reload cmdline macros */
|
||||
rpmLoadMacros(&rpmCLIMacroContext, RMIL_CMDLINE);
|
||||
}
|
||||
|
||||
void
|
||||
freeMacros(MacroContext *mc)
|
||||
rpmFreeMacros(MacroContext *mc)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &globalMacroContext;
|
||||
mc = &rpmGlobalMacroContext;
|
||||
|
||||
for (i = 0; i < mc->firstFree; i++) {
|
||||
MacroEntry *me;
|
||||
|
@ -1375,6 +1398,7 @@ int isCompressed(const char *file, int *compressed)
|
|||
if (fd == NULL || Ferror(fd)) {
|
||||
/* XXX Fstrerror */
|
||||
rpmError(RPMERR_BADSPEC, _("File %s: %s"), file, Fstrerror(fd));
|
||||
if (fd) Fclose(fd);
|
||||
return 1;
|
||||
}
|
||||
nb = Fread(magic, sizeof(char), sizeof(magic), fd);
|
||||
|
@ -1651,7 +1675,7 @@ main(int argc, char *argv[])
|
|||
exit(1);
|
||||
}
|
||||
|
||||
initMacros(NULL, macrofiles);
|
||||
rpmInitMacros(NULL, macrofiles);
|
||||
for ( ; optind < argc; optind++) {
|
||||
const char *val;
|
||||
|
||||
|
@ -1661,6 +1685,7 @@ main(int argc, char *argv[])
|
|||
xfree(val);
|
||||
}
|
||||
}
|
||||
rpmFreeMacros(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1676,8 +1701,8 @@ main(int argc, char *argv[])
|
|||
FILE *fp;
|
||||
int x;
|
||||
|
||||
initMacros(NULL, macrofiles);
|
||||
dumpMacroTable(NULL, NULL);
|
||||
rpmInitMacros(NULL, macrofiles);
|
||||
rpmDumpMacroTable(NULL, NULL);
|
||||
|
||||
if ((fp = fopen(testfile, "r")) != NULL) {
|
||||
while(rdcl(buf, sizeof(buf), fp, 1)) {
|
||||
|
@ -1693,6 +1718,7 @@ main(int argc, char *argv[])
|
|||
fprintf(stderr, "%d->%s\n <-\n", x, buf);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
}
|
||||
rpmFreeMacros(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ typedef /*@abstract@*/ struct MacroContext {
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void dumpMacroTable (MacroContext * mc, FILE * fp);
|
||||
void rpmDumpMacroTable (MacroContext * mc, FILE * fp);
|
||||
|
||||
/* XXX this is used only in build/expression.c and will go away. */
|
||||
const char *getMacroBody (MacroContext *mc, const char *name);
|
||||
|
@ -45,8 +45,9 @@ void addMacro (MacroContext * mc, const char * n, const char * o,
|
|||
void delMacro (MacroContext * mc, const char * n);
|
||||
|
||||
int rpmDefineMacro (MacroContext * mc, const char * macro, int level);
|
||||
void initMacros (MacroContext * mc, const char * macrofile);
|
||||
void freeMacros (MacroContext * mc);
|
||||
void rpmLoadMacros (MacroContext *mc, int level);
|
||||
void rpmInitMacros (MacroContext * mc, const char * macrofiles);
|
||||
void rpmFreeMacros (MacroContext * mc);
|
||||
|
||||
#define COMPRESSED_NOT 0
|
||||
#define COMPRESSED_OTHER 1
|
||||
|
|
|
@ -571,7 +571,7 @@ int rpmReadRC(const char * rcfiles)
|
|||
{ const char *macrofiles;
|
||||
if ((macrofiles = rpmGetVar(RPMVAR_MACROFILES)) != NULL) {
|
||||
macrofiles = strdup(macrofiles);
|
||||
initMacros(NULL, macrofiles);
|
||||
rpmInitMacros(NULL, macrofiles);
|
||||
xfree(macrofiles);
|
||||
}
|
||||
}
|
||||
|
@ -1232,7 +1232,7 @@ void rpmRebuildTargetVars(const char **buildtarget, const char ** canontarget)
|
|||
|
||||
/*
|
||||
* XXX All this macro pokery/jiggery could be achieved by doing a delayed
|
||||
* initMacros(NULL, PER-PLATFORM-MACRO-FILE-NAMES);
|
||||
* rpmInitMacros(NULL, PER-PLATFORM-MACRO-FILE-NAMES);
|
||||
*/
|
||||
delMacro(NULL, "_target");
|
||||
addMacro(NULL, "_target", NULL, ct, RMIL_RPMRC);
|
||||
|
@ -1367,7 +1367,7 @@ int rpmShowRC(FILE *f)
|
|||
fprintf(f, "%-21s : %s\n", opt->name, s ? s : "(not set)");
|
||||
}
|
||||
|
||||
dumpMacroTable(NULL, f);
|
||||
rpmDumpMacroTable(NULL, f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ typedef /*@abstract@*/ /*@refcounted@*/ struct urlinfo {
|
|||
const char * password;
|
||||
const char * host;
|
||||
const char * portstr;
|
||||
const char * path;
|
||||
const char * proxyu; /* FTP: proxy user */
|
||||
const char * proxyh; /* FTP/HTTP: proxy host */
|
||||
int proxyp; /* FTP/HTTP: proxy port */
|
||||
|
|
50
lib/url.c
50
lib/url.c
|
@ -112,9 +112,6 @@ DBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file, li
|
|||
FREE(u->password);
|
||||
FREE(u->host);
|
||||
FREE(u->portstr);
|
||||
#ifdef DYING
|
||||
FREE(u->path);
|
||||
#endif
|
||||
FREE(u->proxyu);
|
||||
FREE(u->proxyh);
|
||||
|
||||
|
@ -195,18 +192,7 @@ static void urlFind(urlinfo *uret, int mustAsk)
|
|||
uCache[ucx] = urlLink(u, "uCache (miss)");
|
||||
u = urlFree(u, "urlSplit (urlFind miss)");
|
||||
} else {
|
||||
#ifdef DYING
|
||||
/* XXX Swap original url and path into the cached structure */
|
||||
const char *up = uCache[i]->path;
|
||||
ucx = i;
|
||||
uCache[ucx]->path = u->path;
|
||||
u->path = up;
|
||||
up = uCache[ucx]->url;
|
||||
uCache[ucx]->url = u->url;
|
||||
u->url = up;
|
||||
#else
|
||||
ucx = i;
|
||||
#endif
|
||||
u = urlFree(u, "urlSplit (urlFind hit)");
|
||||
}
|
||||
|
||||
|
@ -383,10 +369,7 @@ int urlSplit(const char * url, urlinfo *uret)
|
|||
continue;
|
||||
}
|
||||
|
||||
/* Item was everything-but-path. Save path and continue parse on rest */
|
||||
#ifdef DYING
|
||||
u->path = xstrdup((*se ? se : "/"));
|
||||
#endif
|
||||
/* Item was everything-but-path. Continue parse on rest */
|
||||
*se = '\0';
|
||||
break;
|
||||
}
|
||||
|
@ -457,39 +440,16 @@ int urlGetFile(const char * url, const char * dest) {
|
|||
sfd = Fopen(url, "r.ufdio");
|
||||
if (sfd == NULL || Ferror(sfd)) {
|
||||
rpmMessage(RPMMESS_DEBUG, _("failed to open %s: %s\n"), url, Fstrerror(sfd));
|
||||
#ifdef DYING
|
||||
if (sfd)
|
||||
Fclose(sfd);
|
||||
return FTPERR_UNKNOWN;
|
||||
#else
|
||||
rc = FTPERR_UNKNOWN;
|
||||
goto exit;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DYING
|
||||
{ urlinfo sfu;
|
||||
sfu = ufdGetUrlinfo(sfd);
|
||||
if (sfu != NULL && dest == NULL) {
|
||||
const char *fileName = sfu->path;
|
||||
if ((dest = strrchr(fileName, '/')) != NULL)
|
||||
dest++;
|
||||
else
|
||||
dest = fileName;
|
||||
}
|
||||
if (sfu != NULL) {
|
||||
(void) urlFree(sfu, "ufdGetUrlinfo (urlGetFile)");
|
||||
sfu = NULL;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (dest == NULL) {
|
||||
if ((dest = strrchr(sfuPath, '/')) != NULL)
|
||||
dest++;
|
||||
else
|
||||
dest = sfuPath;
|
||||
}
|
||||
#endif
|
||||
|
||||
tfd = Fopen(dest, "w.ufdio");
|
||||
if (_url_debug)
|
||||
|
@ -497,16 +457,8 @@ fprintf(stderr, "*** urlGetFile sfd %p %s tfd %p %s\n", sfd, url, tfd, dest);
|
|||
if (tfd == NULL || Ferror(tfd)) {
|
||||
/* XXX Fstrerror */
|
||||
rpmMessage(RPMMESS_DEBUG, _("failed to create %s: %s\n"), dest, Fstrerror(tfd));
|
||||
#ifdef DYING
|
||||
if (tfd)
|
||||
Fclose(tfd);
|
||||
if (sfd)
|
||||
Fclose(sfd);
|
||||
return FTPERR_UNKNOWN;
|
||||
#else
|
||||
rc = FTPERR_UNKNOWN;
|
||||
goto exit;
|
||||
#endif
|
||||
}
|
||||
|
||||
switch (urlType) {
|
||||
|
|
589
po/pt_BR.po
589
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
623
po/rpm.pot
623
po/rpm.pot
File diff suppressed because it is too large
Load Diff
16
rpm.c
16
rpm.c
|
@ -100,6 +100,8 @@ extern const char * rpmNAME;
|
|||
extern const char * rpmEVR;
|
||||
extern int rpmFLAGS;
|
||||
|
||||
extern MacroContext rpmCLIMacroContext;
|
||||
|
||||
static struct rpmQVArguments rpmQVArgs;
|
||||
static struct rpmBuildArguments rpmBArgs;
|
||||
|
||||
|
@ -834,12 +836,14 @@ int main(int argc, const char ** argv)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
addMacro(NULL,"_dbpath", NULL, optArg, RMIL_CMDLINE);
|
||||
addMacro(NULL, "_dbpath", NULL, optArg, RMIL_CMDLINE);
|
||||
addMacro(&rpmCLIMacroContext, "_dbpath", NULL, optArg, RMIL_CMDLINE);
|
||||
gotDbpath = 1;
|
||||
break;
|
||||
|
||||
case GETOPT_DEFINEMACRO:
|
||||
rpmDefineMacro(NULL, optArg, RMIL_CMDLINE);
|
||||
rpmDefineMacro(&rpmCLIMacroContext, optArg, RMIL_CMDLINE);
|
||||
break;
|
||||
|
||||
case GETOPT_EVALMACRO:
|
||||
|
@ -855,6 +859,7 @@ int main(int argc, const char ** argv)
|
|||
argerror("Argument to --timecheck must be integer");
|
||||
}
|
||||
addMacro(NULL, "_timecheck", NULL, optArg, RMIL_CMDLINE);
|
||||
addMacro(&rpmCLIMacroContext, "_timecheck", NULL, optArg, RMIL_CMDLINE);
|
||||
timeCheck = 1;
|
||||
break;
|
||||
|
||||
|
@ -1090,15 +1095,19 @@ int main(int argc, const char ** argv)
|
|||
|
||||
if (ftpProxy) {
|
||||
addMacro(NULL, "_ftpproxy", NULL, ftpProxy, RMIL_CMDLINE);
|
||||
addMacro(&rpmCLIMacroContext, "_ftpproxy", NULL, ftpProxy, RMIL_CMDLINE);
|
||||
}
|
||||
if (ftpPort) {
|
||||
addMacro(NULL, "_ftpport", NULL, ftpPort, RMIL_CMDLINE);
|
||||
addMacro(&rpmCLIMacroContext, "_ftpport", NULL, ftpPort, RMIL_CMDLINE);
|
||||
}
|
||||
if (httpProxy) {
|
||||
addMacro(NULL, "_httpproxy", NULL, httpProxy, RMIL_CMDLINE);
|
||||
addMacro(&rpmCLIMacroContext, "_httpproxy", NULL, httpProxy, RMIL_CMDLINE);
|
||||
}
|
||||
if (httpPort) {
|
||||
addMacro(NULL, "_httpport", NULL, httpPort, RMIL_CMDLINE);
|
||||
addMacro(&rpmCLIMacroContext, "_httpport", NULL, httpPort, RMIL_CMDLINE);
|
||||
}
|
||||
|
||||
if (signIt) {
|
||||
|
@ -1291,7 +1300,7 @@ int main(int argc, const char ** argv)
|
|||
NULL, rcfile, force, noDeps);
|
||||
if (ec)
|
||||
break;
|
||||
freeMacros(NULL); /* XXX macros from CLI are destroyed too */
|
||||
rpmFreeMacros(NULL);
|
||||
rpmReadConfigFiles(rcfile, NULL);
|
||||
}
|
||||
break;
|
||||
|
@ -1405,7 +1414,8 @@ int main(int argc, const char ** argv)
|
|||
}
|
||||
|
||||
poptFreeContext(optCon);
|
||||
freeMacros(NULL);
|
||||
rpmFreeMacros(NULL);
|
||||
rpmFreeMacros(&rpmCLIMacroContext);
|
||||
rpmFreeRpmrc();
|
||||
|
||||
if (pipeChild) {
|
||||
|
|
2
rpm.spec
2
rpm.spec
|
@ -2,7 +2,7 @@ Summary: The Red Hat package management system.
|
|||
Name: rpm
|
||||
%define version 3.0.4
|
||||
Version: %{version}
|
||||
Release: 0.12
|
||||
Release: 0.13
|
||||
Group: System Environment/Base
|
||||
Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-3.0.x/rpm-%{version}.tar.gz
|
||||
Copyright: GPL
|
||||
|
|
|
@ -31,7 +31,7 @@ static int _debug = 0;
|
|||
#define urlPath(_xr, _r) *(_r) = (_xr)
|
||||
|
||||
typedef FILE * FD_t;
|
||||
#define Fopen(_path, _fmode) fopen(_path, "_r");
|
||||
#define Fopen(_path, _fmode) fopen(_path, "r");
|
||||
#define Ferror ferror
|
||||
#define Fstrerror(_fd) strerror(errno)
|
||||
#define Fread fread
|
||||
|
@ -47,7 +47,8 @@ typedef FILE * FD_t;
|
|||
|
||||
#include <rpmmacro.h>
|
||||
|
||||
struct MacroContext globalMacroContext;
|
||||
struct MacroContext rpmGlobalMacroContext;
|
||||
struct MacroContext rpmCLIMacroContext;
|
||||
|
||||
typedef struct MacroBuf {
|
||||
const char *s; /* text to expand */
|
||||
|
@ -85,15 +86,12 @@ compareMacroName(const void *ap, const void *bp)
|
|||
MacroEntry *ame = *((MacroEntry **)ap);
|
||||
MacroEntry *bme = *((MacroEntry **)bp);
|
||||
|
||||
if (ame == NULL && bme == NULL) {
|
||||
if (ame == NULL && bme == NULL)
|
||||
return 0;
|
||||
}
|
||||
if (ame == NULL) {
|
||||
if (ame == NULL)
|
||||
return 1;
|
||||
}
|
||||
if (bme == NULL) {
|
||||
if (bme == NULL)
|
||||
return -1;
|
||||
}
|
||||
return strcmp(ame->name, bme->name);
|
||||
}
|
||||
|
||||
|
@ -132,14 +130,14 @@ sortMacroTable(MacroContext *mc)
|
|||
}
|
||||
|
||||
void
|
||||
dumpMacroTable(MacroContext * mc, FILE * fp)
|
||||
rpmDumpMacroTable(MacroContext * mc, FILE * fp)
|
||||
{
|
||||
int i;
|
||||
int nempty = 0;
|
||||
int nactive = 0;
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &globalMacroContext;
|
||||
mc = &rpmGlobalMacroContext;
|
||||
if (fp == NULL)
|
||||
fp = stderr;
|
||||
|
||||
|
@ -171,7 +169,7 @@ findEntry(MacroContext *mc, const char *name, size_t namelen)
|
|||
char namebuf[1024];
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &globalMacroContext;
|
||||
mc = &rpmGlobalMacroContext;
|
||||
if (! mc->firstFree)
|
||||
return NULL;
|
||||
|
||||
|
@ -1061,7 +1059,7 @@ expandMacro(MacroBuf *mb)
|
|||
}
|
||||
|
||||
if (STREQ("dump", f, fn)) {
|
||||
dumpMacroTable(mb->mc, NULL);
|
||||
rpmDumpMacroTable(mb->mc, NULL);
|
||||
while (iseol(*se))
|
||||
se++;
|
||||
s = se;
|
||||
|
@ -1201,7 +1199,7 @@ expandMacros(void *spec, MacroContext *mc, char *s, size_t slen)
|
|||
if (s == NULL || slen <= 0)
|
||||
return 0;
|
||||
if (mc == NULL)
|
||||
mc = &globalMacroContext;
|
||||
mc = &rpmGlobalMacroContext;
|
||||
|
||||
tbuf = alloca(slen + 1);
|
||||
memset(tbuf, 0, (slen + 1));
|
||||
|
@ -1233,7 +1231,7 @@ addMacro(MacroContext *mc, const char *n, const char *o, const char *b, int leve
|
|||
MacroEntry **mep;
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &globalMacroContext;
|
||||
mc = &rpmGlobalMacroContext;
|
||||
|
||||
/* If new name, expand macro table */
|
||||
if ((mep = findEntry(mc, n, 0)) == NULL) {
|
||||
|
@ -1256,7 +1254,7 @@ delMacro(MacroContext *mc, const char *n)
|
|||
MacroEntry **mep;
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &globalMacroContext;
|
||||
mc = &rpmGlobalMacroContext;
|
||||
/* If name exists, pop entry */
|
||||
if ((mep = findEntry(mc, n, 0)) != NULL) {
|
||||
popMacro(mep);
|
||||
|
@ -1272,20 +1270,40 @@ rpmDefineMacro(MacroContext *mc, const char *macro, int level)
|
|||
MacroBuf macrobuf, *mb = ¯obuf;
|
||||
|
||||
/* XXX just enough to get by */
|
||||
mb->mc = (mc ? mc : &globalMacroContext);
|
||||
mb->mc = (mc ? mc : &rpmGlobalMacroContext);
|
||||
(void)doDefine(mb, macro, level, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Load a macro context into rpmGlobalMacroContext */
|
||||
void
|
||||
initMacros(MacroContext *mc, const char *macrofiles)
|
||||
rpmLoadMacros(MacroContext * mc, int level)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (mc == NULL || mc == &rpmGlobalMacroContext)
|
||||
return;
|
||||
|
||||
for (i = 0; i < mc->firstFree; i++) {
|
||||
MacroEntry **mep, *me;
|
||||
mep = &mc->macroTable[i];
|
||||
me = *mep;
|
||||
|
||||
if (me == NULL) /* XXX this should never happen */
|
||||
continue;
|
||||
addMacro(NULL, me->name, me->opts, me->body, (level - 1));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rpmInitMacros(MacroContext *mc, const char *macrofiles)
|
||||
{
|
||||
char *m, *mfile, *me;
|
||||
|
||||
if (macrofiles == NULL)
|
||||
return;
|
||||
if (mc == NULL)
|
||||
mc = &globalMacroContext;
|
||||
mc = &rpmGlobalMacroContext;
|
||||
|
||||
for (mfile = m = xstrdup(macrofiles); *mfile; mfile = me) {
|
||||
FD_t fd;
|
||||
|
@ -1315,8 +1333,10 @@ initMacros(MacroContext *mc, const char *macrofiles)
|
|||
buf[sizeof(buf)-1] = '\0';
|
||||
|
||||
fd = Fopen(buf, "r.fpio");
|
||||
if (fd == NULL || Ferror(fd))
|
||||
if (fd == NULL || Ferror(fd)) {
|
||||
if (fd) Fclose(fd);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* XXX Assume new fangled macro expansion */
|
||||
max_macro_depth = 16;
|
||||
|
@ -1336,15 +1356,18 @@ initMacros(MacroContext *mc, const char *macrofiles)
|
|||
}
|
||||
if (m)
|
||||
free(m);
|
||||
|
||||
/* Reload cmdline macros */
|
||||
rpmLoadMacros(&rpmCLIMacroContext, RMIL_CMDLINE);
|
||||
}
|
||||
|
||||
void
|
||||
freeMacros(MacroContext *mc)
|
||||
rpmFreeMacros(MacroContext *mc)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &globalMacroContext;
|
||||
mc = &rpmGlobalMacroContext;
|
||||
|
||||
for (i = 0; i < mc->firstFree; i++) {
|
||||
MacroEntry *me;
|
||||
|
@ -1375,6 +1398,7 @@ int isCompressed(const char *file, int *compressed)
|
|||
if (fd == NULL || Ferror(fd)) {
|
||||
/* XXX Fstrerror */
|
||||
rpmError(RPMERR_BADSPEC, _("File %s: %s"), file, Fstrerror(fd));
|
||||
if (fd) Fclose(fd);
|
||||
return 1;
|
||||
}
|
||||
nb = Fread(magic, sizeof(char), sizeof(magic), fd);
|
||||
|
@ -1651,7 +1675,7 @@ main(int argc, char *argv[])
|
|||
exit(1);
|
||||
}
|
||||
|
||||
initMacros(NULL, macrofiles);
|
||||
rpmInitMacros(NULL, macrofiles);
|
||||
for ( ; optind < argc; optind++) {
|
||||
const char *val;
|
||||
|
||||
|
@ -1661,6 +1685,7 @@ main(int argc, char *argv[])
|
|||
xfree(val);
|
||||
}
|
||||
}
|
||||
rpmFreeMacros(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1676,8 +1701,8 @@ main(int argc, char *argv[])
|
|||
FILE *fp;
|
||||
int x;
|
||||
|
||||
initMacros(NULL, macrofiles);
|
||||
dumpMacroTable(NULL, NULL);
|
||||
rpmInitMacros(NULL, macrofiles);
|
||||
rpmDumpMacroTable(NULL, NULL);
|
||||
|
||||
if ((fp = fopen(testfile, "r")) != NULL) {
|
||||
while(rdcl(buf, sizeof(buf), fp, 1)) {
|
||||
|
@ -1693,6 +1718,7 @@ main(int argc, char *argv[])
|
|||
fprintf(stderr, "%d->%s\n <-\n", x, buf);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
}
|
||||
rpmFreeMacros(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ typedef /*@abstract@*/ struct MacroContext {
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void dumpMacroTable (MacroContext * mc, FILE * fp);
|
||||
void rpmDumpMacroTable (MacroContext * mc, FILE * fp);
|
||||
|
||||
/* XXX this is used only in build/expression.c and will go away. */
|
||||
const char *getMacroBody (MacroContext *mc, const char *name);
|
||||
|
@ -45,8 +45,9 @@ void addMacro (MacroContext * mc, const char * n, const char * o,
|
|||
void delMacro (MacroContext * mc, const char * n);
|
||||
|
||||
int rpmDefineMacro (MacroContext * mc, const char * macro, int level);
|
||||
void initMacros (MacroContext * mc, const char * macrofile);
|
||||
void freeMacros (MacroContext * mc);
|
||||
void rpmLoadMacros (MacroContext *mc, int level);
|
||||
void rpmInitMacros (MacroContext * mc, const char * macrofiles);
|
||||
void rpmFreeMacros (MacroContext * mc);
|
||||
|
||||
#define COMPRESSED_NOT 0
|
||||
#define COMPRESSED_OTHER 1
|
||||
|
|
Loading…
Reference in New Issue