rust-rd-agent/rust-rd-agent.spec
Benjamin A. Beasley dd5a0ac0e4 Allow procfs 0.18
2026-01-05 10:01:36 +00:00

157 lines
4.3 KiB
RPMSpec

# Generated by rust2rpm 28
%bcond check 1
%global crate rd-agent
%global selinuxtype targeted
%bcond selinux 1
Name: rust-rd-agent
Version: 2.2.5
Release: %autorelease
Summary: Management agent for resctl-demo
License: Apache-2.0
URL: https://crates.io/crates/rd-agent
Source: %{crates_source}
# Used as a data file by rd-agent for the compile sideload
Source: https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.8.11.tar.xz
# Manually created patch for downstream crate metadata changes
# * bump enum-iterator to 2.0
# * allow procfs 0.17,
# https://github.com/facebookexperimental/resctl-demo/pull/326, and 0.18,
# https://github.com/facebookexperimental/resctl-demo/pull/335
Patch: rd-agent-fix-metadata.diff
# https://github.com/facebookexperimental/resctl-demo/commit/f65eedf9017332255ef0a48649664c26b45b9c07
Patch: rd-agent-enum-iterator.patch
# SELinux policy
Source10: %{crate}.fc
Source11: %{crate}.if
Source12: %{crate}.te
BuildRequires: cargo-rpm-macros >= 24
%if %{with selinux}
BuildRequires: selinux-policy-devel
%endif
%global _description %{expand:
Management agent for resctl-demo.}
%description %{_description}
%package -n %{crate}
Summary: %{summary}
# (MIT OR Apache-2.0) AND Unicode-DFS-2016
# 0BSD
# 0BSD OR MIT OR Apache-2.0
# Apache-2.0
# Apache-2.0 OR BSL-1.0
# Apache-2.0 OR MIT
# Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
# BSD-2-Clause OR Apache-2.0 OR MIT
# MIT
# MIT OR Apache-2.0
# MIT OR Zlib OR Apache-2.0
# Unlicense OR MIT
License: 0BSD AND Apache-2.0 AND MIT AND Unicode-DFS-2016 AND (0BSD OR MIT OR Apache-2.0) AND (Apache-2.0 OR BSL-1.0) AND (Apache-2.0 OR MIT) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND (BSD-2-Clause OR Apache-2.0 OR MIT) AND (MIT OR Zlib OR Apache-2.0) AND (Unlicense OR MIT)
# LICENSE.dependencies contains a full license breakdown
%if %{with selinux}
Requires: (%{crate}-selinux if selinux-policy-%{selinuxtype})
%endif
Recommends: rd-hashd = %{version}
Recommends: %{crate}-data = %{version}-%{release}
Recommends: bcc
Recommends: fio
Recommends: oomd
Recommends: stress
Recommends: tar
Recommends: wget
Recommends: xz
%description -n %{crate} %{_description}
%files -n %{crate}
%license LICENSE
%license LICENSE.dependencies
%doc README.md
%{_bindir}/rd-agent
%attr(2775, root, wheel) %dir %{_sharedstatedir}/resctl-demo
%package -n %{crate}-data
Summary: Data files for %{crate}
BuildArch: noarch
%description -n %{crate}-data
This package contains data files for %{crate}.
%files -n %{crate}-data
%{_datadir}/resctl-demo
%if %{with selinux}
%package -n %{crate}-selinux
Summary: SELinux policy for %{crate}
BuildArch: noarch
Requires: selinux-policy-%{selinuxtype}
Requires(post): selinux-policy-%{selinuxtype}
%{?selinux_requires}
%description -n %{crate}-selinux
This package contains the SELinux policy for %{crate}.
%pre -n %{crate}-selinux
%selinux_relabel_pre -s %{selinuxtype}
%post -n %{crate}-selinux
%selinux_modules_install -s %{selinuxtype} %{_datadir}/selinux/packages/%{selinuxtype}/%{crate}.pp.bz2
%selinux_relabel_post -s %{selinuxtype}
%postun -n %{crate}-selinux
if [ $1 -eq 0 ]; then
%selinux_modules_uninstall -s %{selinuxtype} %{crate}
%selinux_relabel_post -s %{selinuxtype}
fi
%files -n %{crate}-selinux
%{_datadir}/selinux/packages/%{selinuxtype}/%{crate}.pp.*
%ghost %verify(not md5 size mtime) %{_sharedstatedir}/selinux/%{selinuxtype}/active/modules/200/%{crate}
%endif
%prep
%autosetup -n %{crate}-%{version} -p1
%cargo_prep
%if %{with selinux}
mkdir selinux
cp -p %{SOURCE10} %{SOURCE11} %{SOURCE12} selinux
%endif
%generate_buildrequires
%cargo_generate_buildrequires
%build
%cargo_build
%{cargo_license_summary}
%{cargo_license} > LICENSE.dependencies
%if %{with selinux}
make -C selinux -f %{_datadir}/selinux/devel/Makefile %{crate}.pp
bzip2 -9 selinux/%{crate}.pp
%endif
%install
%cargo_install
install -Dpm0644 %SOURCE1 %{buildroot}%{_datadir}/resctl-demo/linux.tar.xz
mkdir -p %{buildroot}%{_sharedstatedir}/resctl-demo
%if %{with selinux}
install -Dm0644 selinux/%{crate}.pp.bz2 \
%{buildroot}%{_datadir}/selinux/packages/%{selinuxtype}/%{crate}.pp.bz2
%endif
%if %{with check}
%check
%cargo_test
%endif
%changelog
%autochangelog