## START: Set by rpmautospec
## (rpmautospec version 0.3.5)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# Generated by rust2rpm 25
# The tests assumes workspace
%bcond_with check

%global crate crypto-auditing-agent

Name:           rust-crypto-auditing-agent
Version:        0.2.0
Release:        %autorelease
Summary:        Event collector agent for crypto-auditing project

License:        GPL-3.0-or-later
URL:            https://crates.io/crates/crypto-auditing-agent
Source:         %{crates_source}
Source1:        agent.conf
Source2:        crypto-auditing-agent.service
Source3:	crypto-auditing.sysusers

BuildRequires:  cargo-rpm-macros >= 24
BuildRequires:  libbpf-devel
BuildRequires:  systemd-rpm-macros
%{?sysusers_requires_compat}

%global _description %{expand:
Event collector agent for crypto-auditing project.}

%description %{_description}

%package     -n %{crate}
Summary:        %{summary}
# Upstream license specification: GPL-3.0-or-later
#
# The build dependencies have the following licenses:
#
#   (MIT OR Apache-2.0) AND Unicode-DFS-2016
#   Apache-2.0
#   Apache-2.0 OR MIT
#   BSD-2-Clause
#   BSD-3-Clause OR MIT OR Apache-2.0
#   GPL-3.0-or-later
#   LGPL-2.1-only OR BSD-2-Clause
#   MIT
#   MIT OR Apache-2.0
#   Unlicense OR MIT
#
License:        GPL-3.0-or-later
# LICENSE.dependencies contains a full license breakdown

%description -n %{crate} %{_description}

%files       -n %{crate}
%license LICENSE
%license LICENSE.BSD-2-Clause
%license LICENSE.GPL-2.0
%license LICENSE.LGPL-2.1
%license LICENSE.dependencies
%{_bindir}/crypto-auditing-agent
%attr(0755,root,root) %dir %{_sysconfdir}/crypto-auditing
%config(noreplace) %{_sysconfdir}/crypto-auditing/agent.conf
%{_unitdir}/crypto-auditing-agent.service
%{_sysusersdir}/crypto-auditing.conf
%attr(0755,crypto-auditing,crypto-auditing) %dir %{_localstatedir}/log/crypto-auditing

%prep
%autosetup -n %{crate}-%{version} -p1
%cargo_prep

%generate_buildrequires
%cargo_generate_buildrequires

%build
%cargo_build
%{cargo_license_summary}
%{cargo_license} > LICENSE.dependencies

%install
%cargo_install

mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/crypto-auditing
install -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/crypto-auditing

mkdir -p $RPM_BUILD_ROOT%{_unitdir}
install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_unitdir}

mkdir -p $RPM_BUILD_ROOT%{_sysusersdir}
install -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysusersdir}/crypto-auditing.conf

mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log/crypto-auditing

%if %{with check}
%check
%cargo_test
%endif

%pre -n %{crate}
%sysusers_create_compat %{SOURCE3}

%post -n %{crate}
%systemd_post crypto-auditing-agent.service

%preun -n %{crate}
%systemd_preun crypto-auditing-agent.service

%postun -n %{crate}
%systemd_postun_with_restart crypto-auditing-agent.service

%changelog
* Mon Nov 20 2023 John Doe <packager@example.com> - 0.2.0-1
- Uncommitted changes