View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0017664||CentOS-8||rpm||public||2020-08-11 16:11||2020-08-11 16:11|
|Summary||0017664: rpmbuild mishandles macros with names that match header tags|
|Description||rpmbuild mishandles macros |
- with all-lowercase names,
- whose expansions start with a word that is a case-insensitive match to their names,
- when the expansion serves as a spec header or an initial part of one (hence the macro name must also be a header tag),
- but only if the macro is expanded more than once.
Such macros expand to empty strings.
|Steps To Reproduce||1. Ensure rpmbuild is installed.|
2. Execute the following two commands:
cat >example.spec <<'EOF'
%global recommends Recommends
Summary: Example spec for mishandled macro expansion
License: public domain
An example demonstrating a macro whose expansion starts with a
word that is a case-insensitive match to its name.
* Tue Aug 11 2020 John Bollinger <John.Bollinger@devnull.net> - 0.1-1
- Initial spec
rpmbuild -bp example.spec
The output is:
error: line 10: Unknown tag: x: y
, which seems to indicate that the %recommends macro is expanding to an empty string.
|Additional Information||I ran into this when attempting to apply macros to the problem of writing spec files that declare weak dependencies in rpm versions that support it, such as that of CentOS 8, but declare the same dependencies as strong ones in rpm versions that do not support weak dependencies, such as that of CentOS 7. It seemed natural to name a macro serving that purpose "recommends", and that worked fine on CentOS 7 where I had it expanding to a "Requires:" header. When I tested the same spec on CentOS 8, however, it failed in the same manner as does the example above.|
A viable workaround is to choose a different macro name. Although case variations in the matching part of the macro expansion do not seem to make a difference, a case change in the macro name seems to be enough to avoid the issue.