
On 03/16/2011 10:23 AM, Jiri Denemark wrote:
On Wed, Mar 16, 2011 at 09:31:13 -0600, Eric Blake wrote:
This works for one-shot evaluation:
# if neither fedora nor rhel was defined, try to guess them from %{dist} %if !0%{?rhel} && !0%{?fedora} %define rhel %{lua: v=string.match(rpm.expand("%{?dist}"), "^%.el([0-9]+).*"); if v ~= nil then print(v) end} %define fedora %{lua: v=string.match(rpm.expand("%{?dist}"), "^%.fc?([0-9]+).*"); if v ~= nil then print(v) end} %endif
Hmm, this is nice in avoiding forks but it unfortunately doesn't seem to work on RHEL-5:
error: lua script failed: [string "<lua>"]:1: attempt to call field `match' (a nil value) 1< (empty) 0< %if 0 error: line 18: %if 0
Indeed - 'yum deplist rpm | grep lua' on a RHEL 5 box shows that rpm was not built with lua support back then. So we can't use lua; any solution will have to stick with what is supported in RHEL 5. Does %{expand:...} do what we want? Otherwise, I'm out of ideas for avoiding a subshell for every time the macro is expanded. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org