File matrix-sliding-sync.spec of Package matrix-sliding-sync
#
# Copyright (c) 2023 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 mod_name sliding-sync
%define home_dir /var/lib/matrix-sliding-sync
%define user_group _matrix-sliding-sync
%define config_dir /etc/matrix-sliding-sync
Name: matrix-sliding-sync
Version: 0.99.16
Release: 0
Summary: Matrix Sliding Sync Proxy
License: Apache-2.0
URL: https://github.com/matrix-org/sliding-sync
Source: https://github.com/matrix-org/sliding-sync/archive/refs/tags/v%{version}.tar.gz#/%{mod_name}-%{version}.tar.gz
Source1: vendor.tar.xz
Source2: matrix-sliding-sync.sysusers
Source3: matrix-sliding-sync.config
Source4: matrix-sliding-sync.service
Source5: matrix-sliding-sync.apparmor
BuildRequires: golang(API) >= 1.20
BuildRequires: golang-packaging
BuildRequires: pkgconfig(systemd)
BuildRequires: sysuser-shadow
BuildRequires: sysuser-tools
BuildRequires: apparmor-profiles
BuildRequires: apparmor-rpm-macros
%{?go_nostrip}
%{?sysusers_requires}
%{?systemd_ordering}
%description
Run a sliding sync proxy. An implementation of MSC3575.
%prep
%autosetup -p1 -n %{mod_name}-%{version} -a 1
%build
go build -mod=vendor -buildmode=pie -o sliding-sync-proxy ./cmd/syncv3/
%sysusers_generate_pre %{SOURCE2} %{name} %{name}.conf
%install
install -D -m 0755 -t %{buildroot}%{_sbindir} sliding-sync-proxy
install -D -m 0644 %{SOURCE2} %{buildroot}%{_sysusersdir}/%{name}.conf
install -D -m 0644 %{SOURCE4} %{buildroot}%{_unitdir}/matrix-sliding-sync.service
install -D -m 0750 -d %{buildroot}%{config_dir}
install -D -m 0640 %{SOURCE3} %{buildroot}%{config_dir}/config
install -D -m 0750 -d %{buildroot}%{home_dir}
install -D -m 0644 %{SOURCE5} %{buildroot}/etc/apparmor.d/%{name}
%pre -f %{name}.pre
%service_add_pre matrix-sliding-sync.service
%preun
%service_del_preun matrix-sliding-sync.service
%post
%apparmor_reload /etc/apparmor.d/%{name}
%service_add_post matrix-sliding-sync.service
%postun
%service_del_postun matrix-sliding-sync.service
%files
%license LICENSE
%doc README.md
%config(noreplace) %attr(-,root,root) %{config_dir}
%dir %attr(-,%{user_group},%{user_group}) %{home_dir}
%{_sbindir}/sliding-sync-proxy
%{_sysusersdir}/%{name}.conf
%{_unitdir}/matrix-sliding-sync.service
/etc/apparmor.d/%{name}
%changelog