File vaultwarden.spec of Package vaultwarden
#
# spec file for package vaultwarden
#
# 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/
#
%global pkg_name vaultwarden
%global services %{pkg_name}.service
%if 0%{?suse_version} >= 1599
%bcond_without mimalloc
%else
%bcond_with mimalloc
%endif
%if 0%{?suse_version}
%bcond_without apparmor
%else
%bcond_with apparmor
%endif
Name: %{pkg_name}
Version: 1.34.3
Release: 0
Summary: Unofficial Bitwarden compatible server written in Rust
License: GPL-3.0-only
URL: https://github.com/dani-garcia/vaultwarden
Source0: %{pkg_name}-%{version}.tar.xz
Source1: vendor.tar.xz
Source3: %{pkg_name}.sysusers
Source10: %{pkg_name}.service
Source11: %{pkg_name}.logrotate
Source12: %{pkg_name}.apparmor
Source100: %{pkg_name}.cfg
%if %{with apparmor}
BuildRequires: apparmor-abstractions
BuildRequires: apparmor-rpm-macros
%endif
BuildRequires: git
BuildRequires: pkgconfig
BuildRequires: cargo >= 1.81
BuildRequires: rust >= 1.81
BuildRequires: cargo-packaging
BuildRequires: sed
BuildRequires: sysuser-shadow
BuildRequires: sysuser-tools
BuildRequires: pkgconfig(libpq)
BuildRequires: pkgconfig(libpqxx)
%if %{with mimalloc}
BuildRequires: pkgconfig(mimalloc)
%endif
BuildRequires: (pkgconfig(mysqlclient) or pkgconfig(libmariadb))
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(systemd)
Recommends: %{pkg_name}-web-vault
Suggests: logrotate
Conflicts: bitwarden
Conflicts: bitwarden-rs
Provides: bitwarden
Provides: bitwarden-rs = %{version}-%{release}
Obsoletes: bitwarden-rs < %{version}-%{release}
%{?systemd_ordering}
%{?sysusers_requires}
%description
Alternative implementation of the Bitwarden server API written in Rust and
compatible with upstream Bitwarden clients, perfect for self-hosted deployment
where running the official resource-heavy service might not be ideal.
%prep
%autosetup -p1 -a 1
cp %{SOURCE10} .
%build
%{cargo_build} --features=sqlite,mysql,postgresql,enable_mimalloc,s3
%sysusers_generate_pre %{SOURCE3} %{pkg_name} %{pkg_name}.conf
%install
install -m 755 -d \
%{buildroot}%{_bindir} \
%{buildroot}%{_sbindir}
install -m 750 -d \
%{buildroot}%{_sharedstatedir}/%{pkg_name} \
%{buildroot}%{_localstatedir}/log/%{pkg_name} \
%{buildroot}%{_sysconfdir}/%{pkg_name}
install -D -m 750 target/release/%{pkg_name} %{buildroot}%{_bindir}/%{pkg_name}
install -D -m 644 -t %{buildroot}%{_unitdir}/ %{services}
install -D -m 644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{pkg_name}.conf
install -D -m 644 %{SOURCE11} %{buildroot}%{_sysconfdir}/logrotate.d/%{pkg_name}
install -D -m 640 %{SOURCE100} %{buildroot}%{_sysconfdir}/%{pkg_name}/%{pkg_name}.cfg
%if %{with apparmor}
install -D -m 0644 %{SOURCE12} %{buildroot}%{_sysconfdir}/apparmor.d/%{pkg_name}
%endif
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{pkg_name}
%pre -f %{pkg_name}.pre
%service_add_pre %{services}
%preun
%service_del_preun %{services}
%post
%service_add_post %{services}
%postun
%if %{with apparmor}
%apparmor_reload %{_sysconfdir}/apparmor.d/%{pkg_name}
%endif
%service_del_postun %{services}
%files
%{_unitdir}/%{services}
%{_sysusersdir}/%{pkg_name}.conf
%{_sbindir}/rc%{pkg_name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{pkg_name}
%config(noreplace) %attr(-,root,%{pkg_name}) %{_sysconfdir}/%{pkg_name}/
#
%attr(750,root,%{pkg_name}) %{_bindir}/%{pkg_name}
#
%dir %attr(750,%{pkg_name},%{pkg_name}) %{_sharedstatedir}/%{pkg_name}/
%dir %attr(750,%{pkg_name},%{pkg_name}) %{_localstatedir}/log/%{pkg_name}/
#
%if %{with apparmor}
%config %{_sysconfdir}/apparmor.d/%{pkg_name}
%config(noreplace) %ghost %{_sysconfdir}/apparmor.d/local/%{pkg_name}
%endif
%changelog