From 69b5574ce0c3219c7212ed1855b3bb198dc81a76 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Oct 19 2022 09:39:20 +0000 Subject: Add %cargo_license and %cargo_license_summary macros --- diff --git a/data/macros.cargo b/data/macros.cargo index 206df14..e54705a 100644 --- a/data/macros.cargo +++ b/data/macros.cargo @@ -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$")