Red Hat Bugzilla – Bug 143874
Commented %define still %defines
Last modified: 2007-11-30 17:10:57 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5)
Description of problem:
A %define directive on a comment line still %defines the symbol. If
the commented line appears after a live %define directive, the
commented definition replaces the live one.
Commented lines should have no effect.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Install the attached foo.spec file in SOURCES.
2. rpmbuild -bp foo.spec
Actual Results: Output echoes "bazz" on screen.
Expected Results: Output echoes "bar" on screen.
foo.spec file attached below.
Note the lines:
%define foo bar
# %define foo bazz
The latter %define overrides the former, even though it is commented out.
Created attachment 109189 [details]
RPM spec file exhibiting how commented %defines are still live.
Build this package (foo-0.0) with "rpmbuild -bp foo.spec". The output echoes
"bazz" when it should echo "bar".
This is a known limitation of the spec parser, macros are expanded everywhere -
comments, changelog etc. Common packager approaches are to either add a % to
escape or replace the % with the #
#%%define foo bazz
#define foo bazz
OK fine, but this needs to be documented in big red letters in places that
specfile authors are likely to see it (appropriate sections of the HOWTO and
Maximum RPM, at least). For anyone used to most common programming languages,
shell languages, makefile syntax, etc., this is totally unexpected behavior.
In the Maximum RPM snapshot
the following appears:
Comments are a way to make RPM ignore a line in the spec file. The contents of a
comment line are entirely up to the person writing the spec file.
To create a comment, enter an octothorp (#) at the start of the line. Any text
following the comment character will be ignored by RPM.
The same appears in Appendix E
I have not encountered any reference to expansion of macros in comments anywhere
For speedy update patches against maximum rpm happily taken and the snapshot
will be updated. CVS details here, feel free to attach here or post to rpm-list:
OK Will post here or there when I have a chance to write the patches.