Generate a pacman PKGBUILD for a Rust binary project, so you can install and remove it with pacman.
Zero dependencies, written in Rust. cratepkg never installs anything itself.
git clone https://github.com/lazybrar/cratepkg && cd cratepkg/pkg
makepkg -si
In any Rust project (or pass its path):
cratepkg init # writes pkg/PKGBUILD from Cargo.toml
cd pkg && makepkg -si # build and install with pacman
cratepkg build # or: only build the package (makepkg -f), print the pacman -U line
Options for init: --force (overwrite), --pkgname NAME (default: crate name, lowercased), --no-check (no check() running cargo test).
pkg/PKGBUILD(+pkg/.gitignore), so makepkg'ssrc/never clashes with the project'ssrc/.- Name, version, description, license (SPDX), url (
repositoryorhomepage) fromCargo.toml, including values inherited from[workspace.package]. - Every binary target (
src/main.rs,src/bin/*,[[bin]], honouringautobins = false), plus README* and LICENSE*/COPYING*. !debug,depends=('gcc-libs' 'glibc'),makedepends=('cargo'),arch=('x86_64' 'aarch64').- With a
Cargo.lock:prepare()fetches with--locked, and build/test use--frozen. - Extra files: everything under
pkg/overlay/is copied into the package as is, e.g.pkg/overlay/usr/lib/systemd/system/foo.serviceorsysusers.d/tmpfiles.dentries.
The package builds from the local project tree, not from a downloaded tarball.
- Binary crates only; library-only crates are rejected.
- The workspace root itself can't be packaged; run it on a member crate's path.
- Reads
Cargo.tomlwith a small purpose-built parser: multi-line strings for the fields it reads are rejected with an error rather than guessed. - Packages are named after the crate; check for name clashes in the Arch repos/AUR and use
--pkgnameif needed.
GPL-2.0-or-later. See LICENSE.