[Rpm-maint] [rpm-software-management/rpm] Proposal for default init.lua (#321)

Jason Tibbitts notifications at github.com
Thu Sep 7 22:23:18 UTC 2017

I don't know if people see init.lua as something to be used or avoided, but I have played with it on and off over the past few years.  When playing with macros I generally do anything even mildly complicated in lua, and I ended up with a basic debugging framework and a set of utility functions.  Having those by default in the namespace is useful, but not generally possible unless a specfile invokes a macro which defines them or you use init.lua.

But one obvious problem with it is that it's a monolithic file, so you can't  have a package drop in additional functions.  I solved this with the following init.lua file, which just loads other lua files from /usr/lib/rpm/lua.d.  Note that I wrote this with the intent of shipping this in one of the Fedora RPM-related packages but did not get to the point of actually doing that.

I can already see various improvements to be made (such as making sure the list is processed in order) but I figured I would at least offer something to start a discussion.

-- Master Fedora Lua init file for RPM

-- RPM will execute this file at each run.  It should do nothing other than
-- sourcing other Lua files in /usr/lib/rpm/lua.d

-- Originally written by Jason Tibbitts <tibbs at math.uh.edu> in 2016.
-- Donated to the public domain.  If you require a statement of license, please
-- consider this work to be licensed as "CC0 Universal", any version you
-- choose.

-- My hope is that other distributions, or RPM itself, will adopt this method.
-- If RPM does, this file should go away.

local rpm_lua_dir = "/usr/lib/rpm/lua.d"

package.path = package.path .. ";" .. rpm_lua_dir .. "/?.lua"

local i, file
for i, file in pairs(posix.dir(rpm_lua_dir)) do
    local name = file:match("(.*).lua")
    if name then

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20170907/e5e4c5b0/attachment.html>

More information about the Rpm-maint mailing list