Add %cargo_license and %cargo_license_summary macros

This commit is contained in:
Fabio Valentini 2022-08-03 23:07:30 +02:00
parent 23523b5fdc
commit 69b5574ce0
No known key found for this signature in database
GPG key ID: 5AC5F572E5D410AF

View file

@ -109,6 +109,44 @@ if %__cargo_is_bin; then \
fi \
)
# This macro prints license information for all crates in the dependency tree
# that are neither build-dependencies, dev-dependencies nor proc-macro
# dependencies.
# Additionally, deprecated SPDX syntax is normalized before sorting the
# results to ensure consistent order.
%cargo_license(naf:)\
%{shrink:\
%{__cargo} tree \
--workspace \
--offline \
--edges no-build,no-dev,no-proc-macro \
--no-dedupe \
--target all \
%{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \
--prefix none \
--format "{l}: {p}" \
| sed -e "s: ($(pwd)[^)]*)::g" -e "s: / :/:g" -e "s:/: OR :g" \
| sort -u
}
# This macro prints license summary for all crates in the dependency tree that
# are neither dev-dependencies nor proc-macros. Additionally, deprecated SPDX
# syntax is normalized before sorting the results to ensure consistent order.
%cargo_license_summary(naf:)\
%{shrink:\
%{__cargo} tree \
--workspace \
--offline \
--edges no-build,no-dev,no-proc-macro \
--no-dedupe \
--target all \
%{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \
--prefix none \
--format "# {l}" \
| sed -e "s: / :/:g" -e "s:/: OR :g" \
| sort -u \
}
%__cargo_feature_from_name(n:) %{lua:
local name = rpm.expand("%{-n*}")
local feature = string.match(name, "^[^+]+%+(.+)-devel$")