Make %py_provides work repeatedly

This commit is contained in:
Miro Hrončok 2020-04-28 18:54:02 +02:00
parent 8fea79b1ec
commit 5fe974759a
2 changed files with 9 additions and 7 deletions

View File

@ -149,12 +149,8 @@
evr = rpm.expand('%{?epoch:%{epoch}:}%{version}-%{release}')
end
print('Provides: ' .. name .. ' = ' .. evr .. '\\n')
local provides = python.python_altprovides_once(name, evr)
-- provides is either an array/table or nil
-- nil means the function was already called with the same arguments
if provides then
for i, provide in ipairs(provides) do
print('Provides: ' .. provide .. '\\n')
end
local provides = python.python_altprovides(name, evr)
for i, provide in ipairs(provides) do
print('Provides: ' .. provide .. '\\n')
end
}

View File

@ -31,6 +31,11 @@ end
-- Uses python_altnames under the hood
-- Returns a table/array with strings.
local function python_altprovides(name, evr)
-- global cache that tells what provides were already processed
if __python_altnames_provides_beenthere == nil then
__python_altnames_provides_beenthere = {}
end
__python_altnames_provides_beenthere[name .. ' ' .. evr] = true
local altprovides = {}
for i, altname in ipairs(python_altnames(name)) do
table.insert(altprovides, altname .. ' = ' .. evr)
@ -41,6 +46,7 @@ end
-- Like python_altprovides but only return something once.
-- For each argument can only be used once, returns nil otherwise.
-- Previous usage of python_altprovides counts as well.
local function python_altprovides_once(name, evr)
-- global cache that tells what provides were already processed
if __python_altnames_provides_beenthere == nil then