From f4e2b139e9e33fd970189c345564713f4f9b80a4 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Sep 22 2023 13:41:57 +0000 Subject: Add cargo_vendor_manifest macro and and a _cargo_vendor generator The %cargo_vendor_manifest macro can be used to generate a file that lists the contents of vendor directories / tarballs generated by "cargo vendor", and this manifest file can then be installed to be consumed by the _cargo_vendor generator to produce correct virtual Provides for bundled Rust crates. --- diff --git a/fileattrs/cargo_vendor.attr b/fileattrs/cargo_vendor.attr new file mode 100644 index 0000000..e9dc933 --- /dev/null +++ b/fileattrs/cargo_vendor.attr @@ -0,0 +1,2 @@ +%__cargo_vendor_provides /usr/bin/cargo2rpm parse-vendor-manifest +%__cargo_vendor_path ^%{_defaultlicensedir}(/[^/]+)+/cargo-vendor.txt$ diff --git a/macros.d/macros.cargo b/macros.d/macros.cargo index 8adb9fa..c283647 100644 --- a/macros.d/macros.cargo +++ b/macros.d/macros.cargo @@ -215,3 +215,25 @@ fi \ | sort -u \ } +# cargo_vendor_manifest: write list of vendored crates and their versions +# +# The arguments for the internal "cargo tree" call emulate the logic +# that determines which crates are included when running "cargo vendor". +# The results are written to "cargo-vendor.txt". +%cargo_vendor_manifest()\ +%{shrink:\ + %{__cargo} tree \ + --workspace \ + --offline \ + --edges normal,build,dev \ + --no-dedupe \ + --target all \ + --all-features \ + --prefix none \ + --format "{p}" \ + | grep -v "$(pwd)" \ + | sed -e "s: (proc-macro)::" \ + | sort -u \ + > cargo-vendor.txt \ +} +