Skip to content

Commit

Permalink
Add a Provides generator for rpm lua modules
Browse files Browse the repository at this point in the history
Some packages in Fedora provide shared RPM lua code that's used by other
packages.
It would be nice to have automatic Provides for this code like we have
for rpm macros themselves.

Usecase:

Recently, forge.lua that's used by go-srpm-macros and fonts-srpm-macros
moved out of redhat-rpm-config.
I would like to be able to add `Requires: rpm_lua(fedora.srpm.forge)`
to those packages instead of having to rely on it being implicitly
pulled in by redhat-rpm-config or adding conditional dependencies on
forge-srpm-macros.
  • Loading branch information
gotmax23 authored and pmatilai committed Sep 15, 2023
1 parent 1120c8c commit 6867ef9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fileattrs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
install(FILES
debuginfo.attr desktop.attr elf.attr font.attr metainfo.attr
perl.attr perllib.attr pkgconfig.attr ocaml.attr
rpm_macro.attr script.attr sysusers.attr usergroup.attr
rpm_macro.attr rpm_lua.attr script.attr sysusers.attr usergroup.attr
DESTINATION ${RPM_CONFIGDIR}/fileattrs
)
12 changes: 12 additions & 0 deletions fileattrs/rpm_lua.attr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Generate Provides for modules in /usr/lib/rpm/lua.
# Analogous to the rpm_macro Provides generator
# - /usr/lib/rpm/lua/fedora/common.lua -> rpm_lua(fedora.common)
# - /usr/lib/rpm/lua/fedora/srpm/python.lua -> rpm_lua(fedora.srpm.python)

%__rpm_lua_path ^%{_rpmluadir}/.+\.lua$
%__rpm_lua_provides() %{lua:
-- Strip BUILDROOT + /usr/lib/rpm/lua/
local idx = macros.buildroot:len() + macros._rpmluadir:len() + 2
local path = arg[1]:sub(idx, -5)
print("rpm_lua(" .. path:gsub("/", ".") .. ")")
}

0 comments on commit 6867ef9

Please sign in to comment.