rpm/rpm-4.12.0-unlimited-macro-...

118 lines
3.9 KiB
Diff

diff -up rpm-4.12.0.1/build/files.c.umacros rpm-4.12.0.1/build/files.c
--- rpm-4.12.0.1/build/files.c.umacros 2014-06-30 10:47:13.928503700 +0200
+++ rpm-4.12.0.1/build/files.c 2016-02-29 14:28:40.949514813 +0100
@@ -1590,6 +1590,7 @@ static rpmRC readFilesManifest(rpmSpec s
FILE *fd = NULL;
rpmRC rc = RPMRC_FAIL;
unsigned int nlines = 0;
+ char *expanded;
if (*path == '/') {
fn = rpmGetPath(path, NULL);
@@ -1607,11 +1608,12 @@ static rpmRC readFilesManifest(rpmSpec s
while (fgets(buf, sizeof(buf), fd)) {
if (handleComments(buf))
continue;
- if (expandMacros(spec, spec->macros, buf, sizeof(buf))) {
+ if(rpmExpandMacros(spec->macros, buf, &expanded, 0) < 0) {
rpmlog(RPMLOG_ERR, _("line: %s\n"), buf);
goto exit;
}
- argvAdd(&(pkg->fileList), buf);
+ argvAdd(&(pkg->fileList), expanded);
+ free(expanded);
nlines++;
}
diff -up rpm-4.12.0.1/build/pack.c.umacros rpm-4.12.0.1/build/pack.c
--- rpm-4.12.0.1/build/pack.c.umacros 2016-02-29 14:28:30.001660705 +0100
+++ rpm-4.12.0.1/build/pack.c 2016-02-29 14:28:40.950514800 +0100
@@ -132,11 +132,13 @@ static rpmRC addFileToTag(rpmSpec spec,
}
while (fgets(buf, sizeof(buf), f)) {
- if (expandMacros(spec, spec->macros, buf, sizeof(buf))) {
+ char *expanded;
+ if(rpmExpandMacros(spec->macros, buf, &expanded, 0) < 0) {
rpmlog(RPMLOG_ERR, _("%s: line: %s\n"), fn, buf);
goto exit;
}
- appendStringBuf(sb, buf);
+ appendStringBuf(sb, expanded);
+ free(expanded);
}
headerPutString(h, tag, getStringBuf(sb));
rc = RPMRC_OK;
diff -up rpm-4.12.0.1/build/parseSpec.c.umacros rpm-4.12.0.1/build/parseSpec.c
--- rpm-4.12.0.1/build/parseSpec.c.umacros 2014-09-15 09:17:36.378270111 +0200
+++ rpm-4.12.0.1/build/parseSpec.c 2016-02-29 14:32:05.618787380 +0100
@@ -207,11 +207,16 @@ static int copyNextLineFromOFI(rpmSpec s
spec->lbufOff = 0;
/* Don't expand macros (eg. %define) in false branch of %if clause */
- if (spec->readStack->reading &&
- expandMacros(spec, spec->macros, spec->lbuf, spec->lbufSize)) {
+ if (spec->readStack->reading) {
+ char *expanded;
+ if (rpmExpandMacros(spec->macros, spec->lbuf, &expanded, 0) < 0) {
rpmlog(RPMLOG_ERR, _("line %d: %s\n"),
spec->lineNum, spec->lbuf);
return -1;
+ }
+ free(spec->lbuf);
+ spec->lbuf = expanded;
+ spec->lbufSize = strlen(spec->lbuf) + 1;
}
spec->nextline = spec->lbuf;
}
diff -up rpm-4.12.0.1/rpmio/macro.c.umacros rpm-4.12.0.1/rpmio/macro.c
--- rpm-4.12.0.1/rpmio/macro.c.umacros 2014-07-01 11:07:07.070211597 +0200
+++ rpm-4.12.0.1/rpmio/macro.c 2016-02-29 14:28:40.951514786 +0100
@@ -1462,6 +1462,25 @@ int expandMacros(void * spec, rpmMacroCo
return rc;
}
+
+int rpmExpandMacros(rpmMacroContext mc, const char * sbuf, char ** obuf, int flags)
+{
+ char *target = NULL;
+ int rc;
+
+ mc = rpmmctxAcquire(mc);
+ rc = doExpandMacros(mc, sbuf, &target);
+ rpmmctxRelease(mc);
+
+ if (rc) {
+ free(target);
+ return -1;
+ } else {
+ *obuf = target;
+ return 1;
+ }
+}
+
void
rpmDumpMacroTable(rpmMacroContext mc, FILE * fp)
{
diff -up rpm-4.12.0.1/rpmio/rpmmacro.h.umacros rpm-4.12.0.1/rpmio/rpmmacro.h
--- rpm-4.12.0.1/rpmio/rpmmacro.h.umacros 2014-06-30 10:47:14.105503272 +0200
+++ rpm-4.12.0.1/rpmio/rpmmacro.h 2016-02-29 14:28:40.952514773 +0100
@@ -66,6 +66,17 @@ int expandMacros (void * spec, rpmMacroC
size_t slen);
/** \ingroup rpmmacro
+ * Expand macro into buffer.
+ * @param mc macro context (NULL uses global context).
+ * @param sbuf input macro to expand
+ * @param obuf macro expansion (malloc'ed)
+ * @param flags flags (currently unused)
+ * @return negative on failure
+ */
+int rpmExpandMacros (rpmMacroContext mc, const char * sbuf,
+ char ** obuf, int flags);
+
+/** \ingroup rpmmacro
* Add macro to context.
* @deprecated Use rpmDefineMacro().
* @param mc macro context (NULL uses global context).