Bug 9930 - RPM - cannot comment out %configure macro
RPM - cannot comment out %configure macro
Status: CLOSED WORKSFORME
Product: Red Hat Linux
Classification: Retired
Component: rpm-build (Show other bugs)
6.2
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jeff Johnson
http://www.kondara.org
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-03-03 01:12 EST by Motonobu Ichimura
Modified: 2007-04-18 12:26 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-02-10 14:21:39 EST
Type: ---
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 Motonobu Ichimura 2000-03-03 01:12:11 EST
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 13:34:31 EDT
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 13:52:04 EST
Changing component.
Comment 3 Jack Perdue 2002-11-20 14:24:38 EST
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 14:21:39 EST
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.