No description
Find a file
Zbigniew Jędrzejewski-Szmek a57d4b2c95 Automatically strip foreign dependencies
The basic workflow is that very similarly to how we would open an editor to do
manual patching of Cargo.toml, we automatically rewrite the file first. In this
automatic rewrite, for any sections like [target.cfg(…)], we evaluate the
conditional and drop the whole section if the conditional is known to be false.

When the conditional cannot be evaluated because it uses some form that we don't
understand, it is left untouched. But it seems that the conditionals used in
practice don't have too much variety. If parser and evaluator certainly don't
cover all the corner cases, but it might not matter in practice. We can always
fix them later if unsupported cases are found.

Removed dependencies are filter out from [feature] lists:

For example for tokio:
[features]
-net = ["libc", "mio/os-poll", "mio/os-ext", "mio/net", "socket2", "winapi/namedpipeapi"]
+net = ["libc", "mio/os-poll", "mio/os-ext", "mio/net", "socket2"]

If -p was used, after the automatic filtering, the editor is opened for the user
to do further manual patching.

Automatic and manual changes land in separate patches.

Fixes #2.
2022-07-12 10:48:16 +02:00
data macros.cargo: vacuum up Cargo.toml.orig in addition to Cargo.lock 2022-07-01 19:29:56 +02:00
rust2rpm Automatically strip foreign dependencies 2022-07-12 10:48:16 +02:00
tools fedora-helper: Use f35 as a base for license generation 2021-03-07 21:40:31 +01:00
.gitignore
LICENSE
MANIFEST.in Translate SPDX licenses to Fedora license tags, warn about "/" 2018-08-16 16:16:02 +02:00
NEWS Version 21 2022-02-20 15:51:04 +01:00
README.md Allow setting the "all-features" setting in rust2rpm.conf 2022-06-06 21:37:00 +02:00
requirements.txt metadata: replace semantic-version with a custom parser 2019-10-28 11:19:46 +01:00
setup.py setup: bump development status to "production" 2021-11-28 12:50:37 +01:00
tox.ini Add python 3.10 to tox.ini 2021-10-14 18:41:02 +02:00

rust2rpm

rust2rpm is a tool for automatically generating RPM spec files for Rust crates.

rust2rpm.conf

If it is present, a rust2rpm.conf configuration file is read by rust2rpm to override some aspects of the automatic spec file generation.

This file can be committed to dist-git to ensure that these settings will be applied for future updates of a crate package, as well.

The file follows a slightly modified ini syntax. It supports sections for default settings ([DEFAULT]) and target-specific settings (i.e. [fedora]).

These configuration options are available right now:

  • all-features: enable all cargo features when generating BuildRequires, building the crate, and running cargo tests (defaults to false; setting this value to true is equivalent to supplying the --all-features CLI flag)
  • unwanted-features: features or optional dependencies for which no +feature subpackage should be generated (for example, dependencies on Rust compiler internals for crates that are also bundled with Rust itself)
  • buildrequires: additional build dependencies that must be installed for the package to build correctly (i.e., pkgconfig(foo) for the foo-sys crate)
  • lib.requires: additional build dependencies that must be installed for the crate to build correctly as a dependency of another crate (usually, this contains the same values as the buildrequires option)
  • lib+foo.requires: additional build dependencies that must be installed for the crate to build correctly as a dependency of another crate if it has enabled the optional foo feature
  • bin.requires: additional runtime dependencies of the binary application that is built from this crate
[DEFAULT]
unwanted-features =
  compiler_builtins
  rustc-dep-of-std
buildrequires =
  pkgconfig(foo) >= 1.2.3
lib.requires =
  pkgconfig(foo) >= 1.2.3

[fedora]
bin.requires =
  findutils
buildrequires =
lib.requires =
lib+default.requires =
  pkgconfig(bar) >= 2.0.0

Note that features and optional dependencies that are marked as unwanted-features must not be dependencies of other Cargo features that are not marked "unwanted" as well. Failing to consider transitive dependencies will lead to broken dependencies of generated rust-foo+bar-devel packages and / or errors when generating spec files with rust2rpm.