[Rpm-maint] [rpm-software-management/rpm] RFE: make %{load: } work in %prep (#571)

Jason Tibbitts notifications at github.com
Wed Oct 17 16:18:01 UTC 2018


But that only shows that @pmatilai's point was correct:  If you need to do something dynamically in the build scriptlets, you need to do it with the shell.

That bit of the spec does things via the shell.  So, yes, it's clearly doable in some form: with the shell.

I don't understand how what you ask for could possibly be implemented.  RPM writes out a shell script and passes it off to the shell to be executed.  It has no idea when the shell will get to the point where your %{load:} macro gets called.  RPM has completed its parsing of the spec (and thus the expansion/execution of any macros, Lua or otherwise) before any of those scripts are run.

Now, what you could ask for is some way to get some lua code called just before the scripts generated from %prep, %build, %install, etc. are actually executed (and perhaps at various other points in the build process).  I can think of a number of ways this could be useful but it depends on a number of things and I don't really have much of a clue about how it could be implemented.

Since Lua functions are first class, rpm could just call functions from a table:
```
table.insert(rpmhooks.prep, function () do_stuff() end)
```
It would also work to have a set of "magic" macros and have RPM call back into the macro processor to expand those (rpmExpandMacro) at specific points during the build process:
```
%global ___prep_hook %{lua: do_stuff()}
```
But I've no idea if you can call rpmExpandMacros after parsing is complete or if there's even still an rpmMacroContext around to use.

And obviously in order to do anything useful the lua code would have to be able to modify RPM state, the environment of the scripts or the actual contents of those scripts and I've no idea if that's reasonably possible.  (I guess there are a number of things it could do if it just gets the script filename.)  And I do know that "hook" actually has a different meaning inside RPM that I haven't quite figured out yet; I just don't know what else you would call this.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/571#issuecomment-430693570
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20181017/ad7eac03/attachment-0001.html>


More information about the Rpm-maint mailing list