diff --git a/i2c-tools.spec b/i2c-tools.spec index d2ff75e..58a3d8a 100644 --- a/i2c-tools.spec +++ b/i2c-tools.spec @@ -4,9 +4,15 @@ # This file and all modifications and additions to the pristine # package are under the same license as the package itself. +%if 0%{?rhel} > 7 || 0%{?fedora} > 28 +%bcond_with python2 +%else +%bcond_without python2 +%endif + Name: i2c-tools Version: 4.0 -Release: 4%{?dist} +Release: 5%{?dist} Summary: A heterogeneous set of I2C tools for Linux License: GPLv2+ URL: https://i2c.wiki.kernel.org/index.php/I2C_Tools @@ -21,7 +27,10 @@ Patch2: 0003-py-smbus-Fix-FSF-address-in-smbusmodule.c.patch # for /etc/udev/makedev.d resp /etc/modprobe.d ownership Requires: udev module-init-tools BuildRequires: perl-generators -BuildRequires: python2-devel python3-devel +%if %{with python2} +BuildRequires: python2-devel +%endif +BuildRequires: python3-devel BuildRequires: gcc ExcludeArch: s390 s390x @@ -42,6 +51,7 @@ eeproms in your system is very dangerous and is likely to render your system unusable. Do not install, let alone use this, unless you really, _really_ know what you are doing. +%if %{with python2} %package -n python2-i2c-tools %{?python_provide:%python_provide python2-i2c-tools} # Remove before F30 @@ -52,9 +62,16 @@ Summary: Python 2 bindings for Linux SMBus access through i2c-dev %description -n python2-i2c-tools Python 2 bindings for Linux SMBus access through i2c-dev +%endif %package -n python3-i2c-tools %{?python_provide:%python_provide python3-i2c-tools} +%if %{without python2} +# Remove before F30 +Obsoletes: %{name}-python < 4.0-4 +# Remove before F31 +Obsoletes: python2-i2c-tools < 4.0-5 +%endif Summary: Python 3 bindings for Linux SMBus access through i2c-dev %description -n python3-i2c-tools @@ -96,8 +113,10 @@ pushd eepromer make CFLAGS="$RPM_OPT_FLAGS -I../include" LDFLAGS="$RPM_LD_FLAGS" popd pushd py-smbus +%if %{with python2} CFLAGS="$RPM_OPT_FLAGS -I../include" LDFLAGS="$RPM_LD_FLAGS" \ %{__python2} setup.py build -b build-py2 +%endif CFLAGS="$RPM_OPT_FLAGS -I../include" LDFLAGS="$RPM_LD_FLAGS" \ %{__python3} setup.py build -b build-py3 popd @@ -111,7 +130,9 @@ install -m 755 eepromer/{eepromer,eeprom} \ install -m 644 eepromer/{eepromer,eeprom}.8 \ $RPM_BUILD_ROOT%{_mandir}/man8 pushd py-smbus +%if %{with python2} %{__python2} setup.py build -b build-py2 install --skip-build --root=$RPM_BUILD_ROOT +%endif %{__python3} setup.py build -b build-py3 install --skip-build --root=$RPM_BUILD_ROOT popd # cleanup @@ -163,9 +184,11 @@ exit 0 %{_sbindir}/eepro* %{_mandir}/man8/eepro*.8.gz +%if %{with python2} %files -n python2-i2c-tools %doc py-smbus/README %{python2_sitearch}/* +%endif %files -n python3-i2c-tools %doc py-smbus/README @@ -189,6 +212,9 @@ exit 0 %changelog +* Thu Mar 22 2018 Ondřej Lysoněk - 4.0-5 +- Don't build Python 2 subpackage on EL > 7 and Fedora > 28 + * Mon Feb 19 2018 Ondřej Lysoněk - 4.0-4 - Add gcc to BuildRequires