File ecasbot.spec of Package ecasbot

#
# spec file for package ecasbot
#
# 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/
#


Name:           ecasbot
Version:        1.5.2
Release:        0
Summary:        EC AntiSpam bot
License:        GPL-3.0-only
Group:          Productivity/Networking/Other
Url:            https://github.com/xvitaly/ecasbot
Source:         https://github.com/xvitaly/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
BuildRequires:  fdupes
BuildRequires:  doxygen
BuildRequires:  python3-devel
BuildRequires:  python3-requests
BuildRequires:  python3-setuptools
BuildRequires:  python3-six
BuildRequires:  python3-emoji
BuildRequires:  python3-pytelegrambotapi
Requires:       logrotate
%{?systemd_requires}
BuildArch: noarch


%description
EC AntiSpam bot for Telegram messenger will block all multimedia messages and links from new users, some common spam bots and users who added them to super-groups.

%prep
%autosetup
sed -e 's@"logtofile": "",@"logtofile": "%{_localstatedir}/log/%{name}/%{name}.log",@g' -i config/%{name}.json

%build
doxygen
%py3_build

%install
%py3_install

mkdir -p %{buildroot}%{_sysconfdir}/%{name}
mkdir -p %{buildroot}%{_localstatedir}/log
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
mkdir -p %{buildroot}%{_unitdir}
install -p -m 0644 config/%{name}.json %{buildroot}%{_sysconfdir}/%{name}
install -p -m 0644 config/%{name}-env.conf %{buildroot}%{_sysconfdir}/%{name}
install -p -m 0644 config/%{name}.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
install -p -m 0644 config/%{name}.service %{buildroot}%{_unitdir}
install -d -m 0755 %{buildroot}%{_localstatedir}/log/%{name}

%fdupes %{buildroot}%{python3_sitelib}/%{name}

%check
%{__python3} setup.py test

%pre
getent group %{name} >/dev/null || groupadd -r %{name}
getent passwd %{name} >/dev/null || \
useradd -r -g %{name} -d /dev/null -s /sbin/nologin \
  -c "%{name} service account" %{name}
exit 0
%service_add_pre %{name}.service

%post
%service_add_post %{name}.service

%preun
%systemd_preun %{name}.service

%postun
%systemd_postun_with_restart %{name}.service

%files
%license LICENSE
%doc README.md doxyout/html
%{_bindir}/%{name}
%{python3_sitelib}/%{name}
%{python3_sitelib}/%{name}-*.egg-info
%dir %{_sysconfdir}/%{name}
%attr(-,%{name},%{name}) %config(noreplace) %{_sysconfdir}/%{name}/*.json
%config(noreplace) %{_sysconfdir}/%{name}/*.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%dir %{_localstatedir}/log/%{name}
%ghost %{_localstatedir}/log/%{name}/*.log*
%{_unitdir}/%{name}.service

%changelog

openSUSE Build Service is sponsored by