init package

This commit is contained in:
duyiwei 2022-11-10 14:42:23 +08:00
parent 37a84864cf
commit aac0531ad0
4 changed files with 105 additions and 0 deletions

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

@ -0,0 +1,97 @@
%define debug_package %{nil}
%global crate zram-generator
Name: rust-%{crate}
Version: 1.1.2
Release: 2
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: %{_sbindir}/zramctl
License: MIT
%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}.
%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}
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
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
rm -rf %{buildroot}%{cargo_registry}/%{crate}-%{version}
%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
%changelog
* Thu Sep 8 2022 duyiwei <duyiwei@kylinos.cn> - 1.1.2-2
- remove useless subpackage zram-generator-devel
* Tue Jul 19 2022 duyiwei <duyiwei@kylinos.cn> - 1.1.2-1
- upgrade to 1.1.2
* Tue May 10 2022 duyiwei <duyiwei@kylinos.cn> - 0.3.2-1
- Package init

BIN
zram-generator-1.1.2.crate Normal file

Binary file not shown.

Binary file not shown.

8
zram-generator.conf Normal file
View File

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