File pi-topd.spec of Package pi-topd

#
# spec file for package pi-topd
#
# Copyright (c) 2023 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 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/
#


Name:           pi-topd
Version:        5.6.0
Release:        0
Summary:        Daemon for managing pi-top functionality
License:        Apache-2.0
Group:          System/Management
URL:            https://github.com/pi-top/pi-topd
Source0:        https://github.com/pi-top/pi-topd/archive/v%{version}-1.tar.gz#/%{name}-%{version}.tar.gz
Patch0:         pi-topd-setup.cfg.patch
BuildRequires:  %{python_module setuptools}
BuildRequires:  fdupes
BuildRequires:  python-rpm-generators
BuildRequires:  python-rpm-macros
Requires:       pi-topd-service
Requires:       python-click
Requires:       python-click-logging
Requires:       python-gpiozero
Requires:       python-pitop
Requires:       python-pyee
Requires:       python-pyzmq
Requires:       python-smbus2
Requires:       python-spidev
Requires:       python-systemd
Requires(post): update-alternatives
Requires(postun): update-alternatives
Recommends:     alsa-utils
Recommends:     libnotify-tools
Recommends:     raspi-config
Recommends:     xprintidle
Provides:       pi-topd = %{version}.py%{python_version}-%{release}
BuildArch:      noarch
%{?systemd_requires}
%python_subpackages

%description
This application runs as a background process in order to receive state/event information from pi-top hardware and manage the system configuration in order to provide plug-and-play functionality. It also provides an interface for getting information from the hub without requiring any knowledge of the hub's internal register interface.

This package is needed by all pi-top devices in order for them to work properly.

%prep
%autosetup -p1 -n %{name}-%{version}-1
sed -i -e 's/,<.*//' setup.cfg

%build
%python_build

%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}

%python_clone -a %{buildroot}%{_bindir}/pi-topd
%python_clone -a %{buildroot}%{_bindir}/pt-poweroff
%python_clone -a %{buildroot}%{_bindir}/pt-reboot

install -m 644 -D -t %{buildroot}%{_datadir}/lightdm/lightdm.conf.d debian/extra/pt-xhost-local-root.conf
install -m 644 -D -t %{buildroot}%{_prefix}/lib/systemd/system debian/pi-topd.service debian/pt-reboot.service debian/pt-poweroff.service

%post
%python_install_alternative pi-topd pt-poweroff pt-reboot

%postun
%python_uninstall_alternative pi-topd pt-poweroff pt-reboot

%package -n %{name}-service
Summary:        Service files for managing pi-top functionality
Requires:       xhost

%description -n %{name}-service
Systemd services for managing pi-top hardware.

%pre  -n %{name}-service
%service_add_pre pi-topd.service pt-reboot.service pt-poweroff.service

%post  -n %{name}-service
%service_add_post pi-topd.service pt-reboot.service pt-poweroff.service

%preun  -n %{name}-service
%service_del_preun pi-topd.service pt-reboot.service pt-poweroff.service

%postun  -n %{name}-service
%service_del_postun pi-topd.service pt-reboot.service pt-poweroff.service

%files %{python_files}
%license debian/copyright
%doc README.rst docs
%python_alternative %{_bindir}/pi-topd
%python_alternative %{_bindir}/pt-poweroff
%python_alternative %{_bindir}/pt-reboot
%{python_sitelib}/pitopd*

%files -n %{name}-service
%dir %{_datadir}/lightdm
%dir %{_datadir}/lightdm/lightdm.conf.d
%{_datadir}/lightdm/lightdm.conf.d/pt-xhost-local-root.conf
%{_prefix}/lib/systemd/system/pi-topd.service
%{_prefix}/lib/systemd/system/pt-reboot.service
%{_prefix}/lib/systemd/system/pt-poweroff.service

%changelog
openSUSE Build Service is sponsored by