text: On 03/16/2011 08:34 AM, 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 It creates a temporary lua variable which is either nil or the matched substring, and prints only the matched substring. I tested it with lots of %{echo:...} and various manipulations of %define/%undefine. -- Eric Blake eblake redhat com +1-801-349-2682 Libvirt virtualization library
  Attachment:
  signature.asc
  Description: OpenPGP digital signature