| |
@@ -1,12 +1,26 @@
|
| |
= Rust Packaging Guidelines
|
| |
|
| |
- This document details best practices for packaging Rust crates. Note that the rust2rpm tool, available as a Fedora package or at https://pagure.io/fedora-rust/rust2rpm, automates many of these steps. It is advisable to try `+rust2rpm $crate+` first before attempting to write a specfile by hand.
|
| |
+ This document details best practices for packaging Rust crates.
|
| |
+ Note that the rust2rpm tool,
|
| |
+ available as a Fedora package or at https://pagure.io/fedora-rust/rust2rpm,
|
| |
+ automates many of these steps.
|
| |
+ It is advisable to try `+rust2rpm $crate+` first
|
| |
+ before attempting to write a specfile by hand.
|
| |
+
|
| |
+ CAUTION: This document is applicable only for Rawhide.
|
| |
+ Stable releases do not contain any crates.
|
| |
+ However, it can be used to build modules with Rust applications
|
| |
+ (with filtered build-time dependencies).
|
| |
|
| |
== Naming
|
| |
|
| |
- Rust crates MUST be named `rust-$crate`. The crates are expected to be from https://crates.io[crates.io]. Rust applications that aren't from crates.io MUST follow the main guidelines for package names.
|
| |
+ Rust crates MUST be named `rust-$crate`.
|
| |
+ The crates are expected to be from https://crates.io[crates.io].
|
| |
+ Rust applications that aren't from crates.io MUST follow the main guidelines for package names.
|
| |
|
| |
- At this time, Rust libraries MUST be from crates.io, as this enforces a certain standard in how they are packaged and built.
|
| |
+ At this time,
|
| |
+ Rust libraries MUST be from crates.io,
|
| |
+ as this enforces a certain standard in how they are packaged and built.
|
| |
|
| |
== Dependencies
|
| |
|
| |
@@ -14,17 +28,36 @@
|
| |
|
| |
=== Automatic Dependency Generation
|
| |
|
| |
- `rust-packaging` automatically creates Requires/Provides based on `+%{cargo_registry}/*/Cargo.toml+` files.
|
| |
+ `rust-packaging` automatically creates Requires/Provides
|
| |
+ based on `+%{cargo_registry}/*/Cargo.toml+` files.
|
| |
|
| |
- The Provides generator creates `+crate($name) = $version+` and `+crate($name/$feature) = $version+` for each "feature" the crate provides.
|
| |
+ The Provides generator creates:
|
| |
|
| |
- The automatic requirement generator takes this into account and creates the appropriate rich dependency to ensure that the code works.
|
| |
+ * `+crate($name) = $version+` for base package (`+rust-$name-devel+`)
|
| |
+ * `+crate($name/$feature) = $version+` for feature subpackages (`+rust-$name+$feature-devel+`)
|
| |
|
| |
- For example, `+syn = { version = "0.11", features = ["visit"] }+` becomes `+Requires: ((crate(syn) >= 0.11.0 with crate(syn) < 0.12.0) with crate(syn/visit))+`.
|
| |
+ The automatic requirement generator takes this into account
|
| |
+ and creates the appropriate rich dependencies
|
| |
+ to ensure that the code works.
|
| |
+
|
| |
+ For example:
|
| |
+
|
| |
+ ....
|
| |
+ syn = { version = "0.15", features = ["visit", "extra-traits"] }
|
| |
+ ....
|
| |
+
|
| |
+ becomes
|
| |
+
|
| |
+ ....
|
| |
+ (crate(syn/default) >= 0.15.0 with crate(syn/default) < 0.16.0)
|
| |
+ (crate(syn/extra-traits) >= 0.15.0 with crate(syn/extra-traits) < 0.16.0)
|
| |
+ (crate(syn/visit) >= 0.15.0 with crate(syn/visit) < 0.16.0)
|
| |
+ ....
|
| |
|
| |
=== BuildRequires
|
| |
|
| |
- Packagers MUST specify all BuildRequires according to the definition in Cargo.toml, for example:
|
| |
+ Packagers MUST specify all BuildRequires according to the definition in Cargo.toml,
|
| |
+ for example:
|
| |
|
| |
....
|
| |
[dependencies]
|
| |
@@ -36,19 +69,17 @@
|
| |
should become
|
| |
|
| |
....
|
| |
- # [dependencies]
|
| |
- BuildRequires: (crate(atty) >= 0.2.2 with crate(atty) < 0.3.0)
|
| |
- # [build-dependencies]
|
| |
- BuildRequires: (crate(clap) >= 2.24.1 with crate(clap) < 3.0.0)
|
| |
+ BuildRequires: (crate(atty/default) >= 0.2.2 with crate(atty/default) < 0.3.0)
|
| |
+ BuildRequires: (crate(clap/default) >= 2.24.1 with crate(clap/default) < 3.0.0)
|
| |
....
|
| |
|
| |
=== Versions
|
| |
|
| |
- Packagers SHOULD use latest version of dependent crates.
|
| |
-
|
| |
- Packagers SHOULD patch crates to use the latest version of dependent crates to reduce maintenance burden.
|
| |
-
|
| |
- When doing so, packagers SHOULD forward these upstream so that the upstream software is fixed to support the latest versions of their dependencies.
|
| |
+ * Packagers SHOULD use latest version of dependent crates.
|
| |
+ * Packagers SHOULD patch crates to use the latest version of dependent crates to reduce maintenance burden.
|
| |
+ * When doing so,
|
| |
+ packagers SHOULD forward these upstream
|
| |
+ so that the upstream software is fixed to support the latest versions of their dependencies.
|
| |
|
| |
== ExclusiveArch
|
| |
|
| |
@@ -56,7 +87,8 @@
|
| |
|
| |
== Others
|
| |
|
| |
- Packagers MUST run `+%cargo_prep+` to prepare configuration for further cargo invocations (sets up RUSTFLAGS and all other stuff).
|
| |
+ Packagers MUST run `+%cargo_prep+` to prepare configuration for further cargo invocations
|
| |
+ (sets up RUSTFLAGS and all other stuff).
|
| |
|
| |
=== Exclude unnecessary files
|
| |
|
| |
@@ -82,32 +114,30 @@
|
| |
|
| |
=== Nightly, Other Platforms, etc. crates
|
| |
|
| |
- Packagers MUST NOT package crates which do not work with the distribution. That is, if the crate depends on nightly-only features or works only for non-Linux platforms, the crate is not suitable for inclusion in Fedora.
|
| |
+ Packagers MUST NOT package crates which do not work with the distribution.
|
| |
+ That is,
|
| |
+ if the crate depends on nightly-only features
|
| |
+ or works only for non-Linux platforms,
|
| |
+ the crate is not suitable for inclusion in Fedora.
|
| |
|
| |
- If the crate can be made usable, packagers MUST patch packages which use such dependencies, for example:
|
| |
+ If the crate can be made usable,
|
| |
+ packagers MUST patch packages which use such dependencies,
|
| |
+ for example:
|
| |
|
| |
[source,diff]
|
| |
----
|
| |
- --- cryptovec-0.3.4/Cargo.toml 2017-05-20T16:48:34+02:00
|
| |
- +++ cryptovec-0.3.4/Cargo.toml 2017-06-20T16:02:18.204182+02:00
|
| |
- @@ -10,5 +10,3 @@
|
| |
+ --- memmap-0.7.0/Cargo.toml 1970-01-01T00:00:00+00:00
|
| |
+ +++ memmap-0.7.0/Cargo.toml 2019-03-18T19:59:43.683403+00:00
|
| |
+ @@ -23,9 +23,6 @@
|
| |
+ version = "0.3"
|
| |
+ [target."cfg(unix)".dependencies.libc]
|
| |
+ version = "0.2"
|
| |
+ -[target."cfg(windows)".dependencies.winapi]
|
| |
+ -version = "0.3"
|
| |
+ -features = ["basetsd", "handleapi", "memoryapi", "minwindef", "std", "sysinfoapi"]
|
| |
+ [badges.appveyor]
|
| |
+ repository = "danburkert/mmap"
|
| |
|
| |
- [dependencies]
|
| |
- libc = "0.2"
|
| |
- -winapi = "0.2"
|
| |
- -kernel32-sys = "0.2"
|
| |
- --- cryptovec-0.3.4/src/lib.rs 2017-05-20 16:48:10.000000000 +0200
|
| |
- +++ cryptovec-0.3.4/src/lib.rs 2017-06-20 16:04:31.530991420 +0200
|
| |
- @@ -13,7 +13,9 @@
|
| |
- // limitations under the License.
|
| |
- //
|
| |
- extern crate libc;
|
| |
- +#[cfg(windows)]
|
| |
- extern crate winapi;
|
| |
- +#[cfg(windows)]
|
| |
- extern crate kernel32;
|
| |
- use libc::{malloc, free, c_void};
|
| |
- #[cfg(not(windows))]
|
| |
----
|
| |
|
| |
Such patches SHOULD be forwarded upstream.
|
| |
@@ -116,17 +146,20 @@
|
| |
|
| |
=== Library
|
| |
|
| |
- Rust library packages are packaged as source-only packages, as we do not build dynamic link libraries at this time due to the lack of a stabilized ABI for Rust.
|
| |
+ Rust library packages are packaged as source-only packages,
|
| |
+ as we do not build dynamic link libraries at this time
|
| |
+ due to the lack of a stabilized ABI for Rust.
|
| |
|
| |
- .rust-clap.spec
|
| |
+ .rust-serde.spec
|
| |
[source]
|
| |
----
|
| |
- include::{examplesdir}/rust-clap.spec[]
|
| |
+ include::{examplesdir}/rust-serde.spec[]
|
| |
----
|
| |
|
| |
=== Binary
|
| |
|
| |
- Application packages are compiled into binaries, with the application name used as the package name for the output binary package.
|
| |
+ Application packages are compiled into binaries,
|
| |
+ with the application name used as the package name for the output binary package.
|
| |
|
| |
.rust-ripgrep.spec
|
| |
[source]
|
| |
@@ -136,8 +169,8 @@
|
| |
|
| |
=== Library + Binary
|
| |
|
| |
- .rust-cbindgen.spec
|
| |
+ .rust-yubibomb.spec
|
| |
[source]
|
| |
----
|
| |
- include::{examplesdir}/rust-cbindgen.spec[]
|
| |
+ include::{examplesdir}/rust-yubibomb.spec[]
|
| |
----
|
| |
Signed-off-by: Igor Gnatenko ignatenkobrain@fedoraproject.org