From b1fa63bf02b03b2120d32eb91ca2911d4ec77beb Mon Sep 17 00:00:00 2001 From: Tomas Orsava Date: Mon, 29 Nov 2021 12:31:48 +0100 Subject: [PATCH] From `python3-foo` packages automatically generate `python3.X-foo` Obsoletes tags on CentOS/RHEL --- python-rpm-generators.spec | 8 ++++++-- pythonname.attr | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/python-rpm-generators.spec b/python-rpm-generators.spec index 7a6c39b..fd88df1 100644 --- a/python-rpm-generators.spec +++ b/python-rpm-generators.spec @@ -1,7 +1,7 @@ Name: python-rpm-generators Summary: Dependency generators for Python RPMs Version: 12 -Release: 12%{?dist} +Release: 13%{?dist} # Originally all those files were part of RPM, so license is kept here License: GPLv2+ @@ -25,7 +25,7 @@ Requires: python3-packaging # We have parametric macro generators, we need RPM 4.16 (4.15.90+ is 4.16 alpha) Requires: rpm > 4.15.90-0 # This contains the Lua functions we use: -Requires: python-srpm-macros >= 3.8-5 +Requires: python-srpm-macros >= 3.10-15 %description -n python3-rpm-generators %{summary}. @@ -47,6 +47,10 @@ install -Dpm0755 -t %{buildroot}%{_rpmconfigdir} *.py %{_rpmconfigdir}/pythonbundles.py %changelog +* Wed Jan 26 2022 Tomas Orsava - 12-13 +- From `python3-foo` packages automatically generate `python3.X-foo` Obsoletes + tags on CentOS/RHEL + * Fri Jan 21 2022 Fedora Release Engineering - 12-12 - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild diff --git a/pythonname.attr b/pythonname.attr index 9cd580a..07d8df5 100644 --- a/pythonname.attr +++ b/pythonname.attr @@ -16,4 +16,27 @@ end } +%__pythonname_obsoletes() %{?rhel:%{lua: + -- On CentOS/RHEL we automatically generate Obsoletes tags in the form: + -- package python3-foo -> Obsoletes: python3.XY-foo + -- This provides a clean upgrade path between major versions of CentOS/RHEL. + -- In Fedora this is not needed as we don't ship ecosystem packages + -- for alternative Python interpreters. + local python = require 'fedora.srpm.python' + -- this macro is called for each file in a package, the path being in %1 + -- but we don't need to know the path, so we would get for each file: Macro %1 defined but not used within scope + -- in here, we expand %name conditionally on %1 to suppress the warning + local name = rpm.expand('%{?1:%{name}}') + local evr = rpm.expand('%{?epoch:%{epoch}:}%{version}-%{release}') + local obsoletes = python.python_altobsoletes_once(name, evr) + -- obsoletes is either an array/table or nil + -- nil means the function was already called with the same arguments: + -- either with another file in %1 or manually via %py_provides + if obsoletes then + for i, obsolete in ipairs(obsoletes) do + print(obsolete .. ' ') + end + end +}} + %__pythonname_path ^/