File heisenbridge.spec of Package heisenbridge

#
# spec file for package heisenbridge
#
# Copyright (c) 2021 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/
#

%define use_python %{primary_python}

%define services %{name}.service
%define homedir /var/lib/heisenbridge

Name:           heisenbridge
Version:        1.14.6
Release:        0
Summary:        A bouncer-style Matrix IRC bridge
License:        MIT
Url:            https://github.com/hifi/heisenbridge
Source:         https://github.com/hifi/heisenbridge/releases/download/v%{version}/heisenbridge-%{version}.tar.gz
Source1:        heisenbridge-user.conf
Source2:        heisenbridge.service
Source3:        heisenbridge.sysconfig
Source4:        heisenbridge.apparmor
Source99:       series
BuildArch:      noarch
BuildRequires:  apparmor-abstractions
BuildRequires:  apparmor-rpm-macros
BuildRequires:  sysuser-shadow
BuildRequires:  sysuser-tools
BuildRequires:  pkgconfig(systemd)
BuildRequires:  %{use_python}-setuptools
BuildRequires:  %{use_python}-base >= 3.9
BuildRequires:  (%{use_python}-aiohttp >= 3.8.0       with %{use_python}-aiohttp < 4.0)
BuildRequires:  (%{use_python}-irc >= 19.0.0          with %{use_python}-irc < 20.4)
BuildRequires:  (%{use_python}-ruamel.yaml >= 0.15.35 with %{use_python}-ruamel.yaml < 0.18)
BuildRequires:  (%{use_python}-mautrix >= 0.16.0      with %{use_python}-mautrix < 0.21)
BuildRequires:  (%{use_python}-python-socks >= 1.2.4)
%requires_eq    %{use_python}-base
%requires_eq    %{use_python}-aiohttp
%requires_eq    %{use_python}-irc
%requires_eq    %{use_python}-ruamel.yaml
%requires_eq    %{use_python}-mautrix
%requires_eq    %{use_python}-python-socks
Requires(post): fillup

%{systemd_ordering}
%{sysusers_requires}
%description
Heisenbridge brings IRC to Matrix by creating an environment where every user connects
to each network individually like they would with a traditional IRC bouncer.
Simplicity is achieved by exposing IRC in the most straightforward way as possible
where it makes sense so it feels familiar for long time IRC users.

%prep
%autosetup -p1

%build
%python3_build
%sysusers_generate_pre %{SOURCE1} %{name}

%install
%python3_install
install -D -d -m 0750 %{buildroot}%{_sysconfdir}/%{name}
install -D -m 0644 %{SOURCE1} %{buildroot}%{_sysusersdir}/%{name}.conf
install -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service
install -D -m 0644 %{SOURCE3} %{buildroot}%{_fillupdir}/sysconfig.%{name}
install -D -m 0644 %{SOURCE4} %{buildroot}/etc/apparmor.d/%{name}

install -D -m 0750 -d         %{buildroot}%{homedir}

%pre -f %{name}.pre
%service_add_pre %{services}

%post
%fillup_only %{name}
%service_add_post %{services}

%preun
%service_del_preun %{services}

%postun
%apparmor_reload /etc/apparmor.d/%{name}
%service_del_postun %{services}

%files
%doc README.md
%license LICENSE
%config(noreplace) %attr(-,root,%{name}) %{_sysconfdir}/%{name}/
%ghost %config(noreplace) %attr(0640,root,%{name}) %{_sysconfdir}/%{name}/registration.yaml
%{_bindir}/%{name}
%{python3_sitelib}/%{name}-%{version}*egg*
%{python3_sitelib}/%{name}
%{_sysusersdir}/%{name}.conf
%{_unitdir}/%{name}.service
%config /etc/apparmor.d/%{name}
%ghost %config(noreplace) /etc/apparmor.d/local/%{name}
%{_fillupdir}/sysconfig.%{name}
%dir %attr(-,%{name},%{name}) %{homedir}/

%changelog
openSUSE Build Service is sponsored by