From 575f3764a72ac890183a4b7b4f242e4c0414ad72 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Fri, 1 Jul 2016 16:44:21 +0200 Subject: [PATCH] SPEC: Rename python packages using macro %python_provide Fedora and epel contains macro %python_provide for simpler renaming of python packages. It will generate correct provides and obsoletes. --- contrib/sssd.spec.in | 86 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 20 deletions(-) diff --git a/contrib/sssd.spec.in b/contrib/sssd.spec.in index 2b0d4e3e3f145a90dad2870fc74cea8989923888..69f0115b8a5db636a663b1050a392945e1929664 100644 --- a/contrib/sssd.spec.in +++ b/contrib/sssd.spec.in @@ -11,6 +11,42 @@ %{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} %endif +%{!?python_provide: %global need_python_provide 1} +%if 0%{?need_python_provide} +%define python_provide() %{lua:\ + function string.starts(String,Start)\ + return string.sub(String,1,string.len(Start))==Start\ + end\ + package = rpm.expand("%{?1:%{1}}");\ + vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}") + if (string.starts(package, "python2-")) then\ + if (rpm.expand("%{?buildarch}") ~= "noarch") then\ + str = "Provides: python-" .. string.sub(package,9,string.len(package)) .. "%{?_isa} = " .. vr;\ + print(rpm.expand(str));\ + end\ + print("\\nProvides: python-");\ + print(string.sub(package,9,string.len(package)));\ + print(" = ");\ + print(vr);\ + --Obsoleting the previous default python package\ + if (rpm.expand("%{?buildarch}") ~= "noarch") then\ + str = "\\nObsoletes: python-" .. string.sub(package,9,string.len(package)) .. "%{?_isa} < " .. vr;\ + print(rpm.expand(str));\ + end\ + print("\\nObsoletes: python-");\ + print(string.sub(package,9,string.len(package)));\ + print(" < ");\ + print(vr);\ + elseif (string.starts(package, "python3-")) then\ + --No unversioned provides as python3 is not default\ + else\ + print("%python_provide: ERROR: ");\ + print(package);\ + print(" not recognized.");\ + end\ +} +%endif + # Fedora and RHEL 6+ # we don't want to provide private python extension libs %define __provides_exclude_from %{python2_sitearch}/.*\.so$ @@ -95,7 +131,7 @@ Requires: sssd-proxy = %{version}-%{release} %if (0%{?with_python3} == 1) Requires: python3-sssdconfig = %{version}-%{release} %else -Requires: python-sssdconfig = %{version}-%{release} +Requires: python2-sssdconfig = %{version}-%{release} %endif %global servicename sssd @@ -252,8 +288,8 @@ Requires: sssd-common = %{version}-%{release} Requires: python3-sss = %{version}-%{release} Requires: python3-sssdconfig = %{version}-%{release} %else -Requires: python-sss = %{version}-%{release} -Requires: python-sssdconfig = %{version}-%{release} +Requires: python2-sss = %{version}-%{release} +Requires: python2-sssdconfig = %{version}-%{release} %endif %description tools @@ -266,13 +302,14 @@ Also provides several other administrative tools: * sss_obfuscate for generating an obfuscated LDAP password * sssctl -- an sssd status and control utility -%package -n python-sssdconfig +%package -n python2-sssdconfig Summary: SSSD and IPA configuration file manipulation classes and functions Group: Applications/System License: GPLv3+ BuildArch: noarch +%python_provide python2-sssdconfig -%description -n python-sssdconfig +%description -n python2-sssdconfig Provides python2 files for manipulation SSSD and IPA configuration files. %if (0%{?with_python3} == 1) @@ -281,18 +318,20 @@ Summary: SSSD and IPA configuration file manipulation classes and functions Group: Applications/System License: GPLv3+ BuildArch: noarch +%python_provide python3-sssdconfig %description -n python3-sssdconfig Provides python3 files for manipulation SSSD and IPA configuration files. %endif -%package -n python-sss +%package -n python2-sss Summary: Python2 bindings for sssd Group: Development/Libraries License: LGPLv3+ Requires: sssd-common = %{version}-%{release} +%python_provide python2-sss -%description -n python-sss +%description -n python2-sss Provides python2 module for manipulating users, groups, and nested groups in SSSD when using id_provider = local in /etc/sssd/sssd.conf. @@ -306,6 +345,7 @@ Summary: Python3 bindings for sssd Group: Development/Libraries License: LGPLv3+ Requires: sssd-common = %{version}-%{release} +%python_provide python3-sss %description -n python3-sss Provides python3 module for manipulating users, groups, and nested groups in @@ -316,12 +356,13 @@ Also provides several other useful python3 bindings: * class for obfuscation of passwords %endif -%package -n python-sss-murmur +%package -n python2-sss-murmur Summary: Python2 bindings for murmur hash function Group: Development/Libraries License: LGPLv3+ +%python_provide python2-sss-murmur -%description -n python-sss-murmur +%description -n python2-sss-murmur Provides python2 module for calculating the murmur hash version 3 %if (0%{?with_python3} == 1) @@ -329,6 +370,7 @@ Provides python2 module for calculating the murmur hash version 3 Summary: Python3 bindings for murmur hash function Group: Development/Libraries License: LGPLv3+ +%python_provide python3-sss-murmur %description -n python3-sss-murmur Provides python3 module for calculating the murmur hash version 3 @@ -458,16 +500,17 @@ Requires: libipa_hbac = %{version}-%{release} %description -n libipa_hbac-devel Utility library to validate FreeIPA HBAC rules for authorization requests -%package -n python-libipa_hbac +%package -n python2-libipa_hbac Summary: Python2 bindings for the FreeIPA HBAC Evaluator library Group: Development/Libraries License: LGPLv3+ Requires: libipa_hbac = %{version}-%{release} Provides: libipa_hbac-python = %{version}-%{release} Obsoletes: libipa_hbac-python < 1.12.90 +%python_provide python2-libipa_hbac -%description -n python-libipa_hbac -The python-libipa_hbac contains the bindings so that libipa_hbac can be +%description -n python2-libipa_hbac +The python2-libipa_hbac contains the bindings so that libipa_hbac can be used by Python applications. %if (0%{?with_python3} == 1) @@ -476,6 +519,7 @@ Summary: Python3 bindings for the FreeIPA HBAC Evaluator library Group: Development/Libraries License: LGPLv3+ Requires: libipa_hbac = %{version}-%{release} +%python_provide python3-libipa_hbac %description -n python3-libipa_hbac The python3-libipa_hbac contains the bindings so that libipa_hbac can be @@ -501,16 +545,17 @@ Requires: libsss_nss_idmap = %{version}-%{release} %description -n libsss_nss_idmap-devel Utility library for SID and certificate based lookups -%package -n python-libsss_nss_idmap +%package -n python2-libsss_nss_idmap Summary: Python2 bindings for libsss_nss_idmap Group: Development/Libraries License: LGPLv3+ Requires: libsss_nss_idmap = %{version}-%{release} Provides: libsss_nss_idmap-python = %{version}-%{release} Obsoletes: libsss_nss_idmap-python < 1.12.90 +%python_provide python2-libsss_nss_idmap -%description -n python-libsss_nss_idmap -The python-libsss_nss_idmap contains the bindings so that libsss_nss_idmap can +%description -n python2-libsss_nss_idmap +The python2-libsss_nss_idmap contains the bindings so that libsss_nss_idmap can be used by Python applications. %if (0%{?with_python3} == 1) @@ -519,6 +564,7 @@ Summary: Python3 bindings for libsss_nss_idmap Group: Development/Libraries License: LGPLv3+ Requires: libsss_nss_idmap = %{version}-%{release} +%python_provide python3-libsss_nss_idmap %description -n python3-libsss_nss_idmap The python3-libsss_nss_idmap contains the bindings so that libsss_nss_idmap can @@ -960,7 +1006,7 @@ done %{_mandir}/man8/sss_debuglevel.8* %{_mandir}/man8/sss_seed.8* -%files -n python-sssdconfig -f python2_sssdconfig.lang +%files -n python2-sssdconfig -f python2_sssdconfig.lang %defattr(-,root,root,-) %dir %{python2_sitelib}/SSSDConfig %{python2_sitelib}/SSSDConfig/*.py* @@ -974,7 +1020,7 @@ done %{python3_sitelib}/SSSDConfig/__pycache__/*.py* %endif -%files -n python-sss +%files -n python2-sss %defattr(-,root,root,-) %{python2_sitearch}/pysss.so @@ -984,7 +1030,7 @@ done %{python3_sitearch}/pysss.so %endif -%files -n python-sss-murmur +%files -n python2-sss-murmur %defattr(-,root,root,-) %{python2_sitearch}/pysss_murmur.so @@ -1030,7 +1076,7 @@ done %{_libdir}/libsss_nss_idmap.so %{_libdir}/pkgconfig/sss_nss_idmap.pc -%files -n python-libsss_nss_idmap +%files -n python2-libsss_nss_idmap %defattr(-,root,root,-) %{python2_sitearch}/pysss_nss_idmap.so @@ -1040,7 +1086,7 @@ done %{python3_sitearch}/pysss_nss_idmap.so %endif -%files -n python-libipa_hbac +%files -n python2-libipa_hbac %defattr(-,root,root,-) %{python2_sitearch}/pyhbac.so -- 2.7.4