diff --git a/macros.rust-toolset b/macros.rust-toolset new file mode 100644 index 0000000000000000000000000000000000000000..41bb129e5c8eced23dfc086036f3aa16ae9521c9 --- /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.spec b/rust.spec index 73311796d8f68a483ad797c81aaa11c76ed78980..7a205e539d83eaa364b9790203f91b0bbc6b49d6 100644 --- a/rust.spec +++ b/rust.spec @@ -1,4 +1,4 @@ -%define anolis_release 1 +%define anolis_release 2 # Only x86_64 and i686 are Tier 1 platforms at this time. # https://doc.rust-lang.org/nightly/rustc/platform-support.html @@ -91,6 +91,8 @@ Patch2: rustc-1.61.0-rust-gdb-substitute-path.patch Patch3: 0001-Fix-Async-Generator-ABI.patch ### RHEL-specific patches below ### +# Simple rpm macros for rust-toolset (as opposed to full rust-packaging) +Source100: macros.rust-toolset # Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949) Patch100: rustc-1.65.0-disable-libssh2.patch @@ -465,6 +467,16 @@ This package contains analysis data files produced with rustc's -Zsave-analysis feature for the Rust standard library. The RLS (Rust Language Server) uses this data to provide information about the Rust standard library. +%package toolset +Summary: Rust Toolset +Requires: rust = %{version}-%{release} +Requires: cargo = %{version}-%{release} +Buildarch: noarch + +%description toolset +This is the metapackage for Rust Toolset, bringing in the Rust compiler, +the Cargo package manager, and a few convenience macros for rpm builds. + %prep @@ -728,6 +740,9 @@ rm -f %{buildroot}%{rustlibdir}/etc/lldb_* # We don't want Rust copies of LLVM tools (rust-lld, rust-llvm-dwp) rm -f %{buildroot}%{rustlibdir}/%{rust_triple}/bin/rust-ll* +# This allows users to build packages using Rust Toolset. +%{__install} -D -m 644 %{SOURCE100} %{buildroot}%{rpmmacrodir}/macros.rust-toolset + %check %{export_rust_env} @@ -906,8 +921,13 @@ end} %files analysis %{rustlibdir}/%{rust_triple}/analysis/ +%files toolset +%{rpmmacrodir}/macros.rust-toolset %changelog +* Fri Feb 24 2023 Funda Wang - 1.67.1-2 +- Merge rust-toolset into main package + * Fri Feb 10 2023 Funda Wang - 1.67.1-1 - New version 1.67.1