!2 add zram-generator source package and spec file

From: @duyiwei7w 
Reviewed-by: @yangzhao_kl 
Signed-off-by: @yangzhao_kl
This commit is contained in:
openeuler-ci-bot 2022-06-21 06:52:29 +00:00 committed by Gitee
commit 80076c7029
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 109 additions and 0 deletions

100
rust-zram-generator.spec Normal file
View File

@ -0,0 +1,100 @@
%define debug_package %{nil}
%global crate zram-generator
Name: rust-%{crate}
Version: 0.3.2
Release: 1
Summary: Systemd unit generator for zram swap devices
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.)
}
%description %{_description}
%package -n %{crate}
Summary: %{summary}
Recommends: /usr/bin/zramctl
%description -n %{crate} %{_description}
%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}.
%package devel
Summary: %{summary}
%description devel %{_description}
This package contains library source intended for building other packages
which use "%{crate}" crate.
%prep
%autosetup -n %{crate}-%{version} -p1
cp -a %{S:1} .
tar zxvf %{SOURCE2}
%cargo_prep
mkdir -p .cargo
cat >.cargo/config << EOF
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"
EOF
%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 -a $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.conf.5
%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.conf.5*
%files -n %{crate}-defaults
%{_prefix}/lib/systemd/zram-generator.conf
%files devel
%license LICENSE
%doc README.md
%{cargo_registry}/%{crate}-%{version}
%changelog
* Tue May 10 2022 duyiwei <duyiwei@kylinos.cn> - 0.3.2-1
- Package init

BIN
zram-generator-0.3.2.crate Normal file

Binary file not shown.

Binary file not shown.

9
zram-generator.conf Normal file
View File

@ -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