rust2rpm/data/cargo_bundled.attr

4 lines
214 B
Text
Raw Normal View History

Add bundled() provider for vendoring This commit add basic support for crate vendoring in Rust. The user will use something like `cargo vendor` to create a vendor directory (that can later be deployed as a tgz) that contains all the dependencies. This patch will analyze the output of `cargo manifest` to calculate the closure of dependencies, and via the new parameter `--provides-vendor`, print all the 'bundled(crate(NAME/FEATURE)) = 0.0.0' provided by the binary. The algorithm is not perfect, as today it will include all the features resolved for the crate (not all the availables, tho), but basically is something like: 1.- A dependency generator macro, cargo_bundled, will call cargo-inspector like this: # In STDIN we will provide the name of the binary cargo-inspector --provides-vendor --path %{_builddir} 2.- cargo-inspector will search inside the 'path' tree a Cargo.toml that generate the binary name send via STDIN. 3.- From this point, we go up to the tree to find the top-most Cargo.toml, as this will be the directory where .cargo/config is living. We make this directory our `cwd`. 4.- Using the metadata from `cargo manifest`, we generate the closure of dependencies required by this binary. To simplify the problem, the current code do not resolve the features, and accept the one resolved by cargo as valid. Most of the time this will be OK, maybe will include some extra features needed for other binaries. 5.- Print the 'bundled()' data. This code will only be executed in the directory 'vendor' is present in the top-most directory found on step 3.
2019-12-17 16:22:45 +00:00
%__cargo_bundled_provides %{_bindir}/cargo-inspector --provides-vendor --path %{_builddir}
%__cargo_bundled_flags exeonly
%__cargo_bundled_magic ^(setuid,? )?(setgid,? )?(sticky )?ELF (32|64)-bit.*executable