File shutdown-daemon.spec of Package shutdown-daemon

#
# spec file for package shutdown-daemon
#
# Copyright (c) 2022 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#

Name:           shutdown-daemon
Version:        0
Release:        0
Summary:        Shutdown Daemon
License:        GPL-3.0-or-later
Group:          Productivity/Other
Url:            https://gitlab.com/etherlab.org/shutdown-daemon
Source:         shutdown-daemon-%{version}.tar.bz2
BuildArch:      noarch

%{?systemd_requires}

%define skip_python2 1
BuildRequires:  python-rpm-macros
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes

Requires(post):   update-alternatives
Requires(postun):  update-alternatives
Requires:       shutdown-daemon-data
Requires:       python-pdcom5 >= 5.2.0

# https://en.opensuse.org/openSUSE:Packaging_Python
# If your packages are targeted for anything older than Leap 15, the spec file
# must include a redefinition of the python_module macro.
%{?!python_module:%define python_module() python-%{**} python3-%{**}}

%python_subpackages

%description
A simple python service that uses PdCom 5 to listen to a process variable
change and issues a system command (i. e. poweroff).

%package -n shutdown-daemon-data
Group:          Productivity/Other
Summary:        Shutdown Daemon

%description -n shutdown-daemon-data
A simple python service that uses PdCom 5 to listen to a process variable
change and issues a system command (i. e. poweroff).
This package contains the service file.


%prep
%setup -q -n shutdown-daemon-%{version}

%build
%python_build

%install
%python_install
%python_clone -a %{buildroot}%{_bindir}/shutdown_daemon.py
install -d ${RPM_BUILD_ROOT}%{_unitdir}
install -m 644 shutdown-daemon.service ${RPM_BUILD_ROOT}%{_unitdir}
%python_expand %fdupes %{buildroot}%{$python_sitelib}

%pre -n shutdown-daemon-data
%service_add_pre shutdown-daemon.service

%post -n shutdown-daemon-data
%service_add_post shutdown-daemon.service

%post
%python_install_alternative shutdown_daemon.py

%preun -n shutdown-daemon-data
%service_del_preun shutdown-daemon.service

%postun -n shutdown-daemon-data
%service_del_postun shutdown-daemon.service

%postun
%python_uninstall_alternative shutdown_daemon.py

%files %{python_files}
%python_alternative %{_bindir}/shutdown_daemon.py
%{python_sitelib}/shutdown_daemon-*-info
%if 0%{?suse_version} >= 1600
%{python_sitelib}/shutdown_daemon.py
%pycache_only %{python_sitelib}/__pycache__/
%endif

%files -n shutdown-daemon-data
%{_unitdir}/shutdown-daemon.service

%changelog
openSUSE Build Service is sponsored by