[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 12:43:53 UTC 2021


>From the beginning, this was not about "file existence" but about the `load` builtin existence. The problem is that `load` is not available in RHEL 7 while it is available in RHEL8+. The whole #1669 went somehow sideways due to the expression remark and I am not sure why it popups here again.

Also, it is not true that the builtin behaves the same as other macros:

~~~
$ head -4 ruby.spec 
%{?foo}
%{?foo:}
%{?load}
%{?load:}

$ fedpkg srpm 
error: /home/vondruch/fedora-scm/own/ruby/ruby.spec: line 3: %load: argument expected

Could not execute srpm: Error running rpmspec on "/home/vondruch/fedora-scm/own/ruby/ruby.spec", return code 1
~~~

The case on line 4 fails similarly.

There are two problems:
1) For the builtins, the arguments are enforced while they are not enforced for macros. If the builtin existence could be checked just via `%{?load}`, maybe we would have nothing to talk about.
2) In case the `load` builtin, the behavior of `%{?load:foo}` is significantly different to `%{load:foo}`. For the first case, it is expanded to `foo`. For the later, the "foo" is consumed as an argument and the macro returns nothing.

Please note that the `load` can be replaced by e.g. `exists` or `getenv` and the issue stays the same. But of course, the difference is that `exists`/`getenv` will not be used on their own, but as a part of some expression, therefore it is not so obvious.

-- 
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#issuecomment-995782596
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20211216/efbdb068/attachment.html>


More information about the Rpm-maint mailing list