Bug 490740

Summary: nested lua expansions not supported
Product: [Fedora] Fedora Reporter: Carl Roth <roth>
Component: rpmAssignee: Panu Matilainen <pmatilai>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: ffesti, jnovy, n3npq, pinto.elia, pmatilai, yersinia.spiros
Target Milestone: ---Keywords: FutureFeature, Upstream
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-07-19 05:05:01 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Attachments:
Description Flags
spec file with lua scripts none

Description Carl Roth 2009-03-17 15:22:27 EDT
Description of problem:

Nested lua expansions in an RPM spec file don't appear to work.  From what I can tell (also by peeking at the RPM sources) the print buffer for lua expansions is not preserved between nested lua invocations.

Version-Release number of selected component (if applicable):

rpm-4.6.0-1.fc10.x86_64 (also affects F9 rpm)

How reproducible:

Always (see attach spec)

Steps to Reproduce:
1. download the attached spec file
2. rpmbuild --nodeps -bs *.spec
3. rpm -qp --requires *.src.rpm
  
Actual results:


Expected results:


Additional info:

I guess the workaround is to never nest lua expansions, but it can be tricky if other rpm macros are defined in terms of them...
Comment 1 Carl Roth 2009-03-17 15:23:29 EDT
Created attachment 335592 [details]
spec file with lua scripts
Comment 2 Jeff Johnson 2009-09-21 09:35:04 EDT
(aside)
Nested lua expansions actually "work" @rpm5.org.

Here's your foo.spec with %trace added:
  0< # this statement stumbles (print buffer is mis-directed)
  1>   %{expand:%{lua:
  foo = rpm.expand("%__foo")
  print("BuildRequires: " .. foo .. "-devel" .. "\n")
}}^
  2>     %{lua:
  foo = rpm.expand("%__foo")
  print("BuildRequires: " .. foo .. "-devel" .. "\n")
}^
  1>   %__foo^
  2>     %{lua:
  print("foo")
}^
  1<   foo
  0< foo
  1<   BuildRequires: foo-devel
  1<   BuildRequires: foo-devel
  0< BuildRequires: foo-devel

But the fundamental issue for RPM is
    Is there any need for multiple nested lua invocations in RPM
    coordinated through a print buffer?

E.g. the embedded lua interpreter is (by intent) persistent so that
variables can be shared between invocations.

OTOH, the expectation here is that the print buffer be specifcally tied
to each nested invocation, i.e. unshared. That isn't a suprising expectation,
just not what was/is implemented with embedded lua.

Its conceivable to have lua invocations behave either with globally
shared state, or with independent nested invocations, dependent
on how invoked. The analogue in shell is {} vs () nesting, commands within
{} are executed by the current interpreter, () nests an interpreter when needed.

But that just brings me full circle to
    Is there really any need for this level of complexity to generate
        BuildRequires: foo-devel
Comment 3 Bug Zapper 2009-11-18 06:32:45 EST
This message is a reminder that Fedora 10 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 10.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '10'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 10's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 10 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 4 Panu Matilainen 2011-05-24 13:49:57 EDT
FWIW, support for nested Lua macros has now been added upstream.
Comment 5 Panu Matilainen 2011-07-19 05:05:01 EDT
Nested lua macros are supported in rpm >= 4.9.1, in rawhide now.