Bug 552944 - locally defined macros still buggy
locally defined macros still buggy
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
26
All Linux
medium Severity medium
: ---
: ---
Assigned To: Fedora Packaging Toolset Team
Fedora Extras Quality Assurance
: Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-01-06 10:54 EST by Stepan Kasal
Modified: 2017-08-22 07:40 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-08-22 07:40:48 EDT
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 Stepan Kasal 2010-01-06 10:54:40 EST
I'm using rpm-4.8.0-0.beta1.5 which is supposed to fix a bug with %define, see
http://www.redhat.com/archives/fedora-devel-list/2010-January/msg00093.html

But I can still get very weird results:
1) take the example and move the first two lines after %prep, like this:
--- snip ---
Name:             macroscope
Version:          1.0
Release:          1
License:          Testing
Summary:          Testing macro behavior

%description
%{summary}

%prep
%{!?foo: %define foo bar}
%define dofoo() true
echo 1: %{foo}
%dofoo
echo 2: %{foo}

%files
%defattr(-,root,root)
--- snip ---

2) rpmbuild -b macroscope.spec
The expansion is:
1: bar
2: %{foo}

I believe both %{foo} should expand to the same.
Comment 1 Bug Zapper 2010-03-15 09:46:14 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 13 development cycle.
Changing version to '13'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 2 Bug Zapper 2011-06-02 12:59:10 EDT
This message is a reminder that Fedora 13 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 13.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '13'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 13's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 13 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 3 Panu Matilainen 2011-06-17 08:46:13 EDT
Moving to rawhide to avoid timeouting, this hasn't been addressed in later rpm versions either (and in fact, the attempted fix to %define scoping was reverted soon after introducing as it broke other things).
Comment 4 Fedora Admin XMLRPC Client 2012-04-13 19:08:12 EDT
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 5 Fedora Admin XMLRPC Client 2012-04-13 19:11:38 EDT
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 6 Fedora End Of Life 2013-04-03 14:19:10 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.

(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19
Comment 7 Stepan Kasal 2014-10-20 08:56:07 EDT
Moving to rawhide to avoid timeouting,...

Has anything happened with this?
Comment 8 Panu Matilainen 2014-10-20 09:28:04 EDT
Yes and no... rpm upstream now warns on this:

[pmatilai@localhost rpm]$ ./rpmbuild -bp ~/rpmbuild/SPECS/macroscope.spec 
warning: Macro %foo defined but not used within scope
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.4HO5Nz
+ umask 022
+ cd /home/pmatilai/rpmbuild/BUILD
+ echo 1: bar
1: bar
+ true
+ echo 2: '%{foo}'
2: %{foo}
+ exit 0

Rpm 4.12 can emit that warning too if macro tracing is on (eg place '%trace' at top of the spec'), disabled by default in part because of performance issues, and the upstream fix to that could be quite easily backported to 4.12 branch.

However I find myself wondering more and more whether a saner solution to the whole scoping business exists, such as perhaps only treating %define as locally scoped within parametrized macros. But note that this is merely speculation at this point.
Comment 9 Stepan Kasal 2015-05-04 11:01:14 EDT
Yes, I have to agree that the current behaviour is very counter-intuitive.
Comment 10 Jan Kurik 2015-07-15 11:20:12 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 23 development cycle.
Changing version to '23'.

(As we did not run this process for some time, it could affect also pre-Fedora 23 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 23 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora23
Comment 11 Fedora End Of Life 2016-11-24 05:26:05 EST
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 12 Panu Matilainen 2016-11-24 06:58:09 EST
Maging to rawhide to avoid timeouting, the issue is still valid.
Comment 13 Fedora End Of Life 2017-02-28 04:28:49 EST
This bug appears to have been reported against 'rawhide' during the Fedora 26 development cycle.
Changing version to '26'.
Comment 14 Panu Matilainen 2017-03-07 07:51:07 EST
Fixed upstream, hopefully for good, by actually changing the alleged scoping rules to what everybody expects and what always mostly worked. Ie macros defined within parametric macros are local and really removed when they go out of scope, everything else is global:

https://github.com/rpm-software-management/rpm/commit/237f35f16f978bb20e4cafd78abfab1f2e5db480
Comment 15 Panu Matilainen 2017-08-22 07:40:48 EDT
In rawhide/F27 now as of rpm >= 4.13.90

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