# dh-rust

This project began as a fork of the debhelper script [dh-cargo],
with these functional changes:

  * support workspace (i.e. multi-crate project),
    * resolve crate name and version from Cargo.toml,
      using X-Cargo-Crates hint or library package name only as key
    * support debhelper options --sourcedirectory --builddirectory
    * support debhelper option --no-package
    * validate package names against Cargo.toml entries,
      failing early (not after test) on crate vs. package mismatch
    * generate cargo-checksum during install
    * pass cargo --remap-path-prefix option sets in RUSTFLAGS
  * allow overriding CARGO_HOME
  * install crate contents using "cargo package"
    * omit license files, Cargo.toml.orig, and debian/patches
      (see bug#880689)
  * use debian/Cargo.lock or Cargo.lock (in that order) during build,
    if Cargo.lock exists
  * use crates below debian/vendorlibs when available
  * use dh_auto_build
    (not confusingly only dh_auto_test)

Also included is a slight fork of related [cargo] wrapper script,
with these functional changes:

  * support CARGO_MANIFEST_DIR=${debhelper_sourcedirectory}
  * support --remap-path-prefix option sets in RUSTFLAGS
    by omitting that (not fail) when DEB_CARGO_CRATE is not set
  * support documented shorter CARGO_HOME path
  * support cargo option --path
  * fix only inject path for "cargo install" when not passed as option
  * support DEB_BUILD_OPTIONS=terse
  * warn when cargo wrapper bails due to mismatching CARGO_HOME
  * add suffix .toml to config file,
    supported since cargo 1.39
  * enable optimization flags by default also for tests,
    and support DEB_BUILD_OPTIONS=noopt

[dh-cargo]: <https://salsa.debian.org/rust-team/dh-cargo/-/blob/master/cargo.pm>

[cargo]: <https://salsa.debian.org/rust-team/cargo/-/blob/debian/sid/debian/bin/cargo>

 -- Jonas Smedegaard <dr@jones.dk>  Sat, 20 Sep 2025 20:18:13 +0200
