Initial rust-toolset on el9

This commit is contained in:
Josh Stone 2020-11-10 12:07:54 -08:00
parent ba39a91145
commit ab79d03fdb
2 changed files with 76 additions and 0 deletions

51
macros.rust-toolset Normal file
View File

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

25
rust-toolset.spec Normal file
View File

@ -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 <jistone@redhat.com> - 1.47.0-1
- Initial rust-toolset on el9