File python-mautrix-telegram.spec of Package python-mautrix-telegram

#
# spec file for package python-mautrix-telegram
#
# Copyright (c) 2024 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:           python-mautrix-telegram
Version:        0.15.3
Release:        0
Summary:        Matrix-Telegram puppeting/relaybot bridge
License:        AGPL-3.0-only
URL:            https://github.com/mautrix/telegram
Source0:        telegram-%{version}.tar.gz
Source1:        mautrix-telegram.service
Source2:        mautrix-telegram.sysuser
Patch0:         no-scm-version.patch
BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module wheel}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  sed
Requires:       python-aiohttp >= 3
Requires:       python-asyncpg >= 0.20
Requires:       python-commonmark >= 0.8
Requires:       python-mako >= 1
Requires:       python-mautrix >= 0.20.8
Requires:       python-python-magic >= 0.4
Requires:       python-ruamel.yaml >= 0.15.35
Requires:       python-tulir-telethon >= 1.99.0a6
Requires:       python-yarl >= 1
Requires(post): update-alternatives
Requires(postun): update-alternatives
Suggests:       python-olm >= 3
Suggests:       python-pycryptodome >= 3
Suggests:       python-unpaddedbase64 >= 1
BuildArch:      noarch

%package -n system-user-mautrix-telegram
Summary:        System user and group for mautrix-telegram
BuildRequires:  sysuser-tools
%sysusers_requires

%package -n mautrix-telegram-server
Summary:        Matrix-Telegram puppeting/relaybot bridge service
BuildRequires:  systemd-rpm-macros
Requires:       %{python_flavor}-mautrix-telegram = %{version}
Requires:       group(mautrix-telegram)
Requires:       user(mautrix-telegram)
%python_subpackages

%description
A Matrix-Telegram hybrid puppeting/relaybot bridge.

%description -n system-user-mautrix-telegram
System user and group for the mautrix-telegram service.

%description -n mautrix-telegram-server
A Matrix-Telegram hybrid puppeting/relaybot bridge server.

%prep
%autosetup -p1 -n telegram-%{version}

sed -i \
  -e 's|\(\s*(\)"\.",\s*\[\s*"mautrix_telegram/example-config\.yaml"\s*\]\s*)|        ("%{_sysconfdir}/mautrix-telegram", ["mautrix_telegram/example-config.yaml"])|' \
  -e s/__VERSION__/%{version}/ \
  setup.py

%build
%python_build
%sysusers_generate_pre %{SOURCE2} mautrix-telegram system-user-mautrix-telegram.conf

%install
install -dm 771    %{buildroot}%{_sysconfdir}/mautrix-telegram
install -dm 771    %{buildroot}%{_localstatedir}/log/mautrix-telegram

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

install -Dm 0644 %{SOURCE1} %{buildroot}%{_unitdir}/mautrix-telegram.service
install -Dm 0644 %{SOURCE2} %{buildroot}%{_sysusersdir}/system-user-mautrix-telegram.conf

%pre -n system-user-mautrix-telegram -f mautrix-telegram.pre

%pre -n mautrix-telegram-server
%service_add_pre mautrix-telegram.service

%post -n mautrix-telegram-server
%service_add_post mautrix-telegram.service

%preun -n mautrix-telegram-server
%service_del_preun mautrix-telegram.service

%postun -n mautrix-telegram-server
%service_del_postun mautrix-telegram.service

%files -n system-user-mautrix-telegram
%{_sysusersdir}/system-user-mautrix-telegram.conf

%files -n mautrix-telegram-server
%dir %{_sysconfdir}/mautrix-telegram/
%config %{_sysconfdir}/mautrix-telegram/example-config.yaml
%dir %attr(744, mautrix-telegram, mautrix-telegram) %{_localstatedir}/log/mautrix-telegram
%{_unitdir}/mautrix-telegram.service

%files %{python_files}
%license LICENSE
%doc README.md
%{python_sitelib}/mautrix_telegram
%{python_sitelib}/mautrix_telegram-%{version}-py%{python_version}.egg-info

%changelog
openSUSE Build Service is sponsored by