Blame input-remapper.spec

c0d9288
Name:           input-remapper
d372c97
Version:        2.0.1
c0d9288
Release:        %autorelease
c0d9288
Summary:        An easy to use tool to change the behaviour of your input devices
c0d9288
c0d9288
License:        GPL-3.0-or-later
c0d9288
URL:            https://github.com/sezanzeb/%{name}
52895a4
Source0:        %{url}/archive/%{version}/%{name}-%{version}.tar.gz
c0d9288
Source1:        README.Fedora
c0d9288
BuildArch:      noarch
c0d9288
c0d9288
BuildRequires:  desktop-file-utils
c0d9288
BuildRequires:  libappstream-glib
c0d9288
BuildRequires:  pyproject-rpm-macros
c0d9288
BuildRequires:  systemd-rpm-macros
c0d9288
BuildRequires:  python3-devel
c0d9288
BuildRequires:  python3-setuptools
c0d9288
BuildRequires:  python3-wheel
c0d9288
BuildRequires:  gettext
e05c503
e05c503
# Called from inputremapper/gui/reader_service.py
e05c503
BuildRequires:  /usr/bin/pgrep
e05c503
Requires:       /usr/bin/pgrep
e05c503
56e8991
# inputremapper/gui/components/editor.py
56e8991
BuildRequires:  %{py3_dist pycairo}
56e8991
Requires:       %{py3_dist pycairo}
56e8991
02a705d
# Extra test dependencies (see scripts/ci-install-deps.sh):
02a705d
BuildRequires:  %{py3_dist psutil}
02a705d
75df120
# Using pytest as the test runner lets us ignore modules and skip tests
75df120
BuildRequires:  %{py3_dist pytest}
75df120
d23e545
BuildRequires:  gobject-introspection
d23e545
Requires:       gobject-introspection
d23e545
# Grep for require_version to find these:
d23e545
# gi.require_version("Gdk", "3.0")
d23e545
# gi.require_version("Gtk", "3.0")
d23e545
BuildRequires:  gtk3
d23e545
Requires:       gtk3
d23e545
# gi.require_version("GLib", "2.0")
d23e545
BuildRequires:  glib2
d23e545
Requires:       glib2
d23e545
# gi.require_version("GtkSource", "4")
d23e545
BuildRequires:  gtksourceview4
c0d9288
Requires:       gtksourceview4
c0d9288
c0d9288
%generate_buildrequires
c0d9288
%pyproject_buildrequires -r
c0d9288
c0d9288
c0d9288
%description
c0d9288
An easy to use tool to change the mapping of your input device buttons. 
c0d9288
Supports mice, keyboards, gamepads, X11, Wayland, combined buttons and 
c0d9288
programmable macros. Allows mapping non-keyboard events (click, joystick, 
c0d9288
wheel) to keys of keyboard devices.
c0d9288
The program works at the evdev interface level, by filtering and redirecting 
c0d9288
the output of physical devices to that of virtual ones.
c0d9288
c0d9288
c0d9288
%prep
c0d9288
%autosetup -p1 -n %{name}-%{version}
c0d9288
cp %{SOURCE1} ./
c0d9288
#Fix rpmlint errors
c0d9288
#find inputremapper/ -iname "*.py" -type f -print0 | xargs -0 sed -i -e 's+\s*#\s*!/usr/bin/python3++'
c0d9288
c0d9288
c0d9288
%build
c0d9288
%pyproject_wheel
c0d9288
c0d9288
c0d9288
%install
c0d9288
%pyproject_install
c0d9288
%pyproject_save_files inputremapper
c0d9288
mv %{buildroot}%{python3_sitelib}/etc %{buildroot}/etc
c0d9288
mv %{buildroot}%{python3_sitelib}/usr/bin %{buildroot}/usr/bin
c0d9288
mv %{buildroot}%{python3_sitelib}/usr/lib/systemd %{buildroot}/usr/lib/systemd
c0d9288
mv %{buildroot}%{python3_sitelib}/usr/lib/udev %{buildroot}/usr/lib/udev
c0d9288
mv %{buildroot}%{python3_sitelib}/usr/share %{buildroot}/usr/share
c0d9288
mkdir -p %{buildroot}/usr/share/dbus-1/system.d/
c0d9288
mv %{buildroot}/etc/dbus-1/system.d/inputremapper.Control.conf %{buildroot}/usr/share/dbus-1/system.d/
c0d9288
c0d9288
# clean up duplicate files
c0d9288
rm %{buildroot}%{_datadir}/%{name}/inputremapper.Control.conf
c0d9288
rm %{buildroot}%{_datadir}/%{name}/io.github.sezanzeb.input_remapper.metainfo.xml
c0d9288
rm %{buildroot}%{_datadir}/%{name}/%{name}-gtk.desktop
c0d9288
rm %{buildroot}%{_datadir}/%{name}/%{name}.policy
c0d9288
c0d9288
c0d9288
%post -n %{name}
c0d9288
%systemd_post %{name}.service
c0d9288
c0d9288
c0d9288
%preun -n %{name}
c0d9288
%systemd_preun %{name}.service
c0d9288
c0d9288
c0d9288
%postun -n %{name}
c0d9288
%systemd_postun_with_restart %{name}.service
c0d9288
c0d9288
c0d9288
%check
c0d9288
desktop-file-validate %{buildroot}/%{_datadir}/applications/%{name}-gtk.desktop
c0d9288
appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/*.metainfo.xml
c0d9288
dbd1e6f
# See .github/workflows/test.yml
99519b5
# Note that setting TMPDIR="${PWD}/test_tmp" tends to form paths that are too
99519b5
# long for UNIX domain sockets, causing test failures, so we just use the
99519b5
# default temporary directory.
75df120
export DATA_DIR='%{buildroot}%{_datadir}/%{name}'
dbd1e6f
dbd1e6f
# Make sure everything is at least importable:
dbd1e6f
%pyproject_check_import
dbd1e6f
dbd1e6f
# Run the unit tests.
75df120
75df120
# Upstream would run them like this...
75df120
#   PYTHONPATH='%%{buildroot}%%{python3_sitelib}' PYTHONDONTWRITEBYTECODE=1 \
75df120
#       %%{python3} tests/test.py --start-dir unit || :
75df120
# ... but using pytest allows us to ignore modules and skip tests easily.
75df120
75df120
# E   gi.repository.GLib.GError: g-io-error-quark: Could not connect: No such
75df120
#     file or directory (1)
75df120
ignore="${ignore-} --ignore=tests/unit/test_daemon.py"
75df120
# These tests only work when executed under a user whose home directory
75df120
# (based on the passwd entry, not on $HOME) begins with /tmp. Obviously, we
75df120
# can’t satisfy that, and we need to skip the affected tests.
75df120
ignore="${ignore-} --ignore=tests/unit/test_migrations.py"
75df120
75df120
# TODO: What is wrong?
75df120
# E       AssertionError: Lists differ: [<Inp[37 chars]x7f3a2f82e6f0>,
75df120
#         <InputEvent for (3, 1, 16384) [131 chars]b10>] != [
75df120
#         chars]x7f3a3254b770>, <InputEvent for (3, 1, 16384) [235 chars]8f0>]
75df120
# E
75df120
# E       Second list contains 2 additional elements.
75df120
# E       First extra element 4:
75df120
# E       <InputEvent for (3, 0, 0) ABS_X at 0x7f3a2f82e360>
75df120
# E
75df120
# E       Diff is 1044 characters long. Set self.maxDiff to None to see it.
75df120
k="${k-}${k+ and }not (TestRelToAbs and test_rel_to_abs)"
75df120
75df120
# This seems to fail only in Koji, not in mock…
75df120
# >       self.assertAlmostEqual(len(mouse_history), rel_rate * sleep * 2, delta=5)
75df120
# E       AssertionError: 51 != 60.0 within 5 delta (9.0 difference)
75df120
k="${k-}${k+ and }not (TestAbsToRel and test_abs_to_rel)"
75df120
75df120
# These tests are based on timing/sleeps, and seem to experience flaky and/or
75df120
# arch-dependent failures in koji. The failures generally appear to be
75df120
# noisy/spurious.
75df120
#
75df120
k="${k-}${k+ and }not (TestIdk and test_axis_switch)"
75df120
# >       self.assertAlmostEqual(len(mouse_history), rel_rate * sleep, delta=3)
75df120
# E       AssertionError: 26 != 30.0 within 3 delta (4.0 difference)
75df120
# >       self.assertLess(time.time() - start, sleep_time * 1.3)
75df120
# E       AssertionError: 0.5397047996520996 not less than 0.52
75df120
k="${k-}${k+ and }not (TestMacros and test_2)"
75df120
# >       self.assertLess(time.time() - start, total_time * 1.2)
75df120
# E       AssertionError: 0.44843482971191406 not less than 0.432
75df120
k="${k-}${k+ and }not (TestMacros and test_3)"
75df120
# >       self.assertLess(time.time() - start, total_time * 1.2)
75df120
# E       AssertionError: 0.511094331741333 not less than 0.48
75df120
k="${k-}${k+ and }not (TestMacros and test_5)"
75df120
#         # this seems to have a tendency of injecting less wheel events,
75df120
#         # especially if the sleep is short
75df120
# >       self.assertGreater(actual_wheel_event_count, expected_wheel_event_count * 0.8)
75df120
# E       AssertionError: 2 not greater than 2.4000000000000004
75df120
k="${k-}${k+ and }not (TestMacros and test_mouse)"
75df120
75df120
%pytest tests/unit ${ignore-} -k "${k-}" -v
dbd1e6f
c0d9288
c0d9288
%files -f %{pyproject_files}
c0d9288
%doc README.md README.Fedora
c0d9288
%license LICENSE
c0d9288
%{_datadir}/dbus-1/system.d/inputremapper.Control.conf
c0d9288
%{_sysconfdir}/xdg/autostart/%{name}-autoload.desktop
c0d9288
%{_bindir}/%{name}*
c0d9288
%{_unitdir}/%{name}.service
c0d9288
%{_udevrulesdir}/99-%{name}.rules
c0d9288
%{_datadir}/%{name}
e56c85b
e56c85b
# deal with non-standard location of localization files
e56c85b
%exclude %dir %{_datadir}/%{name}/lang
e56c85b
%lang(fr) %{_datadir}/%{name}/lang/fr
e56c85b
%lang(fr) %{_datadir}/%{name}/lang/fr_FR
e56c85b
%lang(it) %{_datadir}/%{name}/lang/it
e56c85b
%lang(it) %{_datadir}/%{name}/lang/it_IT
d372c97
%lang(pt) %{_datadir}/%{name}/lang/pt
d372c97
%lang(pt) %{_datadir}/%{name}/lang/pt_BR
e56c85b
%lang(ru) %{_datadir}/%{name}/lang/ru
e56c85b
%lang(ru) %{_datadir}/%{name}/lang/ru_RU
e56c85b
%lang(sk) %{_datadir}/%{name}/lang/sk
e56c85b
%lang(sk) %{_datadir}/%{name}/lang/sk_SK
e56c85b
%lang(uk) %{_datadir}/%{name}/lang/uk
e56c85b
%lang(uk) %{_datadir}/%{name}/lang/uk_UA
e56c85b
%lang(zh) %{_datadir}/%{name}/lang/zh
e56c85b
%lang(zh) %{_datadir}/%{name}/lang/zh_CN
e56c85b
c0d9288
%{_datadir}/applications/%{name}-gtk.desktop
c0d9288
%{_datadir}/polkit-1/actions/%{name}.policy
c0d9288
%{_metainfodir}/*.metainfo.xml
c0d9288
c0d9288
c0d9288
%changelog
c0d9288
%autochangelog