Bug 9930

Summary: RPM - cannot comment out %configure macro
Product: [Retired] Red Hat Linux Reporter: Motonobu Ichimura <famao>
Component: rpm-buildAssignee: Jeff Johnson <jbj>
Status: CLOSED WORKSFORME QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: iamanikamalhotra, iammariaanams, nml580oa, ss
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
URL: http://www.kondara.org
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-02-10 19:21:39 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Motonobu Ichimura 2000-03-03 06:12:11 UTC
when use %configure macro, and comment out like

#%configure

but rpm expands this to

#
 [ -f configure.in ] && libtoolize --copy --force
    CFLAGS="-O2 -m486 -fno-strength-reduce" ./configure i386-redhat-linux
--prefix=/usr

so %configure macro cannot be commented out
may also %GNUconfigure(MC:)

I wrote an easy patch for not expanding macro when
in a comment.

Here is the patch.

--- rpm-3.0.4/lib/macro.c.orig  Sat Feb 19 12:16:29 2000
+++ rpm-3.0.4/lib/macro.c       Wed Mar  1 08:31:49 2000
@@ -886,6 +886,7 @@
     int negate;
     char grab;
     int chkexist;
+    int comment = 0;

     if (++mb->depth > max_macro_depth) {
        rpmError(RPMERR_BADSPEC, _("Recursion depth(%d) greater than
max(%d)"),
@@ -899,11 +900,27 @@
        s++;
        /* Copy text until next macro */
        switch(c) {
+       case '#':
+               if (*s != '!')  /* not shell script, comment */
+                       comment = 1;
+               /* fall thru */
        case '%':
-               if (*s != '%')
-                       break;
-               s++;    /* skip first % in %% */
-               /* fall thru */
+               if(!comment) {
+                       if (*s != '%')
+                             break;
+                       s++;
+                       /* fall thru */
+               }
+               /* if in comment , fall thru */
        default:
                SAVECHAR(mb, c);
                continue;

Comment 1 Pekka Savola 2000-07-16 17:34:31 UTC
This is still an issue in rpm-4.0-0.45 from Rawhide too.

This also happens with %define.



Comment 2 Jeff Johnson 2001-02-21 18:52:04 UTC
Changing component.

Comment 3 Jack Perdue 2002-11-20 19:24:38 UTC
This is still a problem with rpm-4.0.4-7x on RH7.1.

Here is a simple test case and the results:

[root@redtower SPECS]# cat test.spec

Summary: shows octothorp aren't ignored by lines with %defines
Name: test
Version: 1
Release: 1
Group: testcase
License: open

# here is the definition we want

%define good    good

# the following define is preceeded by a octothorp which
# should cause the line to be ignored but doesn't

# %define good  bad

%description
See Summary:

%build
echo "good is %{good} is %good"

[root@redtower SPECS]# rpm -ba test.spec
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.39414
+ umask 022
+ cd /usr/src/redhat/BUILD
+ echo 'good is bad is bad'
good is bad is bad
+ exit 0
Wrote: /usr/src/redhat/SRPMS/test-1-1.src.rpm



Comment 4 Jeff Johnson 2004-02-10 19:21:39 UTC
Macros are context free, expanded wherever thay are found, within
strings, in comments, everywhere.

Add an escaping %, as in %%define if you wish to disable the
expansion.

Comment 8 Jeremy Gross 2021-05-26 10:15:57 UTC
Cannot comment out % configure macro, This confirmation is better for everyone for those who are checking our https://essay-reviewer.com/college-paper-org-review/ comment they understand the importance for Marco which we mostly use in our comments.