rust-zram-generator/rust-zram-generator.spec

97 lines
2.7 KiB
RPMSpec

%bcond_without check
%global crate zram-generator
%{!?_systemd_util_dir:%global _systemd_util_dir /usr/lib/systemd}
Name: rust-%{crate}
Version: 1.1.2
Release: %autorelease
Summary: Systemd unit generator for zram swap devices
# Upstream license specification: MIT
License: MIT
URL: https://crates.io/crates/zram-generator
Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate
Source1: zram-generator.conf
Source2: %{crate}-%{version}-vendor.tar.xz
ExclusiveArch: %{rust_arches}
BuildRequires: rust-toolset
BuildRequires: glibc-devel
BuildRequires: make
BuildRequires: systemd-rpm-macros
%global _description %{expand:
This is a systemd unit generator that enables swap on zram.
(With zram, there is no physical swap device. Part of the available RAM
is used to store compressed pages, essentially trading CPU cycles for memory.)
To activate, install %{crate}-defaults subpackage.}
%description %{_description}
%package -n %{crate}
Summary: %{summary}
# MIT
# MIT or ASL 2.0
License: MIT
Recommends: %{_sbindir}/zramctl
%description -n %{crate} %{_description}
%files -n %{crate}
%license LICENSE
%doc zram-generator.conf.example
%doc README.md
%{_systemdgeneratordir}/zram-generator
%{_unitdir}/systemd-zram-setup@.service
%package -n %{crate}-defaults
Summary: Default configuration for %{crate}
Requires: %{crate} = %{version}-%{release}
Obsoletes: zram < 0.4-2
BuildArch: noarch
%description -n %{crate}-defaults
%{summary}.
%files -n %{crate}-defaults
%{_prefix}/lib/systemd/zram-generator.conf
%prep
%autosetup -n %{crate}-%{version} -p1 -a2
cp -a %{S:1} .
%cargo_prep -V 2
rm -f Cargo.lock
sed -i -e '/Command::new/s|"modprobe"|"/sbin/modprobe"|' src/generator.rs
%build
export SYSTEMD_UTIL_DIR=%{_systemd_util_dir}
export LC_ALL=C.UTF-8
%cargo_build
%make_build SYSTEMD_SYSTEM_UNIT_DIR=%{_unitdir} SYSTEMD_SYSTEM_GENERATOR_DIR=%{_systemdgeneratordir} \
systemd-service
%install
export SYSTEMD_UTIL_DIR=%{_systemd_util_dir}
%make_install SYSTEMD_SYSTEM_UNIT_DIR=%{_unitdir} SYSTEMD_SYSTEM_GENERATOR_DIR=%{_systemdgeneratordir} \
NOBUILD=1 NOMAN=1
install -Dpm0644 -t %{buildroot}%{_prefix}/lib/systemd %{SOURCE1}
%if %{with check}
%check
export SYSTEMD_UTIL_DIR=%{_systemd_util_dir}
%cargo_test
: ==============================================================================
%{buildroot}%{_systemdgeneratordir}/zram-generator --help
: ==============================================================================
%{buildroot}%{_systemdgeneratordir}/zram-generator --help | grep -q %{_systemd_util_dir}/systemd-makefs
%endif
%changelog
%autochangelog