diff --git a/src/new/templates/rust.rs b/src/new/templates/rust.rs index 94dbd75..7454f24 100644 --- a/src/new/templates/rust.rs +++ b/src/new/templates/rust.rs @@ -101,6 +101,9 @@ impl Template for Rust { /// sources (e.g. `-sys` crates shipping `config.sub`/`config.guess`) /// carry per-file cargo checksums, and debhelper refreshing those files /// with the system's newer copies would break `cargo build --offline`. + /// `dh_clean` gets `-X Cargo.toml.orig` for the same reason: it treats + /// every vendored `Cargo.toml.orig` as a patch backup and deletes it, + /// which breaks the checksums on any build without a warm cache. fn rules_extra(&self, opts: &NewOptions) -> String { let locked = if lockfile_present(opts) { " --locked" @@ -125,6 +128,12 @@ impl Template for Rust { \n\ override_dh_update_autotools_config:\n\ \n\ + override_dh_clean:\n\ + \t# dh_clean unlinks `*.orig` patch backups, but vendored crates\n\ + \t# ship files like `Cargo.toml.orig` that cargo's per-file\n\ + \t# checksums require on cold builds (chroots, Launchpad).\n\ + \tdh_clean -X .orig\n\ + \n\ override_dh_auto_clean:\n\ \tcargo clean\n", locked = locked, @@ -552,6 +561,8 @@ mod tests { ); assert!(extra.contains("override_dh_auto_test:\n\tcargo test --release --offline\n")); assert!(extra.contains("override_dh_auto_clean:\n\tcargo clean")); + assert!(extra.contains("override_dh_clean:")); + assert!(extra.contains("\tdh_clean -X .orig")); assert!(!extra.contains("--locked")); }