#9 packaging
Opened 7 years ago by ignatenkobrain. Modified 7 years ago

file modified
+6
@@ -24,6 +24,12 @@ 

  

  .. _ripgrep: https://github.com/BurntSushi/ripgrep

  

+ ---------

+ Packaging

+ ---------

+ 

+ You can find packaging guidelines and hints on :ref:`packaging` page.

+ 

  --------

  Meetings

  --------

file added
+283
@@ -0,0 +1,283 @@ 

+ .. _packaging:

+ 

+ =========

+ Packaging

+ =========

+ 

+ Apart from guidelines mentioned below, package must follow `Fedora Packaging Guidelines`_.

+ 

+ .. _Fedora Packaging Guidelines: https://fedoraproject.org/wiki/Packaging:Guidelines

+ 

+ ------

+ Naming

+ ------

+ 

+ Source package **MUST** be named *rust-$crate*.

+ 

+  * If package provide binaries, those **SHOULD** be in *$crate* subpackage

+  * If package provide library, it **MUST** be in *rust-$crate-devel* subpackage

+ 

+ where *$crate* is name on crates.io.

+ 

+ -------------

+ ExclusiveArch

+ -------------

+ 

+ Packages **MUST** have ``ExclusiveArch: %{rust_arches}```.

+ 

+ ------------

+ Dependencies

+ ------------

+ 

+ Packagers **MUST** use ``with`` rich dependency operator and specify exact version range for dependencies and their features.

+ 

+ -------------

+ BuildRequires

+ -------------

+ 

+ Packages **MUST** have ``BuildRequires: rust`` and ``BuildRequires: cargo``.

+ 

+ --------

+ Examples

+ --------

+ 

+ Library

+ =======

+ 

+ ::

+ 

+     %bcond_without check

+ 

+     %global debug_package %{nil}

+ 

+     %global crate synom

+ 

+     Name:           rust-%{crate}

+     Version:        0.11.3

+     Release:        1%{?dist}

+     Summary:        Stripped-down Nom parser used by Syn

+ 

+     License:        MIT or ASL 2.0

+     URL:            https://crates.io/crates/synom

+     Source0:        https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate

+ 

+     ExclusiveArch:  %{rust_arches}

+ 

+     BuildRequires:  rust

+     BuildRequires:  cargo

+     # [dependencies]

+     BuildRequires:  (crate(unicode-xid) >= 0.0.4 with crate(unicode-xid) < 0.0.5)

+     %if %{with check}

+     # [dev-dependencies]

+     BuildRequires:  ((crate(syn) >= 0.11.0 with crate(syn) < 0.12.0) with crate(syn/parsing) with crate(syn/full))

+     %endif

+ 

+     %description

+     %{summary}.

+ 

+     %package        devel

+     Summary:        %{summary}

+     BuildArch:      noarch

+ 

+     %description    devel

+     Stripped-down Nom parser used by Syn.

+ 

+     This package contains library source intended for building other packages

+     which use %{crate} from crates.io.

+ 

+     %prep

+     %autosetup -n %{crate}-%{version} -p1

+     %cargo_prep

+ 

+     %build

+     %cargo_build

+ 

+     %install

+     %cargo_install

+ 

+     %if %{with check}

+     %check

+     %cargo_test

+     %endif

+ 

+     %files          devel

+     %license LICENSE-MIT LICENSE-APACHE

+     %doc README.md

+     %{cargo_registry}/%{crate}-%{version}/

+ 

+     %changelog

+ 

+ Binary

+ ======

+ 

+ ::

+ 

+     %bcond_without check

+ 

+     %global crate ripgrep

+ 

+     Name:           rust-%{crate}

+     Version:        0.4.0

+     Release:        6%{?dist}

+     Summary:        Line oriented search tool using Rust's regex library

+ 

+     License:        Unlicense or MIT

+     URL:            https://crates.io/crates/ripgrep

+     Source0:        https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate

+     # Initial patched metadata

+     # * No windows

+     # * No simd

+     # * Bump env_logger, https://github.com/BurntSushi/ripgrep/pull/382

+     # * Bump termcolor, https://github.com/BurntSushi/ripgrep/commit/a114b860635c98198d53e6ba8ed37c88df2c5cc3

+     Patch0:         ripgrep-0.4.0-fix-metadata.diff

+     # Fix build with new termcolor, https://github.com/BurntSushi/ripgrep/commit/22cb644eb6fc7872c1a0e5e084791b87382014b4

+     Patch1:         0001-termcolor-add-support-for-output-to-standard-error.patch

+ 

+     ExclusiveArch:  %{rust_arches}

+ 

+     BuildRequires:  rust

+     BuildRequires:  cargo

+     # [dependencies]

+     BuildRequires:  (crate(bytecount) >= 0.1.4 with crate(bytecount) < 0.2.0)

+     BuildRequires:  (crate(clap) >= 2.19.0 with crate(clap) < 3.0.0)

+     BuildRequires:  (crate(env_logger) >= 0.4.0 with crate(env_logger) < 0.5.0)

+     BuildRequires:  (crate(grep) >= 0.1.5 with crate(grep) < 0.2.0)

+     BuildRequires:  (crate(ignore) >= 0.1.7 with crate(ignore) < 0.2.0)

+     BuildRequires:  (crate(lazy_static) >= 0.2.0 with crate(lazy_static) < 0.3.0)

+     BuildRequires:  (crate(libc) >= 0.2.0 with crate(libc) < 0.3.0)

+     BuildRequires:  (crate(log) >= 0.3.0 with crate(log) < 0.4.0)

+     BuildRequires:  (crate(memchr) >= 1.0.0 with crate(memchr) < 2.0.0)

+     BuildRequires:  (crate(memmap) >= 0.5.0 with crate(memmap) < 0.6.0)

+     BuildRequires:  (crate(num_cpus) >= 1.0.0 with crate(num_cpus) < 2.0.0)

+     BuildRequires:  (crate(regex) >= 0.2.1 with crate(regex) < 0.3.0)

+     BuildRequires:  (crate(same-file) >= 0.1.1 with crate(same-file) < 0.2.0)

+     BuildRequires:  (crate(termcolor) >= 0.3.0 with crate(termcolor) < 0.4.0)

+     # [build-dependencies]

+     BuildRequires:  (crate(clap) >= 2.18.0 with crate(clap) < 3.0.0)

+     BuildRequires:  (crate(lazy_static) >= 0.2.0 with crate(lazy_static) < 0.3.0)

+ 

+     %description

+     %{summary}.

+ 

+     %package     -n %{crate}

+     Summary:        %{summary}

+     

+     %description -n %{crate}

+     Line oriented search tool using Rust's regex library. Combines

+     the raw performance of grep with the usability of the silver searcher.

+ 

+     %prep

+     %autosetup -n %{crate}-%{version} -p1

+     %cargo_prep

+ 

+     %build

+     %cargo_build

+ 

+     %install

+     %cargo_install

+     install -D -p -m0644 doc/rg.1 %{buildroot}%{_mandir}/man1/rg.1

+ 

+     %if %{with check}

+     %check

+     %cargo_test

+     %endif

+ 

+     %files -n %{crate}

+     %license LICENSE-MIT UNLICENSE COPYING

+     %doc README.md CHANGELOG.md

+     %{_bindir}/rg

+     %{_mandir}/man1/rg.1*

+ 

+     %changelog

+ 

+ Binary + Library

+ ================

+ 

+ ::

+ 

+     %bcond_without check

+ 

+     %global crate rustfmt

+ 

+     Name:           rust-%{crate}

+     Version:        0.7.1

+     Release:        3%{?dist}

+     Summary:        Tool to find and fix Rust formatting issues

+ 

+     # https://github.com/rust-lang-nursery/rustfmt/issues/1340

+     License:        ASL 2.0 or MIT

+     URL:            https://crates.io/crates/rustfmt

+     Source0:        https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate

+     # Initial patched metadata

+     # * No windows

+     Patch0:         rustfmt-0.7.1-fix-metadata.diff

+     # https://github.com/rust-lang-nursery/rustfmt/pull/1338

+     Patch1:         0001-bump-env_logger-to-0.4.patch

+     Patch2:         0002-bump-regex-to-0.2.patch

+     Patch3:         0003-bump-syntex_-to-0.58.patch

+ 

+     ExclusiveArch:  %{rust_arches}

+ 

+     BuildRequires:  rust

+     BuildRequires:  cargo

+     # [dependencies]

+     BuildRequires:  (crate(diff) >= 0.1.0 with crate(diff) < 0.2.0)

+     BuildRequires:  (crate(env_logger) >= 0.4.0 with crate(env_logger) < 0.5.0)

+     BuildRequires:  (crate(getopts) >= 0.2.0 with crate(getopts) < 0.3.0)

+     BuildRequires:  (crate(itertools) >= 0.5.8 with crate(itertools) < 0.6.0)

+     BuildRequires:  (crate(libc) >= 0.2.11 with crate(libc) < 0.3.0)

+     BuildRequires:  (crate(log) >= 0.3.0 with crate(log) < 0.4.0)

+     BuildRequires:  (crate(multimap) >= 0.3.0 with crate(multimap) < 0.4.0)

+     BuildRequires:  (crate(regex) >= 0.2.0 with crate(regex) < 0.3.0)

+     BuildRequires:  (crate(rustc-serialize) >= 0.3.0 with crate(rustc-serialize) < 0.4.0)

+     BuildRequires:  (crate(strings) >= 0.0.1 with crate(strings) < 0.0.2)

+     BuildRequires:  (crate(syntex_errors) >= 0.58.0 with crate(syntex_errors) < 0.59.0)

+     BuildRequires:  (crate(syntex_syntax) >= 0.58.0 with crate(syntex_syntax) < 0.59.0)

+     BuildRequires:  (crate(term) >= 0.4.0 with crate(term) < 0.5.0)

+     BuildRequires:  (crate(toml) >= 0.2.1 with crate(toml) < 0.3.0)

+     BuildRequires:  (crate(unicode-segmentation) >= 1.0.0 with crate(unicode-segmentation) < 2.0.0)

+     # [build-dependencies]

+     BuildRequires:  (crate(walkdir) >= 1.0.3 with crate(walkdir) < 2.0.0)

+ 

+     %description

+     %{summary}.

+ 

+     %package     -n %{crate}

+     Summary:        %{summary}

+ 

+     %description -n %{crate}

+     Tool to find and fix Rust formatting issues.

+ 

+     %package        devel

+     Summary:        %{summary}

+     BuildArch:      noarch

+ 

+     %description    devel

+     Tool to find and fix Rust formatting issues.

+ 

+     This package contains library source intended for building other packages

+     which use %{crate} from crates.io.

+ 

+     %prep

+     %autosetup -n %{crate}-%{version} -p1

+     %cargo_prep

+ 

+     %build

+     %cargo_build

+ 

+     %install

+     %cargo_install

+ 

+     %if %{with check}

+     %check

+     %cargo_test

+     %endif

+ 

+     %files       -n %{crate}

+     %{_bindir}/rustfmt

+     %{_bindir}/cargo-fmt

+ 

+     %files          devel

+     %{cargo_registry}/%{crate}-%{version}/

+ 

+     %changelog

The given library example uses rust-foo for the srpm and rust-foo-devel.

Also, what happens if a library-only or binary-only crate later becomes dual-purpose?

as in other ecosystems, we rename it

Most ecosystems have main generic package name, and everything is subpackages underneath. That way, you can avoid the renaming process.

So I would go with the source package being rust-foo in all cases.

I would suggest an inline example here.

What about guidelines for how BuildRequires for crates should be structured? It seems like a specific case of what we do for Dependencies.

Alternatively, I think it might make sense to fold in BuildRequires section into Dependencies in general. It's really a subtopic of it anyway...

I suggest source package name should always be rust-%{crate} for this case.

rebased

7 years ago

I think we should use Google docs instead of git for faster collaboration, since we have only one week to prepare these guidelines. Of course I expect to switch back after we are done.

We are discussing changes for this PR here, if you want to contribute:
https://docs.google.com/document/d/1yx6TmybWdu82geF7H47JjowYf6_x6NaIT2UJ_znUtYM/edit?usp=sharing

Metadata