cargo-deb
Create Debian packages from Rust projects
TLDR
Create a Debian package from a project
Write the .deb file to the specified file or directory
Compile for the specified Rust target triple
Select which package to use in a Cargo workspace
Immediately install the created package
SYNOPSIS
cargo deb [-p SPEC …] [--target TRIPLE] [--variant NAME] [-- BUILD_ARGS …]
PARAMETERS
-p, --package SPEC…
Package to build (see cargo pkgid)
--manifest-path PATH
Path to Cargo.toml
--target TRIPLE
Triple to build for
--target-dir DIR
Target build directory
--variant NAME
Build with specified variant
--no-build
Skip building the package
--deb-version VERSION
Override Debian version
--revision REVISION
Override Debian revision
--features FEATURES…
Space/comma-separated features
--no-default-features
Disable default features
--all-features
Activate all available features
--init
Initialize debian/ directory
--dry-run
Print commands without executing
-v…, --verbose …
Increase verbosity
-h, --help
Print help
-V, --version
Print version
DESCRIPTION
Cargo-deb is a Cargo subcommand designed to streamline building Debian (.deb) packages from Rust projects. It integrates Cargo's build system with Debian packaging tools like debhelper and dh-cargo, automatically generating compliant binary and source packages.
Key features include handling Cargo.toml metadata (name, version, dependencies), support for multiple binaries, workspaces, and features. Users can customize via a debian/ directory for control files, rules.d, patches, or inline Cargo metadata like [[package.metadata.deb]].
Installation: cargo install cargo-deb. Basic usage: cd your-rust-project && cargo deb, producing files in target/debian/. It supports cross-compilation (--target), variants for suites (--variant), dependency overrides, and dry runs. Ideal for Debian/Ubuntu packaging, it respects Rust toolchain versions and generates fields like Depends, Suggests.
Cargo-deb reduces boilerplate, ensuring reproducible builds and Debian policy compliance, making Rust apps/libraries distributable on .deb-based systems.
CAVEATS
Requires debhelper, dh-cargo, build-essential on Debian systems; cross-compilation needs additional Rust targets/toolchains. Not for non-Debian distros without adaptation.
INSTALLATION
cargo install cargo-deb; available in Debian/Ubuntu repos as cargo-deb.
OUTPUT
Generates .deb in target/debian/<pkg>*.deb; use --no-act to simulate.
HISTORY
Created by Michael Stahl (mmstick) in 2017 for Rust Debian packaging; evolved with Rust ecosystem, now maintained by cargo-deb org. Integrated into Debian Rust team workflows since ~2018.


