diff --git a/rust-zram-generator.spec b/rust-zram-generator.spec new file mode 100644 index 0000000000000000000000000000000000000000..35d32f9a96cc7ecd465bf8092f96e954a65346cc --- /dev/null +++ b/rust-zram-generator.spec @@ -0,0 +1,122 @@ +%define debug_package %{nil} +%bcond_without check +%global __cargo_skip_build 0 +%global crate zram-generator + +Name: rust-%{crate} +Version: 0.3.2 +Release: 1 +Summary: Systemd unit generator for zram swap devices + +# Upstream license specification: MIT +License: MIT +URL: https://crates.io/crates/zram-generator +Source: %{crate}-%{version}.crate +Source1: zram-generator.conf +Source2: zram-generator-vendor.tar.gz + +BuildRequires: rust-packaging rubygem-ronn + +%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 avaialable 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} +Recommends: /usr/bin/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 +%{_mandir}/man8/zram-generator.8* +%{_mandir}/man5/zram-generator.5* + +%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 + + +%package devel +Summary: %{summary} + +%description devel %{_description} + +This package contains library source intended for building other packages +which use "%{crate}" crate. + +%files devel +%license LICENSE +%doc README.md +%{cargo_registry}/%{crate}-%{version}/ + +%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. + +%files -n %{name}+default-devel +%ghost %{cargo_registry}/%{crate}-%{version}/Cargo.toml + +%prep +%autosetup -n %{crate}-%{version} -p1 +cp -a %{S:1} . +tar xvf %{SOURCE2} +%cargo_prep + +mkdir -p .cargo +cat >.cargo/config << EOF + +[source.crates-io] +replace-with = "vendored-sources" + +[source.vendored-sources] +directory = "vendor" +EOF + +echo '/usr/bin/make' +echo '/usr/bin/ronn' +echo 'systemd-rpm-macros' + +%build +export SYSTEMD_UTIL_DIR=%{_systemd_util_dir} +%cargo_build +make systemd_service SYSTEMD_SYSTEM_UNIT_DIR=%{?_unitdir} SYSTEMD_SYSTEM_GENERATOR_DIR=%{?_systemdgeneratordir} +LC_ALL=C.UTF-8 ronn --roff --organization="zram-generator %{version}" man/*.md + +%install +export SYSTEMD_UTIL_DIR=%{_systemd_util_dir} +%cargo_install + +mkdir -p %{buildroot}%{?_systemdgeneratordir} +cp -r $PWD/.cargo/bin %{buildroot}/usr/ +mv -v %{buildroot}%{_bindir}/zram-generator %{buildroot}%{?_systemdgeneratordir}/ +install -Dpm0644 -t %{buildroot}%{?_unitdir} units/systemd-zram-setup@.service +install -Dpm0644 -t %{buildroot}%{_prefix}/lib/systemd %{SOURCE1} +install -Dpm0644 -t %{buildroot}%{_mandir}/man8 man/zram-generator.8 +install -Dpm0644 -t %{buildroot}%{_mandir}/man5 man/zram-generator.5 + +%changelog +* Mon Dec 27 2021 duyiwei - 0.3.2-1 +- Package init diff --git a/zram-generator-0.3.2.crate b/zram-generator-0.3.2.crate new file mode 100644 index 0000000000000000000000000000000000000000..0c08f6f04c635e07bc28a83578976b84778560cd Binary files /dev/null and b/zram-generator-0.3.2.crate differ diff --git a/zram-generator-vendor.tar.gz b/zram-generator-vendor.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..6fee6a1f90f27f988a161efa8ad29eb2bab1bb44 Binary files /dev/null and b/zram-generator-vendor.tar.gz differ diff --git a/zram-generator.conf b/zram-generator.conf new file mode 100644 index 0000000000000000000000000000000000000000..a5432f94699c7d09f0db085678aae71e1d63155d --- /dev/null +++ b/zram-generator.conf @@ -0,0 +1,9 @@ +# 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-fraction = 1.0 +max-zram-size = 8192