Problem with expansion of %* macro when using nested parameterized macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Michael,

On Tue, 2015-11-03 at 09:03 +0100, Michael Mraka wrote:
> ...
> 
> arguments starting with '-' are treated as macro options,
> you can workaround it by escaping the first '-' with backslash:
> 
> $ rpm --eval "%systemd_post \--user foo bar"
> 
> if [ $1 -eq 1 ] ; then 
>         # Initial installation 
>         systemctl preset \--user foo bar >/dev/null 2>&1 || : 
> fi
> 
> (Shell will interpret '\-' as '-'.)

thanks for helping me out! This works as you've written.

However, I now encountered another problem. This time the problem is
with the expansion of %* macro when using nested parameterized macros.

Again, let's take systemd macros as an example:
1) %systemd_post macro [1] is defined as:

%systemd_post() \
if [ $1 -eq 1 ] ; then \
        # Initial installation \
        systemctl preset %{?*} >/dev/null 2>&1 || : \
fi \
%{nil}

2) %systemd_user_post macro [2] is defined as:

%systemd_user_post() %systemd_post \\--user \\--global %{?*}

(NOTE: This is different that [2]. Here I properly escaped '--user' and
'--global' arguments with two backslashes.)

Using %systemd_user_post macro results in the following error:
[vagrant@localhost ~]$ rpm --eval '%systemd_user_post foo'
error: Too many levels of recursion in macro expansion. It is likely
caused by recursive macro declaration.

if [ $1 -eq 1 ] ; then 
        # Initial installation 
        systemctl preset \--user \--global \--user \--global \--user
\--global \--user \--global \--user \--global \--user \--global \--user
\--global \--user \--global \--user \--global \--user \--global \--user
\--global \--user \--global \--user \--global 

The problem is that rpm doesn't properly expand the '%{?*}' macro inside
the %systemd_user_post into 'foo'.
Instead, rpm passes it as the third argument to the %systemd_post macro,
where '%{?*}' is then recursively defined as:
\--user \--global {%?*}.

This obviously causes the recursive macro expansion error mentioned
before.

How can I fix the %systemd_user_post macro to properly expand the
'%{?*}' macro?

Thanks and best regards,
Tadej

[1]
https://github.com/systemd/systemd/blob/7c67f0f/src/core/macros.systemd.in#L39
[2]
https://github.com/systemd/systemd/blob/7c67f0f/src/core/macros.systemd.in#L46

_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list



[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux