File matrix-dendrite.spec of Package matrix-dendrite
#
# spec file for package matrix-dendrite
#
# Copyright (c) 2022 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: matrix-dendrite
Version: 0.15.2+git.0.e546df2e
Release: 0
Summary: Dendrite is a second-generation Matrix homeserver written in Go
License: AGPL-3.0-only
Group: Productivity/Networking/Instant Messenger
URL: https://matrix-org.github.io/dendrite/
Source0: %{name}-%{version}.tar.gz
Source1: vendor.tar.gz
Source2: %{name}.service
Source3: %{name}.sysusers
Source4: README.SUSE
BuildRequires: golang(API) >= 1.22
BuildRequires: sysuser-tools
%sysusers_requires
Recommends: postgresql-server
Recommends: nginx
%description
Dendrite is a second-generation Matrix homeserver written in Go! Following the
microservice architecture model, Dendrite is designed to be efficient, reliable
and scalable. Despite being beta, many Matrix features are already supported.
%prep
%autosetup -a1
%build
export GOFLAGS="$GOFLAGS -buildmode=pie -mod=vendor"
for BINARY in create-account dendrite furl generate-config generate-keys resolve-state
do
go build -trimpath -ldflags "-s -w" -o "bin/" -v "./cmd/${BINARY}/..."
done
%sysusers_generate_pre %{SOURCE3} %{name}
%install
install -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf
#Binaries
install -d %{buildroot}%{_sbindir}
install -D bin/create-account %{buildroot}%{_sbindir}/%{name}-create-account
install -D bin/dendrite %{buildroot}%{_sbindir}/%{name}
install -D bin/furl %{buildroot}%{_sbindir}/%{name}-furl
install -D bin/generate-config %{buildroot}%{_sbindir}/%{name}-generate-config
install -D bin/generate-keys %{buildroot}%{_sbindir}/%{name}-generate-keys
install -D bin/resolve-state %{buildroot}%{_sbindir}/%{name}-resolve-state
#Config
install -d %{buildroot}%{_sysconfdir}/%{name}
sed -i 's|storage_path: .\/|storage_path: %{_localstatedir}/lib\/%{name}|g' dendrite-sample.yaml
sed -i 's|base_path: .\/media_store|base_path: %{_localstatedir}/lib\/%{name}\/media_store|g' dendrite-sample.yaml
sed -i 's|index_path: ".\/searchindex"|index_path: %{_localstatedir}/lib\/%{name}\/searchindex|g' dendrite-sample.yaml
sed -i 's|path: .\/logs|path: %{_localstatedir}\/log\/%{name}|g' dendrite-sample.yaml
install -D -m 0660 dendrite-sample.yaml %{buildroot}%{_sysconfdir}/%{name}/dendrite-sample.yaml
#Logdir
install -d %{buildroot}%{_localstatedir}/log/%{name}
#Storage
install -d %{buildroot}%{_localstatedir}/lib/%{name}
#Units
install -d -m 755 %{buildroot}%{_unitdir}
install -m 444 %{SOURCE2} %{buildroot}%{_unitdir}
#Docs
install -d %{buildroot}%{_docdir}/%{name}
cp -r docs %{buildroot}%{_docdir}/%{name}/
cp %{SOURCE4} .
%pre -f %{name}.pre
%service_add_pre %{name}.service
%post
%service_add_post %{name}.service
%preun
%service_del_preun %{name}.service
%postun
%service_del_postun %{name}.service
%files
%license LICENSE
%doc CHANGES.md README.md README.SUSE
%{_sbindir}/%{name}*
%{_unitdir}/%{name}*
%{_sysusersdir}/%{name}.conf
%dir %{_sysconfdir}/%{name}
%config %{_sysconfdir}/%{name}/dendrite-sample.yaml
%{_docdir}/%{name}
%attr(750,dendrite,dendrite) %{_localstatedir}/log/%{name}
%attr(750,dendrite,dendrite) %{_localstatedir}/lib/%{name}
%changelog