Bug 9930 - RPM - cannot comment out %configure macro
Summary: RPM - cannot comment out %configure macro
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: rpm-build   
(Show other bugs)
Version: 6.2
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jeff Johnson
QA Contact:
URL: http://www.kondara.org
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-03-03 06:12 UTC by Motonobu Ichimura
Modified: 2007-04-18 16:26 UTC (History)
1 user (show)

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: ---


Attachments (Terms of Use)

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.


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