[Rpm-maint] [rpm-software-management/rpm] Warn if a text is after %else or %endif (#625)

Panu Matilainen notifications at github.com
Fri Feb 8 13:17:00 UTC 2019


>  %lua_requires \\
%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7 \\
Requires: lua(abi) = %{lua_version} \\
%else \\
Requires: lua >= %{lua_version} \\
Requires: lua < %{lua: os.setlocale('C'); print(string.sub(_VERSION, 5) + 0.1)} \\
%endif \\
%{nil}

That %if-%else-%endif in a macro body is just arbitrary literal text to the macro engine. There's nothing wrong with this kind of use as such, it's just that such a macro is only useful inside a spec.



>>    I'm thinking the only sane interpretation would be that only the opening %if can appear from a macro expanded on that line.

> Please can you explain why? In this case there is still a problem with detecting %else and %endif lines too? What %if's that are expanded from an already expanded macro?

I'm not sure what you mean. The point is to put limits to this insanity. The above %lua_requires macro is perfectly fine, but this is not:
>  %lua_requires_if \\
%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7 \\
Requires: lua(abi) = %{lua_version} 
>
>%lua_requires_else\\
%else \\
Requires: lua >= %{lua_version} \\
Requires: lua < %{lua: os.setlocale('C'); print(string.sub(_VERSION, 5) + 0.1)} \\
%endif \\
%{nil}

...because obviously, you cannot detect the %else before expanding a line that should not be expanded. Does that make it clearer?

-- 
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/pull/625#issuecomment-461799446
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20190208/580006b5/attachment.html>


More information about the Rpm-maint mailing list