RPM

rpmbuild does not do expand with %if %with(...)

Bug #651490 reported by Jeff Johnson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
RPM
New
Undecided
Unassigned
Fedora
Won't Fix
Medium

Bug Description

tracker

Revision history for this message
In , Kirby (kirby-redhat-bugs) wrote :

Description of problem:

Sometimes rpmbuild do does not do expand with %if %with(...)

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

rpm-build-4.4.2.3-18.el5

How reproducible:

100%

Steps to Reproduce:
1. cat > test.spec
# for testing
%bcond_without alternatives
%{!?_extension:%define _extension .gz}
Name: test
Version: 1.0
Release: 1%{?dist}
Summary: Just a test
Group: Testing
License: BSD
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description
Just a Joke
%prep
true
%build
true
%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT%{_infodir}
#%if %{?with_alternatives:1}%{!?with_alternatives:0}
%if %with(alternatives)
echo ft | gzip > $RPM_BUILD_ROOT%{_infodir}/gperf-ace.info%{_extension}
%endif
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
%doc
%{_infodir}/gperf-ace.info%{_extension}
%changelog

2. rpmbuild -bb test.spec

Actual results:
error: File not found: /var/tmp/test-1.0-1.el5-root-root/usr/share/info/gperf-ace.info%{_extension}

Expected results:
rpmbuild expand the correct result: /var/tmp/test-1.0-1.el5-root-root/usr/share/info/gperf-ace.info.gz

Additional info:

replace '%if %with(alternatives)' with '%if %{?with_alternatives:1}%{!?with_alternatives:0}' could temporaryly fix this proble.

replace '%if %with(alternatives)' with '%if %{?with_alternatives:1}%{!?with_alternatives:0}' could temporaryly fix this problem.

replace '%{!?_extension:%define _extension .gz}' with '%{!?_extension:%global _extension .gz}' could temporaryly fix this problem.

Revision history for this message
In , Panu (panu-redhat-bugs) wrote :

There's a indeed a bug here but it's not what you think it is...
Macros are scoped so the _extension %define only exists in the {} block of this line:
%{!?_extension:%define _extension .gz}

Or rather, it's *supposed* to only exist in that block, but due to an ages old bug in the macro engine, it doesn't get undefined until you call a (possibly completely unrelated) parametrized macro, %with() in this case.

This is the correct way, not a workaround:
%{!?_extension:%global _extension .gz}

WONTFIX for RHEL 5 to avoid unnecessary breakage there, but fixed upstream now to enforce use of %global in such cases.

Jeff Johnson (n3npq)
tags: added: macros rpmbuild
tags: added: rhel
Changed in fedora:
importance: Unknown → Medium
status: Unknown → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.