python-rpm-generators/python.attr
Kalev Lember 47a0b37ac0 Generate provides for /app-installed flatpak builds
The generator deliberately does not use %{_prefix} in order to avoid
generating provides for packages that set a custom prefix. This is done
to ensure that provides are only generated for paths where the Python
interpreter actually loads modules from.

As we can't use %{_prefix} (which would make it all much simpler), this
commit adds a conditional to look in /app only when the %flatpak macro
is defined, and /usr otherwise.

This should fix provides generation for /app-installed flatpak builds.
2023-04-20 04:23:47 +02:00

32 lines
1.4 KiB
Plaintext

%__python_provides() %{lua:
-- Match buildroot/payload paths of the form
-- /PATH/OF/BUILDROOT/usr/bin/pythonMAJOR.MINOR
-- generating a line of the form
-- python(abi) = MAJOR.MINOR
-- (Don't match against -config tools e.g. /usr/bin/python2.6-config)
local path = rpm.expand('%1')
-- Use /usr prefix by default, and /app for flatpak builds
local prefix = rpm.expand('%{?!flatpak:/usr}%{?flatpak:/app}')
if path:match(prefix .. '/bin/python%d+%.%d+$') then
local provides = path:gsub('.*' .. prefix .. '/bin/python(%d+%.%d+)', 'python(abi) = %1')
print(provides)
end
}
%__python_requires() %{lua:
-- Match buildroot paths of the form
-- /PATH/OF/BUILDROOT/usr/lib/pythonMAJOR.MINOR/ and
-- /PATH/OF/BUILDROOT/usr/lib64/pythonMAJOR.MINOR/
-- generating a line of the form:
-- python(abi) = MAJOR.MINOR
local path = rpm.expand('%1')
-- Use /usr prefix by default, and /app for flatpak builds
local prefix = rpm.expand('%{?!flatpak:/usr}%{?flatpak:/app}')
if path:match(prefix .. '/lib%d*/python%d+%.%d+/.*') then
local requires = path:gsub('.*' .. prefix .. '/lib%d*/python(%d+%.%d+)/.*', 'python(abi) = %1')
print(requires)
end
}
%__python_path ^((%{?!flatpak:/usr}%{?flatpak:/app}/lib(64)?/python[[:digit:]]+\\.[[:digit:]]+/.*\\.(py[oc]?|so))|(%{_bindir}/python[[:digit:]]+\\.[[:digit:]]+))$