%py_provides: Do not generate Obsoletes for names containing parentheses

This mechanism is already implemented in the old %python_provide macro.

Related: rhbz#1990421
This commit is contained in:
Tomas Orsava 2022-02-08 11:53:45 +01:00
parent a30059967b
commit 85209d6c46
3 changed files with 23 additions and 4 deletions

View File

@ -182,9 +182,14 @@
-- In Fedora this is not needed as we don't ship ecosystem packages
-- for alternative Python interpreters.
if rhel ~= '' then
local obsoletes = python.python_altobsoletes(name, evr)
for i, obsolete in ipairs(obsoletes) do
print('Obsoletes: ' .. obsolete .. '\\n')
-- Create Obsoletes only if the name does not end in a parenthesis,
-- as Obsoletes can't include parentheses.
-- This most commonly happens when the name contains an isa.
if (string.sub(name, "-1") ~= ")") then
local obsoletes = python.python_altobsoletes(name, evr)
for i, obsolete in ipairs(obsoletes) do
print('Obsoletes: ' .. obsolete .. '\\n')
end
end
end
}

View File

@ -1,6 +1,6 @@
Name: python-rpm-macros
Version: 3.9
Release: 51%{?dist}
Release: 52%{?dist}
Summary: The common Python RPM macros
URL: https://src.fedoraproject.org/rpms/python-rpm-macros/
@ -116,6 +116,10 @@ install -m 644 import_all_modules.py %{buildroot}%{_rpmconfigdir}/redhat/
%changelog
* Tue Feb 08 2022 Tomas Orsava <torsava@redhat.com> - 3.9-52
- %%py_provides: Do not generate Obsoletes for names containing parentheses
- Related: rhbz#1990421
* Tue Feb 08 2022 Tomas Orsava <torsava@redhat.com> - 3.9-51
- Add Obsoletes tags with the python39- prefix for smoother upgrade from RHEL8
- Related: rhbz#1990421

View File

@ -195,6 +195,16 @@ def test_py_provides_python3(rhel):
assert len(lines) == 3
@pytest.mark.parametrize('rhel', [None, 9])
def test_py_provides_python3_with_isa(rhel):
lines = rpm_eval('%py_provides python3-foo(x86_64)', version='6', release='1.fc66', rhel=rhel)
assert 'Provides: python3-foo(x86_64) = 6-1.fc66' in lines
assert 'Provides: python-foo(x86_64) = 6-1.fc66' in lines
assert f'Provides: python{X_Y}-foo(x86_64) = 6-1.fc66' in lines
assert f'Obsoletes: python{X_Y}-foo(x86_64) < 6-1.fc66' not in lines
assert len(lines) == 3
@pytest.mark.parametrize('rhel', [None, 13])
def test_py_provides_python3_epoched(rhel):
lines = rpm_eval('%py_provides python3-foo', epoch='1', version='6', release='1.fc66', rhel=rhel)