Bug 1021628 - rpmbuild interprets lines which are commented out in spec files
rpmbuild interprets lines which are commented out in spec files
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: rpm (Show other bugs)
6.4
x86_64 Linux
unspecified Severity low
: rc
: ---
Assigned To: packaging-team-maint
BaseOS QE Security Team
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-21 12:48 EDT by Martin Hecht
Modified: 2013-10-22 04:38 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-10-22 02:50:03 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Martin Hecht 2013-10-21 12:48:05 EDT
Description of problem:
in spec files, lines starting with '#' should be treated as comments and have no influence on the build process. However, this is not always the case. 

Version-Release number of selected component (if applicable):
RPM-Version 4.8.0
RPM-Version 4.7.2
(probably others as well)

How reproducible:


Steps to Reproduce:
1. create a spec file test.spec:

# test.spec
%{!?version: %define version 1.0}
%{!?name: %define name test}
%{!?release: %define release 1.0}
# %define is_client nothing  # this line is commented out

%{!?is_client: %define is_client 1}

Summary: Test of the rpm build system
Name: %{name}
Version: %{version}
Release: %{release}
License: GPL
Provides: %{name} = %{version}

%description
Test of the rpm build system


%prep
echo "the value of is_client is --%{is_client}--"


2. run rpmbuild -ba test.spec


Actual results:

rpmbuild -ba /usr/src/rpmbuild/SPECS/test.spec 
Ausführung(%prep): /bin/sh -e /var/tmp/rpm-tmp.enFbre
+ umask 022
+ cd /usr/src/rpmbuild/BUILD
+ echo the value of is_client is --nothing  # this line is commented out--
the value of is_client is --nothing  # this line is commented out--
+ exit 0
Prüfe auf nicht gepackte Datei(en): /usr/lib/rpm/check-files /usr/src/rpmbuild/BUILDROOT/test-1.0-1.0.i386
Erstellt: /usr/src/rpmbuild/SRPMS/test-1.0-1.0.src.rpm


Expected results:

Ausführung(%prep): /bin/sh -e /var/tmp/rpm-tmp.lFcTLx
+ umask 022
+ cd /usr/src/rpmbuild/BUILD
+ echo the value of is_client is --1--
the value of is_client is --1--
+ exit 0
Prüfe auf nicht gepackte Datei(en): /usr/lib/rpm/check-files /usr/src/rpmbuild/BUILDROOT/test-1.0-1.0.i386
Erstellt: /usr/src/rpmbuild/SRPMS/test-1.0-1.0.src.rpm

Additional info:
the value should be 1 in this case (which one could use for instance in a %if statement). It should not be influenced by something on a line starting with '#'
Comment 2 Panu Matilainen 2013-10-22 02:50:03 EDT
This is expected behavior, see http://www.rpm.org/max-rpm-snapshot/ch-rpm-specref.html
Comment 3 Martin Hecht 2013-10-22 04:38:44 EDT
Hi Panu,

Ok, but intuitively I wouldn't understand %define itself as a macro. 

If the macros which are already defined are expanded inside a comment, it wouldn't matter because the line is commented out anyway. The documentation explicitly speaks about multiline macros, that would add new lines which then "run out of the commented area", that's plausible. But %define rather seems to be a command than a macro, because it is not replaced by anything, but defines a macro. 

I would recommend to add an extra note to the documentation, that everything (including %define) is interpreted even on lines starting with a '#'-sign. The example with the %configure-macro nicely illustrates the problem with multiline macros, but the issue with %define is not that obvious.

I must admit, that I have found the list of builtin macros (http://www.rpm.org/wiki/PackagerDocs/Macros#BuiltinMacros) now, which includes %define. But since this is different from the C-preprocessor for example, I would at least add the link to this list on the page of the documentation you have posted.

best regards,
Martin

Note You need to log in before you can comment on or make changes to this bug.