diff --git a/rust-zram-generator.spec b/rust-zram-generator.spec new file mode 100644 index 0000000000000000000000000000000000000000..01b51c4292fbbcc16f558dabe64fff41b0f6a9c9 --- /dev/null +++ b/rust-zram-generator.spec @@ -0,0 +1,115 @@ +%define anolis_release 1 +%global crate zram-generator + +Name: rust-zram-generator +Version: 1.1.2 +Release: %{anolis_release}%{?dist} +Summary: Systemd unit generator for zram swap devices + +License: MIT +URL: https://crates.io/crates/zram-generator +Source0: https://github.com/systemd/zram-generator/archive/refs/tags/v1.1.2.tar.gz +Source1: zram-generator.conf + +BuildRequires: rust-packaging > 21 + +# The following build dependencies are the software required for the check. +BuildRequires: rust-ctor+default-devel rust-ctor-devel rust-nix-devel +BuildRequires: rust-fs_extra-devel rust-fs_extra+default-devel rust-nix+default-devel +BuildRequires: rust-tempfile+default-devel + +%description +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.) + +%package devel +Summary: %{summary} +BuildArch: noarch + +%description devel +%{description} +This package contains library source intended for building other packages which +use the "%{crate}" crate. + +%package -n zram-generator +Summary: Systemd unit generator for zram swap devices + +%description -n zram-generator +%{description} + +%package -n zram-generator-defaults +Summary: Default configuration for zram-generator +Requires: zram-generator = %{version}-%{release} +Obsoletes: zram < 0.4-2 +BuildArch: noarch + +%description -n zram-generator-defaults +%{summary}. + +%package -n %{name}+default-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+default-devel +%{description} +This package contains library source intended for building other packages +which use "default" feature of "%{crate}" crate. + +%prep +%autosetup -n zram-generator-%{version} -p1 +cp -a %{SOURCE1} ./ + +%cargo_prep +%generate_buildrequires +%cargo_generate_buildrequires +echo '/usr/bin/make' +echo '/usr/bin/ronn' +echo 'systemd-rpm-macros' + +%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 man + +%install +export SYSTEMD_UTIL_DIR=%{_systemd_util_dir} +%cargo_install +rm %{buildroot}%{_bindir}/zram-generator +%make_install SYSTEMD_SYSTEM_UNIT_DIR=%{_unitdir} SYSTEMD_SYSTEM_GENERATOR_DIR=%{_systemdgeneratordir} \ + NOBUILD=1 + +install -Dpm0644 -t %{buildroot}%{_prefix}/lib/systemd %{SOURCE1} + +%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 + +%files devel +%license LICENSE +%doc README.md +%{cargo_registry}/%{crate}-%{version_no_tilde}/ + +%files -n zram-generator +%license LICENSE +%doc zram-generator.conf.example README.md +%{_systemdgeneratordir}/zram-generator +%{_unitdir}/systemd-zram-setup@.service +%{_mandir}/man8/zram-generator.8* +%{_mandir}/man5/zram-generator.conf.5* + +%files -n zram-generator-defaults +%{_prefix}/lib/systemd/zram-generator.conf + +%files -n %{name}+default-devel +%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml + +%changelog +* Wed Apr 20 2022 happy_orange - 1.1.2-1 +- Init package from upstream diff --git a/v1.1.2.tar.gz b/v1.1.2.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..9a83b41cffb3af84ba9e1020046a6eceddb2fdd9 Binary files /dev/null and b/v1.1.2.tar.gz differ diff --git a/zram-generator.conf b/zram-generator.conf new file mode 100644 index 0000000000000000000000000000000000000000..bc520955c39e1609e80791cdff5b7cfce851908a --- /dev/null +++ b/zram-generator.conf @@ -0,0 +1,8 @@ +# This config file enables a /dev/zram0 device with the default settings: +# — size — same as available RAM or 8GB, whichever is less +# — compression — most likely lzo-rle +# +# To disable, uninstall zram-generator-defaults or create empty +# /etc/systemd/zram-generator.conf file. +[zram0] +zram-size = min(ram, 8192)