Automatically call %python_provide

This allows us to drop the %python_provide macro from most spec files,
except where we want to use it for virtual provides or empty packages.
This commit is contained in:
Miro Hrončok 2020-03-05 23:40:17 +01:00
commit bbfe4930d9
5 changed files with 120 additions and 2 deletions

20
pythonname.attr Normal file
View file

@ -0,0 +1,20 @@
%__pythonname_provides() %{lua:
-- this macro is called for each file in a package, the path being in %1
-- but we don't need to know the path, so we would get for each file: Macro %1 defined but not used within scope
-- in here, we expand %name conditionally on %1 to suppress the warning
local name = rpm.expand('%{?1:%{name}}')
-- a structure that knows what names were already processed, so we can end early
if __pythonname_beenthere == nil then
__pythonname_beenthere = {}
end
-- we save ourselves a trip to %python_provide if we have already been there
if __pythonname_beenthere[name] == nil then
local python_provide = rpm.expand('%{?python_provide:%python_provide %{name}}')
for provides in python_provide:gmatch('Provides:[ \\t]+([^\\n]+)') do
print(provides .. " ")
end
__pythonname_beenthere[name] = true
end
}
%__pythonname_path ^/