Building cargo / rust software on community OBS

The last bit of info is that wl-cliboard-rs’s %{cargo_install} macro was rebuilding for i386. This was easily fixed with --target %{SB2_TARGET}.

I’ll try to recap what I needed to do for building cargo/rust software on OBS:

  • For each package you need to clone it locally and run cargo vendor --locked which produces a vendor/ folder and an output to add to cargo_config
  • Zip vendor (or tar) and create a cargo_config file with the output from the cargo vendor command. See for example cargo-packaging in OBS
  • Add vendor.tar.xz and cargo_config as Source1, Source2 etc. in the spec file and unpack the former and copy the latter in the %prep step, e.g. cargo-packaging.spec
  • Serialize the build… hopefully this will not be needed forever. If the spec uses cargo build --offline --release add -j1. If the spec uses %{cargo_build} then %define _smp_mflags -j1 before it.
  • Apply advice from the Wrong linker for Rust cross-compiling - #4 by R1tschY thread (which is also seen in xulrunner spec). I have done it like this for example.
  • If your package depends on cargo-packaging and uses %{cargo_install} append --target %{SB2_TARGET} to that macro invocation otherwise you’ll get an intel build.

Hope this helps somebody in the future;)

5 Likes