[libvirt] [PATCH] spec: Guess rhel/fedora macros from dist
Eric Blake
eblake at redhat.com
Wed Mar 16 17:37:33 UTC 2011
On 03/16/2011 05:54 AM, Jiri Denemark wrote:
> ---
> If anyone knows how to make rpm to evaluate %(...) immediately and not
> at every appearance of rhel/fedora, that would be really cool.
Figured it out without lua: Use %{expand:} to only encounter %define
after the shell substitution has completed (that is, instead of defining
a macro to be a shell substitution, we use shell substitution to
conditionally define a macro to be a constant value).
# If neither fedora nor rhel was defined, try to guess them from %{dist}
%if !0%{?rhel} && !0%{?fedora}
%{expand:%(echo "%{?dist}" | sed -ne 's/^\.el\([0-9]\+\).*/%%define rhel
\1/p')}
%{expand:%(echo "%{?dist}" | sed -ne 's/^\.fc\?\([0-9]\+\).*/%%define
fedora \1/p')}
%endif
Works on RHEL 5, too, since it doesn't use lua.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110316/01f42f56/attachment-0001.sig>
More information about the libvir-list
mailing list