From 85209d6c4672f869505806e6c21a29ca62346567 Mon Sep 17 00:00:00 2001 From: Tomas Orsava Date: Tue, 8 Feb 2022 11:53:45 +0100 Subject: [PATCH] %py_provides: Do not generate Obsoletes for names containing parentheses This mechanism is already implemented in the old %python_provide macro. Related: rhbz#1990421 --- macros.python-srpm | 11 ++++++++--- python-rpm-macros.spec | 6 +++++- tests/test_evals.py | 10 ++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/macros.python-srpm b/macros.python-srpm index f7d6b02..b5a7d54 100644 --- a/macros.python-srpm +++ b/macros.python-srpm @@ -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 } diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 15821f4..a10cece 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -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 - 3.9-52 +- %%py_provides: Do not generate Obsoletes for names containing parentheses +- Related: rhbz#1990421 + * Tue Feb 08 2022 Tomas Orsava - 3.9-51 - Add Obsoletes tags with the python39- prefix for smoother upgrade from RHEL8 - Related: rhbz#1990421 diff --git a/tests/test_evals.py b/tests/test_evals.py index 017457e..33a040f 100644 --- a/tests/test_evals.py +++ b/tests/test_evals.py @@ -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)