diff --git a/build/files.c b/build/files.c index d6193ea8a0..fca1dd5660 100644 --- a/build/files.c +++ b/build/files.c @@ -2026,7 +2026,7 @@ static rpmRC readFilesManifest(rpmSpec spec, Package pkg, const char *path) } /* XXX unmask %license while parsing files manifest*/ - addMacro(spec->macros, "license", NULL, "%%license", RMIL_SPEC); + rpmPushMacro(spec->macros, "license", NULL, "%%license", RMIL_SPEC); while (fgets(buf, sizeof(buf), fd)) { if (handleComments(buf)) @@ -2055,7 +2055,7 @@ static rpmRC readFilesManifest(rpmSpec spec, Package pkg, const char *path) rc = RPMRC_OK; exit: - delMacro(NULL, "license"); + rpmPopMacro(NULL, "license"); if (fd) fclose(fd); free(fn); return rc; diff --git a/build/parseFiles.c b/build/parseFiles.c index 58d5b65a54..f0a607a285 100644 --- a/build/parseFiles.c +++ b/build/parseFiles.c @@ -27,7 +27,7 @@ int parseFiles(rpmSpec spec) }; /* XXX unmask %license while parsing %files */ - addMacro(spec->macros, "license", NULL, "%%license", RMIL_SPEC); + rpmPushMacro(spec->macros, "license", NULL, "%%license", RMIL_SPEC); if ((rc = poptParseArgvString(spec->line, &argc, &argv))) { rpmlog(RPMLOG_ERR, _("line %d: Error parsing %%files: %s\n"), @@ -106,7 +106,7 @@ int parseFiles(rpmSpec spec) res = nextPart; exit: - delMacro(NULL, "license"); + rpmPopMacro(NULL, "license"); free(argv); poptFreeContext(optCon); diff --git a/build/parsePreamble.c b/build/parsePreamble.c index ed15b4726a..3355a3591a 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -301,11 +301,11 @@ static int addSource(rpmSpec spec, Package pkg, const char *field, rpmTagVal tag rasprintf(&buf, "%s%d", (flag & RPMBUILD_ISPATCH) ? "PATCH" : "SOURCE", num); - addMacro(spec->macros, buf, NULL, body, RMIL_SPEC); + rpmPushMacro(spec->macros, buf, NULL, body, RMIL_SPEC); free(buf); rasprintf(&buf, "%sURL%d", (flag & RPMBUILD_ISPATCH) ? "PATCH" : "SOURCE", num); - addMacro(spec->macros, buf, NULL, p->fullSource, RMIL_SPEC); + rpmPushMacro(spec->macros, buf, NULL, p->fullSource, RMIL_SPEC); free(buf); #ifdef WITH_LUA { @@ -801,8 +801,8 @@ static rpmRC handlePreambleTag(rpmSpec spec, Package pkg, rpmTagVal tag, goto exit; } macro = NULL; - delMacro(NULL, "_docdir"); - addMacro(NULL, "_docdir", NULL, field, RMIL_SPEC); + rpmPopMacro(NULL, "_docdir"); + rpmPushMacro(NULL, "_docdir", NULL, field, RMIL_SPEC); break; case RPMTAG_EPOCH: { SINGLE_TOKEN_ONLY; @@ -917,7 +917,7 @@ static rpmRC handlePreambleTag(rpmSpec spec, Package pkg, rpmTagVal tag, } if (macro) - addMacro(spec->macros, macro, NULL, field, RMIL_SPEC); + rpmPushMacro(spec->macros, macro, NULL, field, RMIL_SPEC); rc = RPMRC_OK; exit: return rc; @@ -1155,7 +1155,7 @@ int parsePreamble(rpmSpec spec, int initialPackage) } free(spec->buildRoot); spec->buildRoot = buildRoot; - addMacro(spec->macros, "buildroot", NULL, spec->buildRoot, RMIL_SPEC); + rpmPushMacro(spec->macros, "buildroot", NULL, spec->buildRoot, RMIL_SPEC); } /* XXX Skip valid arch check if not building binary package */ diff --git a/build/parsePrep.c b/build/parsePrep.c index b70aee249f..182056ffc2 100644 --- a/build/parsePrep.c +++ b/build/parsePrep.c @@ -339,7 +339,7 @@ static int doSetupMacro(rpmSpec spec, const char *line) buildInPlace = 1; spec->buildSubdir = NULL; } - addMacro(spec->macros, "buildsubdir", NULL, spec->buildSubdir, RMIL_SPEC); + rpmPushMacro(spec->macros, "buildsubdir", NULL, spec->buildSubdir, RMIL_SPEC); if (buildInPlace) { rc = RPMRC_OK; goto exit; diff --git a/build/parseSpec.c b/build/parseSpec.c index 28f00bc18e..16d41ef36d 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -781,8 +781,8 @@ static rpmSpec parseSpec(const char *specFile, rpmSpecFlags flags, } else { spec->buildRoot = rpmGetPath("%{?buildroot:%{buildroot}}", NULL); } - addMacro(NULL, "_docdir", NULL, "%{_defaultdocdir}", RMIL_SPEC); - addMacro(NULL, "_licensedir", NULL, "%{_defaultlicensedir}", RMIL_SPEC); + rpmPushMacro(NULL, "_docdir", NULL, "%{_defaultdocdir}", RMIL_SPEC); + rpmPushMacro(NULL, "_licensedir", NULL, "%{_defaultlicensedir}", RMIL_SPEC); spec->recursing = recursing; spec->flags = flags; @@ -874,13 +874,13 @@ static rpmSpec parseSpec(const char *specFile, rpmSpecFlags flags, /* Skip if not arch is not compatible. */ if (!rpmMachineScore(RPM_MACHTABLE_BUILDARCH, spec->BANames[x])) continue; - addMacro(NULL, "_target_cpu", NULL, spec->BANames[x], RMIL_RPMRC); + rpmPushMacro(NULL, "_target_cpu", NULL, spec->BANames[x], RMIL_RPMRC); spec->BASpecs[index] = parseSpec(specFile, flags, buildRoot, 1); if (spec->BASpecs[index] == NULL) { spec->BACount = index; goto errxit; } - delMacro(NULL, "_target_cpu"); + rpmPopMacro(NULL, "_target_cpu"); index++; } diff --git a/lib/poptALL.c b/lib/poptALL.c index 6a8fd34c27..9cd4360f73 100644 --- a/lib/poptALL.c +++ b/lib/poptALL.c @@ -112,7 +112,7 @@ static void rpmcliAllArgCallback( poptContext con, rpmcliConfigured(); if (*arg == '%') arg++; - delMacro(NULL, arg); + rpmPopMacro(NULL, arg); break; case 'E': rpmcliConfigured(); @@ -123,7 +123,7 @@ static void rpmcliAllArgCallback( poptContext con, break; case POPT_DBPATH: rpmcliConfigured(); - addMacro(NULL, "_dbpath", NULL, arg, RMIL_CMDLINE); + rpmPushMacro(NULL, "_dbpath", NULL, arg, RMIL_CMDLINE); break; case POPT_SHOWVERSION: printVersion(stdout); diff --git a/lib/relocation.c b/lib/relocation.c index de5779b843..2a0c73118e 100644 --- a/lib/relocation.c +++ b/lib/relocation.c @@ -383,10 +383,10 @@ static void rpmInstallLoadMacros(Header h, int define) default: if (define) { body = rpmtdFormat(&td, RPMTD_FORMAT_STRING, NULL); - addMacro(NULL, tagm->macroname, NULL, body, -1); + rpmPushMacro(NULL, tagm->macroname, NULL, body, -1); free(body); } else { - delMacro(NULL, tagm->macroname); + rpmPopMacro(NULL, tagm->macroname); } break; case RPM_NULL_TYPE: diff --git a/lib/rpmrc.c b/lib/rpmrc.c index eb136d8170..7d67e6c465 100644 --- a/lib/rpmrc.c +++ b/lib/rpmrc.c @@ -585,7 +585,7 @@ static rpmRC doReadRC(rpmrcCtx ctx, const char * urlfn) if (option->localize) *n++ = '_'; strcpy(n, option->name); - addMacro(NULL, name, NULL, val, RMIL_RPMRC); + rpmPushMacro(NULL, name, NULL, val, RMIL_RPMRC); free(name); } rpmSetVarArch(ctx, option->var, val, arch); @@ -716,9 +716,9 @@ static rpmRC rpmPlatform(rpmrcCtx ctx, const char * platform) if (*p != '\0') *p = '\0'; } - addMacro(NULL, "_host_cpu", NULL, cpu, -1); - addMacro(NULL, "_host_vendor", NULL, vendor, -1); - addMacro(NULL, "_host_os", NULL, os, -1); + rpmPushMacro(NULL, "_host_cpu", NULL, cpu, -1); + rpmPushMacro(NULL, "_host_vendor", NULL, vendor, -1); + rpmPushMacro(NULL, "_host_os", NULL, os, -1); char *plat = rpmExpand("%{_host_cpu}-%{_host_vendor}-%{_host_os}", (gnu && *gnu ? "-" : NULL), gnu, NULL); @@ -1527,19 +1527,19 @@ static void rpmRebuildTargetVars(rpmrcCtx ctx, * XXX All this macro pokery/jiggery could be achieved by doing a delayed * rpmInitMacros(NULL, PER-PLATFORM-MACRO-FILE-NAMES); */ - delMacro(NULL, "_target"); - addMacro(NULL, "_target", NULL, ct, RMIL_RPMRC); - delMacro(NULL, "_target_cpu"); - addMacro(NULL, "_target_cpu", NULL, ca, RMIL_RPMRC); - delMacro(NULL, "_target_os"); - addMacro(NULL, "_target_os", NULL, co, RMIL_RPMRC); + rpmPopMacro(NULL, "_target"); + rpmPushMacro(NULL, "_target", NULL, ct, RMIL_RPMRC); + rpmPopMacro(NULL, "_target_cpu"); + rpmPushMacro(NULL, "_target_cpu", NULL, ca, RMIL_RPMRC); + rpmPopMacro(NULL, "_target_os"); + rpmPushMacro(NULL, "_target_os", NULL, co, RMIL_RPMRC); /* * XXX Make sure that per-arch optflags is initialized correctly. */ { const char *optflags = rpmGetVarArch(ctx, RPMVAR_OPTFLAGS, ca); if (optflags != NULL) { - delMacro(NULL, "optflags"); - addMacro(NULL, "optflags", NULL, optflags, RMIL_RPMRC); + rpmPopMacro(NULL, "optflags"); + rpmPushMacro(NULL, "optflags", NULL, optflags, RMIL_RPMRC); } } diff --git a/python/rpmmacro-py.c b/python/rpmmacro-py.c index 3eb0acb566..49b3535b24 100644 --- a/python/rpmmacro-py.c +++ b/python/rpmmacro-py.c @@ -14,7 +14,7 @@ rpmmacro_AddMacro(PyObject * self, PyObject * args, PyObject * kwds) &name, &val)) return NULL; - addMacro(NULL, name, NULL, val, -1); + rpmPushMacro(NULL, name, NULL, val, -1); Py_RETURN_NONE; } @@ -28,7 +28,7 @@ rpmmacro_DelMacro(PyObject * self, PyObject * args, PyObject * kwds) if (!PyArg_ParseTupleAndKeywords(args, kwds, "s:DelMacro", kwlist, &name)) return NULL; - delMacro(NULL, name); + rpmPopMacro(NULL, name); Py_RETURN_NONE; } diff --git a/python/rpmmodule.c b/python/rpmmodule.c index 933cb13541..24af222132 100644 --- a/python/rpmmodule.c +++ b/python/rpmmodule.c @@ -150,10 +150,10 @@ static PyObject * setInterruptSafety(PyObject * self, PyObject * args, PyObject static PyMethodDef rpmModuleMethods[] = { { "addMacro", (PyCFunction) rpmmacro_AddMacro, METH_VARARGS|METH_KEYWORDS, - "addMacro(macro, value)\n" + "rpmPushMacro(macro, value)\n" }, { "delMacro", (PyCFunction) rpmmacro_DelMacro, METH_VARARGS|METH_KEYWORDS, - "delMacro(macro)\n" + "rpmPopMacro(macro)\n" }, { "expandMacro", (PyCFunction) rpmmacro_ExpandMacro, METH_VARARGS|METH_KEYWORDS, "expandMacro(string, numeric=False) -- expands a string containing macros\n\n" diff --git a/python/spec-py.c b/python/spec-py.c index f710f5c872..cd5ad0f92e 100644 --- a/python/spec-py.c +++ b/python/spec-py.c @@ -19,7 +19,7 @@ * For example * \code * import rpm - * rpm.addMacro("_topdir","/path/to/topdir") + * rpm.rpmPushMacro("_topdir","/path/to/topdir") * s=rpm.spec("foo.spec") * print s.prep() * \endcode diff --git a/rpmbuild.c b/rpmbuild.c index 02d2655968..0f40df646e 100644 --- a/rpmbuild.c +++ b/rpmbuild.c @@ -429,7 +429,7 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba) /* Override default BUILD value for _builddir */ if (buildInPlace) { char *cwd = rpmGetCwd(); - addMacro(NULL, "_builddir", NULL, cwd, 0); + rpmPushMacro(NULL, "_builddir", NULL, cwd, 0); free(cwd); } @@ -459,7 +459,7 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba) dir = xstrdup(arg); } srcdir = dirname(dir); - addMacro(NULL, "_sourcedir", NULL, srcdir, RMIL_TARBALL); + rpmPushMacro(NULL, "_sourcedir", NULL, srcdir, RMIL_TARBALL); free(dir); } else { specFile = xstrdup(arg); diff --git a/rpmio/macro.c b/rpmio/macro.c index 1f33d48eec..9fe55bf3f8 100644 --- a/rpmio/macro.c +++ b/rpmio/macro.c @@ -1498,7 +1498,7 @@ rpmDumpMacroTable(rpmMacroContext mc, FILE * fp) rpmmctxRelease(mc); } -void addMacro(rpmMacroContext mc, +void rpmPushMacro(rpmMacroContext mc, const char * n, const char * o, const char * b, int level) { mc = rpmmctxAcquire(mc); @@ -1506,7 +1506,7 @@ void addMacro(rpmMacroContext mc, rpmmctxRelease(mc); } -void delMacro(rpmMacroContext mc, const char * n) +void rpmPopMacro(rpmMacroContext mc, const char * n) { mc = rpmmctxAcquire(mc); popMacro(mc, n); diff --git a/rpmio/rpmmacro.h b/rpmio/rpmmacro.h index 1444c3c7d4..b0900eb35b 100644 --- a/rpmio/rpmmacro.h +++ b/rpmio/rpmmacro.h @@ -45,6 +45,10 @@ extern const char * macrofiles; #define RMIL_OLDSPEC -1 #define RMIL_GLOBAL 0 +/* Deprecated compatibility wrappers */ +#define addMacro(_mc, _n, _o, _b, _l) rpmPushMacro(_mc, _n, _o, _b, _l) +#define delMacro(_mc, _n) rpmPopMacro(_mc, _n) + /** \ingroup rpmmacro * Print macros to file stream. * @param mc macro context (NULL uses global context). @@ -65,24 +69,23 @@ int rpmExpandMacros (rpmMacroContext mc, const char * sbuf, char ** obuf, int flags); /** \ingroup rpmmacro - * Add macro to context. - * @deprecated Use rpmDefineMacro(). + * Push macro to context. * @param mc macro context (NULL uses global context). * @param n macro name * @param o macro paramaters * @param b macro body * @param level macro recursion level (0 is entry API) */ -void addMacro (rpmMacroContext mc, const char * n, +void rpmPushMacro (rpmMacroContext mc, const char * n, const char * o, const char * b, int level); /** \ingroup rpmmacro - * Delete macro from context. + * Pop macro from context. * @param mc macro context (NULL uses global context). * @param n macro name */ -void delMacro (rpmMacroContext mc, const char * n); +void rpmPopMacro (rpmMacroContext mc, const char * n); /** \ingroup rpmmacro * Define macro in context. diff --git a/rpmsign.c b/rpmsign.c index ddbc5c5806..b48cfa8887 100644 --- a/rpmsign.c +++ b/rpmsign.c @@ -68,7 +68,7 @@ static int doSign(poptContext optCon) } if (fileSigningKey) { - addMacro(NULL, "_file_signing_key", NULL, fileSigningKey, RMIL_GLOBAL); + rpmPushMacro(NULL, "_file_signing_key", NULL, fileSigningKey, RMIL_GLOBAL); } if (signfiles) { @@ -86,7 +86,7 @@ static int doSign(poptContext optCon) #endif } - addMacro(NULL, "_file_signing_key_password", NULL, + rpmPushMacro(NULL, "_file_signing_key_password", NULL, fileSigningKeyPassword, RMIL_CMDLINE); if (fileSigningKeyPassword) { memset(fileSigningKeyPassword, 0, strlen(fileSigningKeyPassword)); diff --git a/sign/rpmgensig.c b/sign/rpmgensig.c index 1c4128f4c2..ae2f6cb99a 100644 --- a/sign/rpmgensig.c +++ b/sign/rpmgensig.c @@ -257,8 +257,8 @@ static int runGPG(sigTarget sigt, const char *sigfile) namedPipeName = mkTempFifo(); - addMacro(NULL, "__plaintext_filename", NULL, namedPipeName, -1); - addMacro(NULL, "__signature_filename", NULL, sigfile, -1); + rpmPushMacro(NULL, "__plaintext_filename", NULL, namedPipeName, -1); + rpmPushMacro(NULL, "__signature_filename", NULL, sigfile, -1); if (!(pid = fork())) { char *const *av; @@ -279,8 +279,8 @@ static int runGPG(sigTarget sigt, const char *sigfile) _exit(EXIT_FAILURE); } - delMacro(NULL, "__plaintext_filename"); - delMacro(NULL, "__signature_filename"); + rpmPopMacro(NULL, "__plaintext_filename"); + rpmPopMacro(NULL, "__signature_filename"); fnamedPipe = Fopen(namedPipeName, "w"); if (!fnamedPipe) { @@ -521,7 +521,7 @@ static rpmRC replaceSigDigests(FD_t fd, const char *rpm, Header *sigp, } /* Set reserved space to 0 */ - addMacro(NULL, "__gpg_reserved_space", NULL, 0, RMIL_GLOBAL); + rpmPushMacro(NULL, "__gpg_reserved_space", NULL, 0, RMIL_GLOBAL); /* Replace old digests in sigh */ rc = rpmGenerateSignature(SHA1, MD5, sigTargetSize, archiveSize, fd); @@ -872,11 +872,11 @@ int rpmPkgSign(const char *path, const struct rpmSignArgs * args) if (args->hashalgo) { char *algo = NULL; rasprintf(&algo, "%d", args->hashalgo); - addMacro(NULL, "_gpg_digest_algo", NULL, algo, RMIL_GLOBAL); + rpmPushMacro(NULL, "_gpg_digest_algo", NULL, algo, RMIL_GLOBAL); free(algo); } if (args->keyid) { - addMacro(NULL, "_gpg_name", NULL, args->keyid, RMIL_GLOBAL); + rpmPushMacro(NULL, "_gpg_name", NULL, args->keyid, RMIL_GLOBAL); } } @@ -884,10 +884,10 @@ int rpmPkgSign(const char *path, const struct rpmSignArgs * args) if (args) { if (args->hashalgo) { - delMacro(NULL, "_gpg_digest_algo"); + rpmPopMacro(NULL, "_gpg_digest_algo"); } if (args->keyid) { - delMacro(NULL, "_gpg_name"); + rpmPopMacro(NULL, "_gpg_name"); } }