#11 "How to" page with packaging tutorial.
Opened 6 years ago by msehnout. Modified 6 years ago
fedora-rust/ msehnout/sig master  into  master

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

+ How to start

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

+ 

+ If you want to contribute to the Rust SIG, you can start by packaging some crates.

+ 

+ First of all you need to fork our `playground on Pagure`_::

+ 

+     $ git clone ssh://git@pagure.io/fedora-rust/playground.git

+     $ cd playground

+ 

+ Then you can package your own crate::

+ 

+     $ mkdir <crate> && cd <crate>

+     $ rust2rpm <crate>

+ 

+ In case you need to patch Cargo.toml (e.g. there are windows libraries as dependencies), you can either patch it manually or use rust2rpm with -p switch.

+ 

+ Now that you have a spec file, you can do a build using either rpmbuild or mock. In case you want to use rpmbuild, you just need to install dependencies to your system with dnf::

+ 

+     $ sudo dnf builddep rust-<crate>.spec

+ 

+ and it should work just fine

+ 

+ Note: If you are running Fedora 26, you need to install all necessary repositories and patched version of RPM (with rich deps). Later versions should work out of the box.

+ 

+ Now you need to run the build. Follow these steps::

+ 

+     $ rpmdev-setuptree # or rpmdev-wipetree in case you already have issued setuptree before

+     $ spectool -g <spec file> # will download all sources (usually crates)

+     $ rpmbuild -ba <spec file> -D "_sourcedir $(pwd)" # Build RPM package and use this directory as a source directory

+ 

+ The second option is to use `mock`_. First of all you need to install and configure mock::

+ 

+     $ sudo dnf install mock

+     $ sudo usermod -a -G mock <your_username>

+ 

+ Next create a source RPM using rpmbuild::

+ 

+     $ rpmbuild -bs <spec file>

+ 

+ Finally you must configure mock to use Rust SIG specific repositories. For example::

+ 

+     $ cp /etc/mock/fedora-26-x86_64.cfg <path-to-your-rusty-config>

+     $ vim <path-to-your-rusty-config>

+     # Now add this repository for newer RPM https://copr.fedorainfracloud.org/coprs/g/rpm-software-management/with-rich-dependency/

+     # and this one for Rust dependencies https://copr.fedorainfracloud.org/coprs/g/rust/playground/

+ 

+ and run it::

+ 

+     $ mock -r <path-to-your-rusty-config> rebuild <SRPM>

+ 

+ 

+ .. _playground on Pagure: https://pagure.io/fedora-rust/playground

+ .. _mock: https://github.com/rpm-software-management/mock/wiki

Tutorial based on my experience with rust2rpm.

Please don't suggest editing existing mock configs. Instead suggest to copy the config out and edit the copied config. mock supports arbitrary config file paths with -r. (For example: mock -r ~/fedora-26-x86_64-rust.cfg rebuild </path/to/package.src.rpm>)

or we should probably even create mock-rust-cfgs and Supplements: mock so users will get that automagically

@ngompa Good point. I should probably revert that change on my machine as well :)

1 new commit added

  • Don't modify system mock config file
6 years ago

1 new commit added

  • how to use rpmbuild with local sources
6 years ago

Do you have any more comments to this PR? I think we should publish it, so more people know how to use rust2rpm.

@msehnout The custom rpm stuff will not be required for Fedora 27 and up, so make note that this is Fedora 26 specific.

1 new commit added

  • note about f26 repos
6 years ago

@msehnout I will check this PR on this weekend, sorry for delay

Metadata
Changes Summary 1