View Issue Details

IDProjectCategoryView StatusLast Update
0017664CentOS-8rpmpublic2020-08-11 16:11
Reporterjcbollinger 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version8.2.2004 
Target VersionFixed in Version 
Summary0017664: rpmbuild mishandles macros with names that match header tags
Descriptionrpmbuild 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 Reproduce1. Ensure rpmbuild is installed.

2. Execute the following two commands:

cat >example.spec <<'EOF'
%global recommends Recommends

Name: example
Version: 0.1
Release: 1
Summary: Example spec for mishandled macro expansion
License: public domain

%{recommends}: x
%{recommends}: y

%description
An example demonstrating a macro whose expansion starts with a
word that is a case-insensitive match to its name.

%files
# none

%changelog
* Tue Aug 11 2020 John Bollinger <John.Bollinger@devnull.net> - 0.1-1
- Initial spec
EOF

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 InformationI 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.
Tagsrpmbuild

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2020-08-11 16:11 jcbollinger New Issue
2020-08-11 16:11 jcbollinger Tag Attached: rpmbuild