From 2b017dcf437a3595d09962b8bdc675501f72de22 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Thu, 17 Sep 2026 23:54:52 +0200 Subject: [PATCH] new: keep vendored *.orig files through dh_clean in the rust rules dh_clean unlinks *.orig patch backups, and vendored crates carry Cargo.toml.orig (and the occasional *.xml.orig) that cargo's per-file checksums require on cold builds. Override dh_clean with -X .orig. --- src/new/templates/rust.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) 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")); }