Bug 124458 - rpmbuild macroprocessing error with commented out _sourcedir
Summary: rpmbuild macroprocessing error with commented out _sourcedir
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: rpm   
(Show other bugs)
Version: 3.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jeff Johnson
QA Contact: Mike McLean
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-05-26 19:09 UTC by Aleksandr Brezhnev
Modified: 2007-11-30 22:07 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-05-26 21:01:00 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 Aleksandr Brezhnev 2004-05-26 19:09:03 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2)
Gecko/20030716

Description of problem:
If rpm spec file has commented out %define statement for _topdir or
_sourcedir, rpmbuild does not undestand that they are commented out
and performs assignments.


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.Put spec file like an example below to your %{_topdir}/SPECS directory.

===== Begin of bug.spec =====
Summary: rpmbuild macro processing bug example
Name: bug
Version: 1
Release: 1
Group: Examples
Source0: example.tar.gz
License: free
Buildroot:%{_tmppath}/%{name}-%{version}

# %define _sourcedir /tmp

%description
This is an example to demonstrate rpmbuild macroprocessing bug.

%prep
%setup -n bug
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/tmp
cp example $RPM_BUILD_ROOT/tmp

%clean
rm -rf $RPM_BUILD_ROOT

%files
%attr(0644,root,root) /tmp/example
===== End of bug.spec =====

Copy bug.spec to good.spec and remove a line with commented out
%define statement from good.spec:

===== Begin of good.spec =====
Summary: rpmbuild macro processing bug example
Name: bug
Version: 1
Release: 1
Group: Examples
Source0: example.tar.gz
License: free
Buildroot:%{_tmppath}/%{name}-%{version}

%description
This is an example to demonstrate rpmbuild macroprocessing bug.

%prep
%setup -n bug

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/tmp
cp example $RPM_BUILD_ROOT/tmp

%clean
rm -rf $RPM_BUILD_ROOT

%files
%attr(0644,root,root) /tmp/example
===== End of good.spec =====

2.Create an example.tar.gz and put it into your %_sourcedir directory.
E.g., 
mkdir bug
echo "Sample file" > bug/example
tar zcvf SOURCES/example.tar.gz bug

3.Try to run "rpmbuild -bp bug.spec
    

Actual Results:  
$ rpmbuild -bp bug.spec
error: File /tmp/example: No such file or directory

Expected Results:  
$ rpmbuild -bp good.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.4950
+ umask 022
+ cd /home/devel/rpm/BUILD
+ cd /home/devel/rpm/BUILD
+ rm -rf bug
+ /usr/bin/gzip -dc /home/devel/rpm/SOURCES/example.tar.gz
+ tar -xvvf -
drwxrwxr-x devel/devel       0 2004-05-26 14:49:46 bug/
-rw-rw-r-- devel/devel      12 2004-05-26 14:49:46 bug/example
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd bug
++ /usr/bin/id -u
+ '[' 1001 = 0 ']'
++ /usr/bin/id -u
+ '[' 1001 = 0 ']'
+ /bin/chmod -Rf a+rX,g-w,o-w .
+ exit 0



Additional info:
$ rpm -q rpm-build
rpm-build-4.2.2-0.14

$ uname -r
2.4.21-9.ELsmp

Comment 1 Jeff Johnson 2004-05-26 21:01:00 UTC
macros are entirely context free, are expanded everywhere
they are found, in comments, within quotes, everywhere.

Do
   # %%foo
to disable the expansion. Note the 2nd %.


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