summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2017-03-07 14:08:27 +0200
committerPanu Matilainen <pmatilai@redhat.com>2017-03-07 14:26:45 +0200
commit5adc56897b9da5dac49701f704ef54390db57c59 (patch)
tree8c97236db17a8a4827e36478d6dee15208042dbd
parent307627993ec0c3eed729aea34843a87aa5bde6d2 (diff)
downloadrpm-5adc56897b9da5dac49701f704ef54390db57c59.tar.gz
Expand parametric macro arguments before processing (#127, RhBug:1397209)
This too is quite a fundamental change for macros: up to now, arguments to parametric macros have not been expanded. It doesn't sound so bad until you consider something like the case in RhBug:1397209: %global rev 133 ... %setup %{?rev:-c} %autosetup %{?rev:-c} One would expect %setup and %autosetup behave the same when you replace one with the other, but no. %setup gets "called" with -c, %autosetup does not. Instead %autosetup receives a completely useless, literal "%{?rev:-c}" as its argument. That's just brain-meltingly non-sensical. This certainly has the potential to break advanced macro constructs, but OTOH what breaks might well be only written that way in order to work around the former behavior. There are some funny subtleties involved as the argument expansion must occur in the callers scope, ie before we create any of the automatic macros. For example, Fedora's font packages break if only this or the macro scope visibility enforcement is applied but start working again once both are present.
-rw-r--r--rpmio/macro.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/rpmio/macro.c b/rpmio/macro.c
index 69f5c9d81..473d83eb7 100644
--- a/rpmio/macro.c
+++ b/rpmio/macro.c
@@ -675,9 +675,10 @@ grabArgs(MacroBuf mb, const rpmMacroEntry me, const char * se,
argvAdd(&argv, me->name);
if (lastc) {
ARGV_t av = NULL;
- char *s = xcalloc((lastc-se)+1, sizeof(*s));
- memcpy(s, se, (lastc-se));
+ char *s = NULL;
+ /* Expand possible macros in arguments */
+ expandThis(mb, se, lastc-se, &s);
argvSplit(&av, s, " \t");
argvAppend(&argv, av);