[Rpm-maint] [rpm-software-management/rpm] The behavior of `%{?builtin_macro:foo}` is unclear from documentation (Issue #1866)
Vít Ondruch
notifications at github.com
Thu Dec 16 10:09:48 UTC 2021
Based on #1864, I'd like the documentation to be clarified what does the `?` do with builtin macros. The documentation currently says:
> both macro “%{?builtin_macro:value}” and its negative version “%{?!builtin_macro:value}” are expanded exactly like the macro without exclamation mark and question mark “%{builtin_macro:value}”
Given how the other macros work, I'd expect that adding the `?` would just soften the behavior, so there would not be failure if the built in macro is not available. Or IOW, the behavior of `%{?builtin_macro:value} == %{builtin_macro:value}`. But it does something different. So lets try it on some random spec and add there the following line:
~~~
%{exists:%{SOURCE4}}
~~~
The `fedpkg srpm` fails with following error:
~~~
error: line 112: Unknown tag: 1
~~~
Ok, so the macro expands to `1`, so the `SOURCE4` file exists. So far so good.
Now lets try the question mark:
~~~
error: line 112: Unknown tag: /home/vondruch/fedora-scm/own/ruby/macros.ruby
~~~
Hm, so it expands the `SOURCE4` now, but it does not tell anything about functionality. So is the following the correct way to ensure the `exists` does not fail even when not available?
~~~
%{?exists:%{exists:%{SOURCE4}}}
~~~
This results in `error: line 112: Unknown tag: 1` so pretty similar to the initial version.
Nevertheless, I in any way, am not able to decipher this behavior from the initial description. In my opinion, the original descriptions should be modified to following:
~~~
The macro “%{?builtin_macro:value}” is expanded into "value" when the `builtin_macro` is available/implemented.
~~~
And I am quite unsure what is the result of `%{?!builtin_macro:value}`. For available builtins, this is probably no-op.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1866
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20211216/0049f7de/attachment.html>
More information about the Rpm-maint
mailing list