File stalwart.spec of Package stalwart
#
# spec file for package stalwart
#
# Copyright (c) 2025 SUSE LLC and contributors
#
# 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 pkg_home %{_localstatedir}/lib/%{name}
Name: stalwart
Version: 0.14.0
Release: 0
Summary: Secure, scalable mail & collaboration server
License: AGPL-3.0-only
URL: https://stalw.art/
Source0: https://github.com/stalwartlabs/stalwart/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1: vendor.tar.zst
BuildRequires: cargo-packaging
#BuildRequires: libclang13
#BuildRequires: libstdc++-devel
BuildRequires: clang
BuildRequires: gcc-c++
BuildRequires: python3
BuildRequires: rust >= 1.74
BuildRequires: systemd-rpm-macros
Provides: group(%{name})
Provides: user(%{name})
%description
All-in-one Mail & Collaboration server.
It supports a number of protocols, including
IMAP, JMAP, SMTP, CalDAV, CardDAV, WebDAV.
%prep
%autosetup -a1
# this removes all proprietary code that is not under AGPL-3.0-only
python3 resources/scripts/ossify.py crates
sed -i -e 's|__PATH__%{_sysconfdir}/config|%{_sysconfdir}/stalwart/config|g' -e 's|__PATH__|/usr|g' resources/systemd/stalwart-mail.service
sed -e 's|\(\[Service\]\)|\1\nEnvironment=STALWART_PATH=%{pkg_home}|' resources/systemd/stalwart-mail.service
%build
%{cargo_build} -p stalwart --no-default-features --features 'sqlite postgres mysql rocks elastic s3 redis azure nats'
%install
install -Dm755 -t %{buildroot}%{_bindir} target/release/stalwart
install -Dm644 -t %{buildroot}%{_sysconfdir}/stalwart resources/config/config.toml
install -Dm644 -t %{buildroot}%{_unitdir} resources/systemd/stalwart-mail.service
%pre
%{_sbindir}/groupadd -r %{name} >/dev/null 2>&1 ||:
%{_sbindir}/useradd -g %{name} -s /bin/false -r -c "user for %{name}" -d %{pkg_home} %{name} >/dev/null 2>&1 ||:
%service_add_pre stalwart-mail.service
%post
%service_add_post stalwart-mail.service
%preun
%service_del_preun stalwart-mail.service
%postun
%service_del_postun stalwart-mail.service
%files
%license LICENSES/AGPL-3.0-only.txt
%doc README.md
%{_bindir}/stalwart
%{_unitdir}/stalwart-mail.service
%{_sysconfdir}/stalwart
%config %{_sysconfdir}/stalwart/config.toml
%changelog