[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Heads-up: %define vs %global in specs

For the impatient:

Starting with today's rawhide, the these kind of constructs in specs no longer "work":
	%{?!foo: %define foo bar}
For the generally desired effect, the above simply becomes:
	%{?!foo: %global foo bar}

This is already recommended by the Fedora guidelines, but packages which haven't been updated to follow the guideline might need revising:

The longer version:

As explained in the guidelines, %define nested in %{ } block was never supposed to work, but due to a longstanding bug in rpm macro engine it has seemed to work in many cases... until you do something completely unrelated in the spec and it suddenly breaks in mysterious ways. Consider this example spec:

--- snip ---
%{!?foo: %define foo bar}
%define dofoo() true

Name:             macroscope
Version:          1.0
Release:          1
License:          Testing
Summary:          Testing macro behavior


echo 1: %{foo}


echo 2: %{foo}

--- snip ---

You'd probably expect %{foo} to expand to "bar" in both 1 and 2, but due to this funny little macro buglet, you'd get this rather non-obvious result:
1: bar
2: %{foo}

What you start getting now is:
1: %{foo}
2: %{foo}

...in other words, the %define inside %{} block goes out of scope when the block ends, and you probably wanted to use %global there instead.

	- Panu -

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]