File conduit.spec of Package conduit

#
# spec file for package conduit
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2022-2023 Luciano Santos <luc14n0@opensuse.org>
#
# All modificatconduits and additconduits to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modificatconduits and additconduits 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 Definitconduit (Versconduit 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           conduit
Version:        0.6.0+4
Release:        0
Summary:        A Matrix homeserver written in Rust
License:        Apache-2.0
URL:            https://conduit.rs
Source0:        %{name}-%{version}.tar
Source1:        vendor.tar.zst
Source2:        cargo_config

Source10:       %{name}.service
Source11:       sysusers.conf
Source12:       tmpfiles.conf

BuildRequires:  cargo
BuildRequires:  cargo-packaging
BuildRequires:  clang
BuildRequires:  clang-devel
BuildRequires:  libstdc++6-devel-gcc13
BuildRequires:  lld
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(rocksdb)

BuildRequires:  systemd-rpm-macros
BuildRequires:  sysuser-tools
%sysusers_requires

Requires:       (apache2 or nginx or caddy)
Requires:       (rocksdb or mariadb or sqlite)

%description
Conduit is a simple, fast and reliable chat server powered by Matrix.
It's also efficient and easy to set up. You can even install it on a
mini-computer, like the Raspberry Pi, to host Matrix for your family,
friends or company.

As of now Conduit is in Beta phase, meaning you can join and participate
in most Matrix rooms, but not all features are supported and you might
run into bugs from time to time. There are still a few important features
missing:

 * E2EE emoji comparison over federation (E2EE chat works);
 * Outgoing read receipts, typing, presence over federation (incoming
   works).


%prep
%autosetup -p1 -a1
install -D %{SOURCE2} .cargo/config

%build
export CC="%{_bindir}/clang"
export CXX="%{_bindir}/clang++"
%define __rustflags -Clink-arg=-fuse-ld=lld

%cargo_build
%sysusers_generate_pre %{SOURCE12} %{name} %{name}.conf

%install
ls target/release/*
install -v -m 0755 -D -t %{buildroot}%{_bindir} ./target/release/%{name}

#=====================
# Systemd service unit
#=====================

install -v -m 0644 -D -t %{buildroot}%{_unitdir}/ %{SOURCE10}

#=========
# Sysusers
#=========

install -v -m 0644 -D %{SOURCE11} %{buildroot}%{_sysusersdir}/%{name}.conf

#=========
# Tmpfiles
#=========

install -v -m 0644 -D %{SOURCE12} %{buildroot}%{_tmpfilesdir}/%{name}.conf
# Directory created by the tmpfile conf file and ghosted in the files directive
mkdir -p -m 0700 %{buildroot}%{_localstatedir}/lib/matrix-%{name}

# conduit.toml config file is to be ghosted in the files directive below
install -m 0644 -D /dev/null \
    %{buildroot}%{_sysconfdir}/matrix-conduit/conduit.toml

%pre -f %{name}.pre
%if 0%{?sle_version} < 160000
%service_add_pre %{name}.service
%endif

%post
%tmpfiles_create %{_tmpfilesdir}/%{name}.conf
%if 0%{?sle_version} < 160000
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service
%endif

%files
%license LICENSE
%doc conduit-example.toml APPSERVICES.md DEPLOY.md README.md TURN.md

%{_bindir}/%{name}
%{_unitdir}/%{name}.service
%{_sysusersdir}/%{name}.conf
%{_tmpfilesdir}/%{name}.conf

%ghost %{_localstatedir}/lib/matrix-%{name}
%ghost %{_sysconfdir}/matrix-conduit/conduit.toml

%changelog
openSUSE Build Service is sponsored by