File ServerStatus-Rust.spec of Package ServerStatus-Rust
#
# spec file for package ServerStatus-Rust
#
# Copyright (c) 2024 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 pkgname serverstatus-rust
Name: ServerStatus-Rust
Version: 1.8.1~git.20240420
Release: 0
Summary: Rust version of ServerStatus
License: Apache-2.0
URL: https://github.com/zdz/ServerStatus-Rust
Source: %{name}-%{version}.tar.xz
Source1: vendor.tar.xz
Patch0: path.patch
BuildRequires: rust
BuildRequires: cargo
BuildRequires: gcc-c++
BuildRequires: libopenssl-devel
Provides: %{pkgname}
%description
Rust version of ServerStatus.
%package server
Summary: Server package for %{name}
Provides: %{name}-server = %{version}-%{release}
Provides: %{pkgname}-server = %{version}-%{release}
Requires: %{name} = %{version}
%description server
Server file of ServerStatus: stat_server
%package client
Summary: Client package for %{name}
Provides: %{name}-client = %{version}-%{release}
Provides: %{pkgname}-client = %{version}-%{release}
Requires: %{name} = %{version}
Recommends: vnstat
%description client
Server file of ServerStatus: stat_client
%package web
Summary: Web resource package for %{name}
Provides: %{name}-web = %{version}-%{release}
Provides: %{pkgname}-web = %{version}-%{release}
Requires: %{name} = %{version}
BuildArch: noarch
%description web
Web resource file of ServerStatus
%prep
%setup -q -a1
%autopatch -p1
mkdir cargo-home
cat >cargo-home/config <<EOF
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"
EOF
%build
export CARGO_HOME=$PWD/cargo-home
cargo build --release %{?_smp_mflags}
%install
install -Dm 0755 target/release/stat_client %{buildroot}%{_bindir}/stat_client
install -Dm 0755 target/release/stat_server %{buildroot}%{_bindir}/stat_server
install -d %{buildroot}%{_unitdir}
install -m0644 systemd/stat_client.service %{buildroot}%{_unitdir}/
install -m0644 systemd/stat_server.service %{buildroot}%{_unitdir}/
install -d %{buildroot}%{_sbindir}
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcstat_client
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcstat_server
install -d %{buildroot}%{_sysconfdir}/serverstatus
install -m0644 config.toml %{buildroot}%{_sysconfdir}/serverstatus/
install -d %{buildroot}%{_sharedstatedir}/serverstatus
install -d %{buildroot}/srv/www/htdocs
cp -r web %{buildroot}/srv/www/htdocs/serverstatus
%pre
%service_add_pre stat_client.service stat_server.service
%post
%service_add_post stat_client.service stat_server.service
%postun
%service_del_preun stat_client.service stat_server.service
%files
%license LICENSE
%doc README.md
%files server
%{_bindir}/stat_server
%{_sbindir}/rcstat_server
%{_unitdir}/stat_server.service
%dir %{_sysconfdir}/serverstatus
%config(noreplace) %{_sysconfdir}/serverstatus/config.toml
%dir %{_sharedstatedir}/serverstatus
%files client
%{_bindir}/stat_client
%{_sbindir}/rcstat_client
%{_unitdir}/stat_client.service
%dir %{_sharedstatedir}/serverstatus
%files web
%dir /srv/www
%dir /srv/www/htdocs
/srv/www/htdocs/serverstatus
%changelog