Description of problem: ----- test.spec %{!?myvar:%define myvar foo} %define othervar bar %{!?release_func:%define release_func() %1} Name: test %{error:%myvar} %{error:%othervar} Version: %release_func 1 %{error:%myvar} %{error:%othervar} Release: 0.fdr.1 Epoch: 0 Group: X License: X Summary: X %description ------ | $ rpmbuild -bs test.spec | error: foo | error: bar | error: %myvar | error: bar please notice the 3rd line: the definition of %myvar was forgotten suddenly when a function was executed. Version-Release number of selected component (if applicable): rpm-4.3.3-8 How reproducible: 100% Steps to Reproduce: 1. see above Actual results: 3rd line is 'error: %myvar' Expected results: 3rd line is 'error: foo'
Yep. A function cleans all macro definitions at same (or deeper) recursion level lazily upon exit. Doing %{!?myvar:%global myvar foo} will give you the behavior you expect. This issue is too arcane to fix imho, use the workaround.