Sync rust-toolset's rpm macros with RHEL 10

If a package is using `%cargo_build`, `%cargo_test`, or `%cargo_install`
with pass-through arguments, they may need to add `--` to explicitly
separate those from the rpm macro arguments.

Resolves: RHEL-104777
This commit is contained in:
Josh Stone 2025-09-10 16:19:03 -07:00
parent 2c97649d7a
commit 54e4b48d95

View File

@ -126,32 +126,31 @@ EOF}\
%{nil} \ %{nil} \
} }
# NB: cargo_build/test/install do not use the -n/-a/-f argument parsing like # cargo_build: builds the crate with cargo with the specified feature flags
# Fedora's rust-packaging, because that change would break anyone that's %cargo_build(naf:)\
# already passing arguments directly to cargo after the macro. Instead, one can
# explicitly use --no-default-features, --all-features, or --features XYZ.
# cargo_build: builds the crate with cargo
%cargo_build\
%{shrink: \ %{shrink: \
%{__cargo} build \ %{__cargo} build \
%{__cargo_common_opts} \ %{__cargo_common_opts} \
--profile rpm \ --profile rpm \
%{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \
%* \
} }
# cargo_test: runs the test suite with cargo # cargo_test: runs the test suite with cargo with the specified feature flags
# #
# To pass command-line arguments to the cargo test runners directly (for # To pass command-line arguments to the cargo test runners directly (for
# example, to skip certain tests during package builds), the # example, to skip certain tests during package builds), both the cargo_test
# "cargo test" argument parsing need to be bypassed, # macro argument parsing and "cargo test" argument parsing need to be bypassed,
# i.e. "%%cargo_test -- --skip foo" for skipping all tests with names that # i.e. "%%cargo_test -- -- --skip foo" for skipping all tests with names that
# match "foo". # match "foo".
%cargo_test\ %cargo_test(naf:)\
%{shrink: \ %{shrink: \
%{__cargo} test \ %{__cargo} test \
%{__cargo_common_opts} \ %{__cargo_common_opts} \
--profile rpm \ --profile rpm \
--no-fail-fast \ --no-fail-fast \
%{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \
%* \
} }
# cargo_install: install files into the buildroot # cargo_install: install files into the buildroot
@ -161,14 +160,19 @@ EOF}\
# "$CARGO_HOME/.crates.toml" file, which is used to keep track of which version # "$CARGO_HOME/.crates.toml" file, which is used to keep track of which version
# of a specific binary has been installed, but which conflicts between builds # of a specific binary has been installed, but which conflicts between builds
# of different Rust applications and is not needed when building RPM packages. # of different Rust applications and is not needed when building RPM packages.
%cargo_install\ %cargo_install(t:naf:)\
%{shrink: \ (\
%{__cargo} install \ set -euo pipefail \
%{__cargo_common_opts} \ %{shrink: \
--profile rpm \ %{__cargo} install \
--no-track \ %{__cargo_common_opts} \
--path . \ --profile rpm \
} --no-track \
--path . \
%{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \
%* \
} \
)
# cargo_license: print license information for all crate dependencies # cargo_license: print license information for all crate dependencies
# #