File python-meshtastic2hass.spec of Package python-meshtastic2hass
#
# spec file for package python-meshtastic2hass
#
# Copyright (c) 2019 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/
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define pythons %primary_python
%global username meshtastic
%global groupname meshtastic
%global homedir /var/lib/meshtastic
Name: python-meshtastic2hass
Version: 1.0.20
Release: 0
License: GPLv3
Summary: A Python client for use with Meshtastic devices
Url: https://github.com/Mictronics/meshtastic2hass
Group: Development/Languages/Python
Source0: https://files.pythonhosted.org/packages/source/m/meshtastic2hass/meshtastic2hass-%{version}.tar.gz
Source1: meshtastic2hass.service
Source2: meshtastic2hass.sysconf
BuildRequires: python-rpm-macros
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module poetry-core}
BuildRequires: %{python_module importlib-metadata >= 4.6.4}
BuildRequires: %{python_module meshtastic >= 2.3.14}
BuildRequires: %{python_module paho-mqtt >= 2.1.0}
BuildRequires: %{python_module tomlkit >= 0.13.0}
Requires: python-globals >= 0.3.36
Requires: python-importlib-metadata >= 4.6.4
Requires: python-meshtastic >= 2.3.14
Requires: python-paho-mqtt >= 2.1.0
#Requires: python-pubsub >= 0.1.2
Requires: python-tomlkit >= 0.13.0
BuildRequires: fdupes
Requires(post): update-alternatives
Requires(postun): update-alternatives
Requires(pre): shadow
Provides: group(%{groupname})
Provides: user(%{username})
BuildArch: noarch
%python_subpackages
%description
%prep
%setup -q -n meshtastic2hass-%{version}
%build
%pyproject_wheel
%install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%python_clone -a %{buildroot}%{_bindir}/meshtastic2hass
mkdir -p '%{buildroot}'%{_sbindir}
ln -sf service '%{buildroot}'%{_sbindir}/rcmeshtastic2hass
install -D -m 644 %{SOURCE1} '%{buildroot}'%{_unitdir}/meshtastic2hass.service
install -D -m 0644 %{SOURCE2} %{buildroot}%{_fillupdir}/sysconfig.meshtastic2hass
mkdir -p %buildroot%homedir
%post
%{python_install_alternative meshtastic2hass}
%service_add_post meshtastic2hass.service
%fillup_only -n meshtastic2hass
%postun
%{python_uninstall_alternative meshtastic2hass}
%service_del_postun meshtastic2hass.service
%pre
getent group %{groupname} >/dev/null || groupadd -r %{groupname}
getent passwd %{username} >/dev/null || \
useradd -r -g %{groupname} -d %{homedir} -s /sbin/nologin \
-c 'Meshtastic User' %{username}
%service_add_pre whisper.service
%preun
%service_del_preun meshtastic2hass.service
%files %{python_files}
%doc README.md
%python_alternative %{_bindir}/meshtastic2hass
%{python_sitelib}/*
%{_fillupdir}/sysconfig.meshtastic2hass
%_unitdir/meshtastic2hass.service
%_sbindir/rcmeshtastic2hass
%dir %attr(0755,%username,%groupname) %homedir
%changelog