Brand as "3.8", rework %python_provide

- Hardcode the default Python 3 version in the SRPM macros
- Provide python38-foo for python3-foo and the other way around (future RHEL compatibility)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1812087

    $ rpm --eval '%python_provide python38-setuptools'
    Provides: python-setuptools = %{version}-%{release}
    Provides: python3-setuptools = %{version}-%{release}
    Obsoletes: python-setuptools < %{version}-%{release}

    $ rpm --eval '%python_provide python3-setuptools'
    Provides: python-setuptools = %{version}-%{release}
    Provides: python38-setuptools = %{version}-%{release}
    Obsoletes: python-setuptools < %{version}-%{release}

    $ rpm --eval '%python_provide python39-setuptools'

    $ rpm --define 'python3_pkgversion 39' --eval '%python_provide python%{python3_pkgversion}-setuptools'

To make the implementation of %python_provide easier,
any names starting with "python" or "pypy" are recognized as valid arguments.

Previously, this was an ERROR:

    $ rpm --eval '%python_provide pythonista'
    %python_provide: ERROR: pythonista not recognized.

Now it is a no-op. The behavior was never documented and the change is
backwards compatible for working spec files.
This commit is contained in:
Miro Hrončok 2020-03-23 12:17:38 +01:00
commit 1b3e731dc6
3 changed files with 39 additions and 17 deletions

View file

@ -52,11 +52,29 @@
end
package = rpm.expand("%{?1}")
vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}")
if (string.starts(package, "python2-")) then
--No unversioned provides as python2 is not default
elseif (string.starts(package, "python" .. rpm.expand("%{python3_pkgversion}") .. "-")) then
if (string.starts(package, "python3-")) then
print("\\nProvides: python-")
l = 8 + string.len(rpm.expand("%{python3_pkgversion}"))
print(string.sub(package,9,string.len(package)))
print(" = ")
print(vr)
print("\\nProvides: python" .. rpm.expand("%{__default_python3_pkgversion}") .. "-")
print(string.sub(package,9,string.len(package)))
print(" = ")
print(vr)
--Obsoleting the previous default python package (if it doesn't have isa)
if (string.sub(package, "-1") ~= ")") then
print("\\nObsoletes: python-")
print(string.sub(package,9,string.len(package)))
print(" < ")
print(vr)
end
elseif (string.starts(package, "python" .. rpm.expand("%{__default_python3_pkgversion}") .. "-")) then
print("\\nProvides: python-")
l = 8 + string.len(rpm.expand("%{__default_python3_pkgversion}"))
print(string.sub(package,l,string.len(package)))
print(" = ")
print(vr)
print("\\nProvides: python3-")
print(string.sub(package,l,string.len(package)))
print(" = ")
print(vr)
@ -67,16 +85,10 @@
print(" < ")
print(vr)
end
elseif (rpm.expand("%{?python3_other_pkgversion}") ~= "" and string.starts(package, "python" .. rpm.expand("%{python3_other_pkgversion}") .. "-")) then
--No unversioned provides as python3_other is not default
elseif (string.starts(package, "pypy-")) then
--No unversioned provides as pypy is not default
elseif (string.starts(package, "pypy2-")) then
--No unversioned provides as pypy is not default
elseif (string.starts(package, "pypy3-")) then
--No unversioned provides as pypy is not default
elseif (string.starts(package, "python-")) then
--No unversioned provides needed for unversioned python
elseif (string.starts(package, "python")) then
--No unversioned provides as other python3 cases are not the default
elseif (string.starts(package, "pypy")) then
--No unversioned provides as pypy is not default either
else
print("%python_provide: ERROR: ")
print(package)