diff --git a/.gitignore b/.gitignore index 355f2e1..823f226 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ /zram-generator-1.1.0.crate /zram-generator-1.1.1.crate /zram-generator-1.1.2.crate +/zram-generator-1.1.2-vendor.tar.xz diff --git a/rust-zram-generator.spec b/rust-zram-generator.spec index 3ae92c0..9ab868b 100644 --- a/rust-zram-generator.spec +++ b/rust-zram-generator.spec @@ -1,6 +1,13 @@ # Generated by rust2rpm 19 %bcond_without check +# RHEL does not have packages for Rust dependencies +%if 0%{?rhel} +%global bundled_rust_deps 1 +%else +%global bundled_rust_deps 0 +%endif + %global crate zram-generator Name: rust-%{crate} @@ -13,10 +20,21 @@ License: MIT URL: https://crates.io/crates/zram-generator Source: %{crates_source} Source1: zram-generator.conf +# To create the vendor tarball: +# tar xf %%{crate}-%%{version}.crate ; pushd %%{crate}-%%{version} ; \ +# cargo vendor && tar Jcvf ../%%{crate}-%%{version}-vendor.tar.xz vendor/ ; popd +Source2: %{crate}-%{version}-vendor.tar.xz ExclusiveArch: %{rust_arches} +%if 0%{?bundled_rust_deps} +BuildRequires: rust-toolset +BuildRequires: make +BuildRequires: /usr/bin/ronn +BuildRequires: systemd-rpm-macros +%else BuildRequires: rust-packaging +%endif %global _description %{expand: This is a systemd unit generator that enables swap on zram. @@ -57,6 +75,7 @@ BuildArch: noarch %files -n %{crate}-defaults %{_prefix}/lib/systemd/zram-generator.conf +%if ! 0%{?bundled_rust_deps} %package devel Summary: %{summary} BuildArch: noarch @@ -82,10 +101,14 @@ which use "default" feature of "%{crate}" crate. %files -n %{name}+default-devel %ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml +%endif %prep %autosetup -n %{crate}-%{version_no_tilde} -p1 cp -a %{S:1} . +%if 0%{?bundled_rust_deps} +%cargo_prep -V 2 +%else %cargo_prep %generate_buildrequires @@ -93,6 +116,7 @@ cp -a %{S:1} . echo '/usr/bin/make' echo '/usr/bin/ronn' echo 'systemd-rpm-macros' +%endif %build export SYSTEMD_UTIL_DIR=%{_systemd_util_dir} diff --git a/sources b/sources index 53f8db3..0977171 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ SHA512 (zram-generator-1.1.2.crate) = dfad7d4384eb4635c33475e4571d33a3135c92cf42138dd1cb50f19aef4b3f2465130783e385a3f544e43a1653273cee9b2d8f45177a8b053acf37805dc939c8 +SHA512 (zram-generator-1.1.2-vendor.tar.xz) = 0d628fd3543ea2351d628a0fb61603cb838050050b1766a4c8c45e5de3a6513d724ca4d97081e112cf8accb9c23045a2b0a3de556374020bedb87ead310e9cf2