File evemu.spec of Package failed_evemu
#
# spec file for package evemu
#
# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license for the pristine package is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
# Let the distro decide if py2 support is still valid. TW disables it
%bcond_without python2
%define soname libevemu
%define sover 3
Name: evemu
Version: 2.7.0
Release: 0
Summary: Input Event Device Emulation Library
License: GPL-3.0-only
Group: Hardware/Other
URL: https://freedesktop.org/wiki/Evemu
Source: https://freedesktop.org/software/%{name}/%{name}-%{version}.tar.xz
Source1: https://freedesktop.org/software/%{name}/%{name}-%{version}.tar.xz.sig
Source2: %{name}.keyring
BuildRequires: asciidoc
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: pkgconfig
%if %{with python2}
BuildRequires: python2-devel
%endif
BuildRequires: python3-devel
BuildRequires: xmlto
BuildRequires: pkgconfig(libevdev) >= 1.2.99.902
Provides: %{name}-tools = %{version}
Obsoletes: %{name}-tools < %{version}
%description
The evemu library and tools are used to describe devices, record
data, create emulation devices and replay data from kernel evdev
(input event) devices.
%package -n %{soname}%{sover}
Summary: Input Event Device Emulation Library
Group: System/Libraries
%description -n %{soname}%{sover}
The evemu library and tools are used to describe devices, record
data, create emulation devices and replay data from kernel evdev
(input event) devices.
%package -n python2-%{name}
Summary: Python2 bindings for evemu
Group: Development/Languages/Python
Requires: %{soname}%{sover} = %{version}
# python-evemu was last used in openSUSE Leap 42.3.
Provides: python-%{name} = %{version}-%{release}
Obsoletes: python-%{name} < %{version}-%{release}
%description -n python2-%{name}
The evemu library and tools are used to describe devices, record
data, create emulation devices and replay data from kernel evdev
(input event) devices.
This package provides the Python2 bindings for evemu.
%package -n python3-%{name}
Summary: Python3 bindings for evemu
Group: Development/Languages/Python
Requires: %{soname}%{sover} = %{version}
%description -n python3-%{name}
The evemu library and tools are used to describe devices, record
data, create emulation devices and replay data from kernel evdev
(input event) devices.
This package provides the Python3 bindings for evemu.
%package devel
Summary: Development files for evemu
Group: Development/Tools/Other
Requires: %{name} = %{version}
Requires: %{soname}%{sover} = %{version}
%description devel
The evemu library and tools are used to describe devices, record
data, create emulation devices and replay data from kernel evdev
(input event) devices.
This package provides the development files.
%prep
%autosetup
evdev_sover="$(basename "$(readlink -f %{_libdir}/libevdev.so)")"
sed -i \
-e 's|"%{soname}.so"|"%{soname}.so.%{sover}"|' \
-e "s|\"libevdev.so\"|\"$evdev_sover\"|" \
python/%{name}/{base,const}.py
# Provide a lightweight compatibility 'imp' module for Python3 installs
# Some older Makefile install scripts still import 'imp' which was removed
# in newer Python versions. Create a shim so "import imp" succeeds during
# the build/install of the python modules.
cat > python/imp.py <<'PYIMP_SHIM'
"""Compatibility shim for the deprecated 'imp' module using importlib.
This provides the small subset of the imp API used by the package's
installation scripts (find_module, load_module, new_module).
"""
import importlib.util
import importlib.machinery
import sys
import types
__all__ = ["find_module", "load_module", "new_module"]
def find_module(name, path=None):
spec = None
if path is None:
spec = importlib.util.find_spec(name)
else:
spec = importlib.machinery.PathFinder.find_spec(name, path)
if spec is None:
raise ImportError(name)
loader = spec.loader
origin = spec.origin
description = None
if getattr(spec, 'submodule_search_locations', None):
description = (None, None, 'pkg')
return loader, origin, description
def load_module(name, file, pathname=None, description=None):
if pathname is None:
raise ImportError(name)
spec = importlib.util.spec_from_file_location(name, pathname)
if spec is None or spec.loader is None:
raise ImportError(name)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
sys.modules[name] = module
return module
def new_module(name):
mod = types.ModuleType(name)
sys.modules[name] = mod
return mod
PYIMP_SHIM
%build
%global _configure ../configure
%if %{with python2}
PYTHONS=python2
%endif
PYTHONS="$PYTHONS python3"
for py in $PYTHONS; do
export PYTHON=$py
mkdir -p build-$py
pushd build-$py
# Ensure an 'imp' shim is present in the build python directory so
# the Makefile's install helper (which does "import imp") can import it
# even on Python versions that removed the stdlib 'imp' module.
mkdir -p python
cat > python/imp.py <<'PYIMP_SHIM'
import importlib.util
import importlib.machinery
import sys
import types
__all__ = ["find_module", "load_module", "new_module"]
def find_module(name, path=None):
spec = None
if path is None:
spec = importlib.util.find_spec(name)
else:
spec = importlib.machinery.PathFinder.find_spec(name, path)
if spec is None:
raise ImportError(name)
loader = spec.loader
origin = spec.origin
description = None
if getattr(spec, 'submodule_search_locations', None):
description = (None, None, 'pkg')
return loader, origin, description
def load_module(name, file, pathname=None, description=None):
if pathname is None:
raise ImportError(name)
spec = importlib.util.spec_from_file_location(name, pathname)
if spec is None or spec.loader is None:
raise ImportError(name)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
sys.modules[name] = module
return module
def new_module(name):
mod = types.ModuleType(name)
sys.modules[name] = mod
return mod
PYIMP_SHIM
%configure \
--disable-static \
--disable-silent-rules \
--disable-tests
make %{?_smp_mflags}
popd
done
%install
%if %{with python2}
%make_install -C build-python2
%endif
%make_install -C build-python3
find %{buildroot} -type f -name "*.la" -delete -print
# Remove useless "optimised" Python byte-code.
rm -f %{buildroot}%{python_sitelib}/%{name}/*.pyo \
%{buildroot}%{python3_sitelib}/%{name}/__pycache__/*.opt-?.pyc
%fdupes %{buildroot}%{_bindir}/
%fdupes %{buildroot}%{_mandir}/
%if %{with python2}
%fdupes %{buildroot}%{python2_sitelib}
%endif
%post -n %{soname}%{sover} -p /sbin/ldconfig
%postun -n %{soname}%{sover} -p /sbin/ldconfig
%files
%license COPYING
%{_bindir}/%{name}-*
%{_mandir}/man?/%{name}-*?%{?ext_man}
%files -n %{soname}%{sover}
%license COPYING
%{_libdir}/%{soname}.so.%{sover}*
%if %{with python2}
%files -n python2-%{name}
%license COPYING
%{python2_sitelib}/%{name}/
%endif
%files -n python3-%{name}
%license COPYING
%{python3_sitelib}/%{name}/
%files devel
%{_includedir}/%{name}.h
%{_libdir}/%{soname}.so
%{_libdir}/pkgconfig/%{name}.pc
%changelog