Skip to content

Commit e250f28

Browse files
committed
%py_provides: Do not generate Obsoletes for names containing parentheses
This mechanism is already implemented in the old %python_provide macro.
1 parent 99e7d86 commit e250f28

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

macros.python-srpm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,14 @@
210210
-- In Fedora this is not needed as we don't ship ecosystem packages
211211
-- for alternative Python interpreters.
212212
if rhel ~= '' then
213-
local obsoletes = python.python_altobsoletes(name, evr)
214-
for i, obsolete in ipairs(obsoletes) do
215-
print('Obsoletes: ' .. obsolete .. '\\n')
213+
-- Create Obsoletes only if the name does not end in a parenthesis,
214+
-- as Obsoletes can't include parentheses.
215+
-- This most commonly happens when the name contains an isa.
216+
if (string.sub(name, "-1") ~= ")") then
217+
local obsoletes = python.python_altobsoletes(name, evr)
218+
for i, obsolete in ipairs(obsoletes) do
219+
print('Obsoletes: ' .. obsolete .. '\\n')
220+
end
216221
end
217222
end
218223
}

python-rpm-macros.spec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ elseif posix.stat('macros.python-srpm') then
4949
end
5050
}
5151
Version: %{__default_python3_version}
52-
Release: 16%{?dist}
52+
Release: 17%{?dist}
5353

5454
BuildArch: noarch
5555

@@ -151,6 +151,9 @@ install -m 755 brp-* %{buildroot}%{_rpmconfigdir}/redhat/
151151

152152

153153
%changelog
154+
* Tue Feb 08 2022 Tomas Orsava <[email protected]> - 3.10-17
155+
- %%py_provides: Do not generate Obsoletes for names containing parentheses
156+
154157
* Mon Jan 31 2022 Miro Hrončok <[email protected]> - 3.10-16
155158
- Explicitly opt-out from Python name-based provides and obsoletes generators
156159

tests/test_evals.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,16 @@ def test_py_provides_python3(rhel):
195195
assert len(lines) == 3
196196

197197

198+
@pytest.mark.parametrize('rhel', [None, 9])
199+
def test_py_provides_python3_with_isa(rhel):
200+
lines = rpm_eval('%py_provides python3-foo(x86_64)', version='6', release='1.fc66', rhel=rhel)
201+
assert 'Provides: python3-foo(x86_64) = 6-1.fc66' in lines
202+
assert 'Provides: python-foo(x86_64) = 6-1.fc66' in lines
203+
assert f'Provides: python{X_Y}-foo(x86_64) = 6-1.fc66' in lines
204+
assert f'Obsoletes: python{X_Y}-foo(x86_64) < 6-1.fc66' not in lines
205+
assert len(lines) == 3
206+
207+
198208
@pytest.mark.parametrize('rhel', [None, 13])
199209
def test_py_provides_python3_epoched(rhel):
200210
lines = rpm_eval('%py_provides python3-foo', epoch='1', version='6', release='1.fc66', rhel=rhel)

0 commit comments

Comments
 (0)