From ab79d03fdb0de71a05edf8f62d76f0eccfd1c851 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 10 Nov 2020 12:07:54 -0800 Subject: [PATCH] Initial rust-toolset on el9 --- macros.rust-toolset | 51 +++++++++++++++++++++++++++++++++++++++++++++ rust-toolset.spec | 25 ++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 macros.rust-toolset create mode 100644 rust-toolset.spec diff --git a/macros.rust-toolset b/macros.rust-toolset new file mode 100644 index 0000000..41bb129 --- /dev/null +++ b/macros.rust-toolset @@ -0,0 +1,51 @@ +# Explicitly use bindir tools, in case others are in the PATH, +# like the rustup shims in a user's ~/.cargo/bin/. +# +# Since cargo 1.31, install only uses $CARGO_HOME/config, ignoring $PWD. +# https://github.com/rust-lang/cargo/issues/6397 +# But we can set CARGO_HOME locally, which is a good idea anyway to make sure +# it never writes to ~/.cargo during rpmbuild. +%__cargo %{_bindir}/env CARGO_HOME=.cargo %{_bindir}/cargo +%__rustc %{_bindir}/rustc +%__rustdoc %{_bindir}/rustdoc + +# Enable optimization, debuginfo, and link hardening. +%__global_rustflags -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now + +%__global_rustflags_toml [%{lua: + for arg in string.gmatch(rpm.expand("%{__global_rustflags}"), "%S+") do + print('"' .. arg .. '", ') + end}] + +%cargo_prep(V:) (\ +%{__mkdir} -p .cargo \ +cat > .cargo/config << EOF \ +[build]\ +rustc = "%{__rustc}"\ +rustdoc = "%{__rustdoc}"\ +rustflags = %{__global_rustflags_toml}\ +\ +[install]\ +root = "%{buildroot}%{_prefix}"\ +\ +[term]\ +verbose = true\ +EOF\ +%if 0%{-V:1}\ +%{__tar} -xoaf %{S:%{-V*}}\ +cat >> .cargo/config << EOF \ +\ +[source.crates-io]\ +replace-with = "vendored-sources"\ +\ +[source.vendored-sources]\ +directory = "./vendor"\ +EOF\ +%endif\ +) + +%cargo_build %__cargo build --release %{?_smp_mflags} + +%cargo_test %__cargo test --release %{?_smp_mflags} --no-fail-fast + +%cargo_install %__cargo install --no-track --path . diff --git a/rust-toolset.spec b/rust-toolset.spec new file mode 100644 index 0000000..6df8f69 --- /dev/null +++ b/rust-toolset.spec @@ -0,0 +1,25 @@ +Summary: Package that installs rust-toolset +Name: rust-toolset +Version: 1.47.0 +Release: 1%{?dist} +License: ASL 2.0 or MIT + +Source0: macros.%{name} + +Requires: rust = %{version} +Requires: cargo = %{version} + +%description +This is the main package for rust-toolset. + +%install + +# This allows users to build packages using Rust Toolset. +%{__install} -D -m 644 %{S:0} %{buildroot}%{rpmmacrodir}/macros.%{name} + +%files +%{rpmmacrodir}/macros.%{name} + +%changelog +* Tue Nov 10 2020 Josh Stone - 1.47.0-1 +- Initial rust-toolset on el9