On Aug 27, 2007, at 2:48 PM, Jos Vos wrote:
On Mon, Aug 27, 2007 at 02:35:14PM -0400, Jeff Johnson wrote:
The macro primitive %{expand:...} is like eval in shell.
That's what I thought...
When browsing through spec files, I have the impression that it is
unnecessarily used in a lot of cases.
Likely.
Just some excerpts from RHEL5 spec files (some are even used
frequently):
%{expand: %%define pyver %(python -c 'import
sys;print(sys.version[0:3])')}
%{expand: %%define build_with_freetype %{?_with_freetype:1}%{!?
_with_freetype:0}}
Ah, this is an optimization. The first pass of the %{expand: ...}
invokes a helper
command, the 2nd pass does the define, so that the helper is not
lazily executed
repeatedly.
I think this is an example of proper use (as there is a recursion),
right?
%{expand: %%define _includedir %{_includedir}/%{name}}
In this case, it really doesn't matter how often "%{_includedir}/%
{name}" is
expanded. Well, it _MAY_matter if the value of %{name} is changing,
but I doubt you can really solve the problem of, say, %{name} possibly
changing
meaningfully by using %{expand:...}.
Invoking a helper repeatedly is what was being avoided by
using %{expand:...} in yr first example.
73 de Jeff
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/rpm-list