Fix packaging for RHEL-9

Resolves: #1930369
This commit is contained in:
Michal Sekletar 2021-06-29 17:28:12 +00:00
parent 71710e70a9
commit 2844ea0189
5 changed files with 209 additions and 90 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@
/zram-generator-0.3.0-rc.1.crate
/zram-generator-0.3.1.crate
/zram-generator-0.3.2.crate
/zram-generator-v0.3.2-vendor.tar.gz

View File

@ -1,109 +1,40 @@
# Generated by rust2rpm 17
%bcond_without check
%global crate zram-generator
Name: rust-%{crate}
Version: 0.3.2
Release: 4%{?dist}
Release: 5%{?dist}
Summary: Systemd unit generator for zram swap devices
# Upstream license specification: MIT
License: MIT
URL: https://crates.io/crates/zram-generator
URL: https://crates.io/crates/%{crate}
Source: %{crates_source}
Source1: zram-generator.conf
Source1: %{crate}-v%{version}-vendor.tar.gz
Source2: zram-generator.conf
Source3: zram-generator.8
Source4: zram-generator.conf.5
ExclusiveArch: %{rust_arches}
%if %{__cargo_skip_build}
BuildArch: noarch
%endif
BuildRequires: rust-packaging
BuildRequires: git
BuildRequires: rust-toolset
BuildRequires: systemd-devel systemd-rpm-macros
BuildRequires: /usr/bin/make
%global _description %{expand:
%description
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}
%if ! %{__cargo_skip_build}
%package -n %{crate}
Summary: %{summary}
# MIT
# MIT or ASL 2.0
License: MIT
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.conf.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
%endif
%package devel
Summary: %{summary}
BuildArch: noarch
%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_no_tilde}/
%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_no_tilde}/Cargo.toml
is used to store compressed pages, essentially trading CPU cycles for memory.)
%prep
%autosetup -n %{crate}-%{version_no_tilde} -p1
cp -a %{S:1} .
%cargo_prep
%generate_buildrequires
%cargo_generate_buildrequires
echo '/usr/bin/make'
echo '/usr/bin/ronn'
echo 'systemd-rpm-macros'
cp -a %{S:2} .
%cargo_prep -V 1
%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_no_tilde}" man/*.md
cp -a %{S:3} %{S:4} man/
%install
export SYSTEMD_UTIL_DIR=%{_systemd_util_dir}
@ -112,17 +43,24 @@ export SYSTEMD_UTIL_DIR=%{_systemd_util_dir}
mkdir -p %{buildroot}%{_systemdgeneratordir}
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}%{_prefix}/lib/systemd %{SOURCE2}
install -Dpm0644 -t %{buildroot}%{_mandir}/man8 man/zram-generator.8
install -Dpm0644 -t %{buildroot}%{_mandir}/man5 man/zram-generator.conf.5
%if %{with check}
%check
export SYSTEMD_UTIL_DIR=%{_systemd_util_dir}
%cargo_test
%endif
%files
%license LICENSE
%doc zram-generator.conf.example
%doc README.md
%{_systemdgeneratordir}/zram-generator
%{_unitdir}/systemd-zram-setup@.service
%{_prefix}/lib/systemd/zram-generator.conf
%{_mandir}/man8/zram-generator.8*
%{_mandir}/man5/zram-generator.conf.5*
%changelog
* Thu Jun 24 2021 <msekleta@redhat.com> - 0.3.2-5
- Adjust packaging to account for differences between Fedora and CentOS/RHEL rust packaging (#1930369)
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com>
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937

View File

@ -1 +1,2 @@
SHA512 (zram-generator-0.3.2.crate) = e16effd58c6e4a91d877316e7ee000d36be6d9ce2d054804794c218cd87feb162179e73daa03e9570338796ea6ffe63a16720a1f2057cee2de616aa00a93311f
SHA512 (zram-generator-v0.3.2-vendor.tar.gz) = 6f2f9655fa9625dd5499150d8a7af5753c03dbf8917f38053a96a0014de9760e43ddc4427a8d049acb279f458beee14d970f16c14d380afea446839224eb04f7

55
zram-generator.8 Normal file
View File

@ -0,0 +1,55 @@
.\" generated with Ronn-NG/v0.9.1
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
.TH "ZRAM\-GENERATOR" "8" "February 2021" "zram-generator developers"
.SH "NAME"
\fBzram\-generator\fR \- Systemd unit generator for zram swap devices
.SH "SYNOPSIS"
\fB/usr/lib/systemd/system\-generators/zram\-generator\fR \fBTARGET_DIR\fR [\fI2RGET_DIR\fR \fI3RGET_DIR\fR]
.br
\fB/usr/lib/systemd/system\-generators/zram\-generator\fR \-\-setup\-device \fBDEVICE\fR
.br
\fB/usr/lib/systemd/system\-generators/zram\-generator\fR \-\-reset\-device \fBDEVICE\fR
.SH "DESCRIPTION"
\fBzram\-generator\fR is a generator that creates systemd units to format and use compressed RAM devices, either as swap or a mount point\.
.P
The generator will be invoked by systemd early at boot\. The generator will then:
.IP "1." 4
read configuration files from \fI{/etc,/lib}/systemd/zram\-generator\.conf[\.d]\fR (see zram\-generator\.conf(5) for details);
.IP "2." 4
generate systemd\.swap(5) and/or systemd\.mount(5) units into \fBTARGET_DIR\fR and connect them to \fBswap\.target\fR or \fBlocal\-fs\.target\fR as appropriate;
.IP "3." 4
ensure the \fBzram\fR module is loaded and create the requested devices\.
.IP "" 0
.P
The generator does nothing if run inside a container (as determined by \fIsystemd\-detect\-virt(8) \-\-container\fR)\.
.P
The generator also understands the kernel command\-line option \fBsystemd\.zram\fR\. See zram\-generator\.conf(5) for details\.
.P
Setting the \fBZRAM_GENERATOR_ROOT\fR environment variable makes the generator run in test mode, in which case containerisation is ignored and step \fB3\fR is skipped\.
.br
For the ramifications of \fBZRAM_GENERATOR_ROOT\fR on config handling, see zram\-generator\.conf(5)\.
.P
Generated \fIdev\-zramN\.swap\fR units depend on \fBsystemd\-swap\-create@zramN\.service\fR, which will:
.IP "1." 4
read configuration files from \fI{/etc,/lib}/systemd/zram\-generator\.conf[\.d]\fR (see zram\-generator\.conf(5) for details);
.IP "2." 4
set the desired compression algorithm, if any; if the current kernel doesn\'t understand the specified algorithm, a warning is issued, but execution continues;
.IP "3." 4
set the desired blockdev size and format it as swap with \fIsystemd\-makefs(8)\fR\.
.IP "" 0
.P
Generated \fIpath\-to\-mount\-point\.mount\fR units depend on \fBsystemd\-swap\-create@zramN\.service\fR\. The effect is similar to what happens for swap units, but of course they are formatted with a file system\.
.P
When the unit is stopped, the zram device is reset, freeing memory and allowing the device to be reused\.
.P
\fBzram\-generator\fR implements systemd\.generator(7)\.
.SH "REPORTING BUGS"
<\fIhttps://github\.com/systemd/zram\-generator/issues\fR>
.SH "SEE ALSO"
zram\-generator\.conf(5), systemd\.generator(7), systemd\.swap(5)
.P
<\fIhttps://github\.com/systemd/zram\-generator\fR>
.P
Linux documentation of zram: <\fIhttps://kernel\.org/doc/html/latest/admin\-guide/blockdev/zram\.html\fR>
.br
and the zram sysfs ABI: <\fIhttps://kernel\.org/doc/Documentation/ABI/testing/sysfs\-block\-zram\fR>

124
zram-generator.conf.5 Normal file
View File

@ -0,0 +1,124 @@
.\" generated with Ronn-NG/v0.9.1
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
.TH "ZRAM\-GENERATOR\.CONF" "5" "February 2021" "zram-generator developers"
.SH "NAME"
\fBzram\-generator\.conf\fR \- Systemd unit generator for zram swap devices (configuration)
.SH "SYNOPSIS"
\fB/usr/lib/systemd/zram\-generator\.conf\fR
.br
\fB/usr/local/lib/systemd/zram\-generator\.conf\fR
.br
\fB/etc/systemd/zram\-generator\.conf\fR
.br
\fB/run/systemd/zram\-generator\.conf\fR
.P
\fB/usr/lib/systemd/zram\-generator\.conf\.d/*\.conf\fR
.br
\fB/usr/local/lib/systemd/zram\-generator\.conf\.d/*\.conf\fR
.br
\fB/etc/systemd/zram\-generator\.conf\.d/*\.conf\fR
.br
\fB/run/systemd/zram\-generator\.conf\.d/*\.conf\fR
.SH "DESCRIPTION"
These files configure devices created by zram\-generator(8)\. See systemd\.syntax(5) for a general description of the syntax\.
.SH "CONFIGURATION DIRECTORIES AND PRECEDENCE"
The default configuration doesn\'t specify any devices\. Consult \fI/usr/share/zram\-generator/zram\-generator\.conf\.example\fR for an example configuration file\.
.P
When packages need to customize the configuration, they can install configuration snippets in \fI/usr/lib/systemd/zram\-generator\.conf\.d/\fR\. Files in \fI/etc/\fR are reserved for the local administrator, who may use this logic to override the configuration files installed by vendor packages\. The main configuration file is read before any of the configuration directories, and has the lowest precedence; entries in a file in any configuration directory override entries in the single configuration file\. Files in the \fI*\.conf\.d/\fR configuration subdirectories are sorted by their filename in lexicographic order, regardless of which of the subdirectories they reside in\. When multiple files specify the same option, for options which accept just a single value, the entry in the file with the lexicographically latest name takes precedence\. It is recommended to prefix all filenames in those subdirectories with a two\-digit number and a dash, to simplify the ordering of the files\.
.P
To disable a configuration file supplied by the vendor, the recommended way is to place a symlink to \fI/dev/null\fR in the configuration directory in \fI/etc/\fR, with the same filename as the vendor configuration file\.
.P
The generator understands the following option on the kernel command\-line: \fBsystemd\.zram[=0|1]\fR\. When specified with a true argument (or no argument), the \fBzram0\fR device will be created\. Default options apply, but may be overridden by configuration on disk if present\. When specified with a false argument, no zram devices will be created by the generator\. This option thus has higher priority than the configuration files\.
.SH "OPTIONS"
Each device is configured independently in its \fB[zramN]\fR section, where N is a nonnegative integer\. Other sections are ignored\.
.P
Devices with the final size of \fI0\fR will be discarded\.
.IP "\[ci]" 4
\fBhost\-memory\-limit\fR=
.IP
Sets the upper limit on the total usable RAM (as defined by \fIMemTotal\fR in \fB/proc/meminfo\fR, confer proc(5)) above which the device will \fInot\fR be created\.
.IP
This takes a nonnegative number, representing that limit in megabytes, or the literal string \fInone\fR, which can be used to override a limit set earlier\.
.IP
Defaults to \fInone\fR\.
.IP
For compatibility with earlier versions, \fBmemory\-limit\fR is allowed as an alias for this option\. Its use is discouraged, and administrators should migrate to \fBhost\-memory\-limit\fR\.
.IP "\[ci]" 4
\fBzram\-fraction\fR=
.IP
Defines the scaling factor of the zram device\'s size with relation to the total usable RAM\.
.IP
This takes a nonnegative floating\-point number representing that factor\.
.IP
Defaults to \fI0\.5\fR\.
.IP "\[ci]" 4
\fBmax\-zram\-size\fR=
.IP
Sets the limit on the zram device\'s size obtained by \fBzram\-fraction\fR\.
.IP
This takes a nonnegative number, representing that limit in megabytes, or the literal string \fInone\fR, which can be used to override a limit set earlier\.
.IP
Defaults to \fI4096\fR\.
.IP "\[ci]" 4
\fBcompression\-algorithm\fR=
.IP
Specifies the algorithm used to compress the zram device\.
.IP
This takes a literal string, representing the algorithm to use\.
.br
Consult \fI/sys/block/zram0/comp_algorithm\fR for a list of currently loaded compression algorithms, but note that additional ones may be loaded on demand\.
.IP
If unset, none will be configured and the kernel\'s default will be used\.
.IP "\[ci]" 4
\fBswap\-priority\fR=
.IP
Controls the relative swap priority, a value between \-1 and 32767\. Higher numbers indicate higher priority\.
.IP
If unset, 100 is used\.
.IP "\[ci]" 4
\fBmount\-point\fR=
.IP
Format the device with a file system (not as swap) and mount this file system over the specified directory\. When neither this option nor \fBfs\-type\fR= is specified, the device will be formatted as swap\.
.IP
Note that the device is temporary: contents will be destroyed automatically after the file system is unmounted (to release the backing memory)\.
.IP "\[ci]" 4
\fBfs\-type\fR=
.IP
Specifies how the device shall be formatted\. The default is \fIext2\fR if \fBmount\-point\fR is specified, and \fIswap\fR otherwise\. (Effectively, the device will be formatted as swap, if neither \fBfs\-type\fR= nor \fBmount\-point\fR= are specified\.)
.IP
Note that the device is temporary: contents will be destroyed automatically after the file system is unmounted (to release the backing memory)\.
.IP
Also see systemd\-makefs(8)\.
.IP "" 0
.SH "ENVIRONMENT VARIABLES"
Setting \fBZRAM_GENERATOR_ROOT\fR during parsing will cause \fI/proc/meminfo\fR to be read from \fI$ZRAM_GENERATOR_ROOT/proc/meminfo\fR instead, and \fI{/usr/lib,/usr/local/lib,/etc,/run}/systemd/zram\-generator\.conf\fR to be read from \fI$ZRAM_GENERATOR_ROOT/{/usr/lib,/usr/local/lib,/etc,/run}/systemd/zram\-generator\.conf\fR\.
.SH "EXAMPLES"
The default configuration will yield the following:
.IP "" 4
.nf
zram device size [MB]
^
4G>│ ooooooooooooo
│ o
│ o
│ o
2G>│ o
│ o
│ o
512M>│ o
0───────────────────────> total usable RAM [MB]
^ ^ ^
1G 4G 8G
.fi
.IP "" 0
.SH "REPORTING BUGS"
<\fIhttps://github\.com/systemd/zram\-generator/issues\fR>
.SH "SEE ALSO"
zram\-generator(8), systemd\.syntax(5), proc(5)
.P
<\fIhttps://github\.com/systemd/zram\-generator\fR>
.P
Linux documentation of zram: <\fIhttps://kernel\.org/doc/html/latest/admin\-guide/blockdev/zram\.html\fR>
.br
and the zram sysfs ABI: <\fIhttps://kernel\.org/doc/Documentation/ABI/testing/sysfs\-block\-zram\fR>