From afedde1f2b5fd0869a7d34c96038f550772ebb3b Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Thu, 17 Sep 2026 11:33:33 +0200 Subject: [PATCH] new: keep generated builds away from local build outputs and vendored autotools files --- src/new/debian.rs | 19 ++++++++++++++++--- src/new/mod.rs | 5 ++++- src/new/templates/rust.rs | 11 +++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/new/debian.rs b/src/new/debian.rs index 681874a..e03c811 100644 --- a/src/new/debian.rs +++ b/src/new/debian.rs @@ -107,9 +107,19 @@ fn source_format(opts: &NewOptions) -> OutputFile { /// `debian/source/local-options` with `single-debian-patch`, so later /// upstream-tree edits stay representable as one `debian/patches/debian-changes-*` -/// patch instead of failing the build (quilt only). +/// patch instead of failing the build (quilt only). Common build-output +/// directories are excluded from the delta as well: compiling locally before +/// a source build must not turn `target/`, `node_modules/` or `.venv/` +/// binaries into unrepresentable changes (dpkg ignores `__pycache__` and +/// friends by default, but not those). fn local_options() -> OutputFile { - OutputFile::new("debian/source/local-options", "single-debian-patch\n") + OutputFile::new( + "debian/source/local-options", + "single-debian-patch\n\ + extend-diff-ignore = ^target/\n\ + extend-diff-ignore = ^node_modules/\n\ + extend-diff-ignore = ^\\.venv/\n", + ) } /// `debian/changelog`: the single initial entry, distribution UNRELEASED by @@ -558,7 +568,10 @@ mod tests { assert_eq!(find("debian/source/format").contents, "3.0 (quilt)\n"); assert_eq!( find("debian/source/local-options").contents, - "single-debian-patch\n" + "single-debian-patch\n\ + extend-diff-ignore = ^target/\n\ + extend-diff-ignore = ^node_modules/\n\ + extend-diff-ignore = ^\\.venv/\n" ); let native = NewOptions { diff --git a/src/new/mod.rs b/src/new/mod.rs index 8a603d2..f90bea7 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -428,7 +428,10 @@ mod tests { ); assert_eq!( std::fs::read_to_string(tree.join("debian/source/local-options")).unwrap(), - "single-debian-patch\n" + "single-debian-patch\n\ + extend-diff-ignore = ^target/\n\ + extend-diff-ignore = ^node_modules/\n\ + extend-diff-ignore = ^\\.venv/\n" ); // Orig tarball: contains the skeleton file, excludes debian/. diff --git a/src/new/templates/rust.rs b/src/new/templates/rust.rs index 3501561..94dbd75 100644 --- a/src/new/templates/rust.rs +++ b/src/new/templates/rust.rs @@ -96,6 +96,11 @@ impl Template for Rust { /// created it, see [`patch_rules_locked`]); omitting it is always safe. /// The built artifact of a skeleton is named after its crate (a /// sanitized package name) and installed under the command name. + /// + /// `dh_update_autotools_config` is overridden away: crates embedding C + /// 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`. fn rules_extra(&self, opts: &NewOptions) -> String { let locked = if lockfile_present(opts) { " --locked" @@ -118,6 +123,8 @@ impl Template for Rust { override_dh_auto_test:\n\ \tcargo test --release --offline{locked}\n\ \n\ + override_dh_update_autotools_config:\n\ + \n\ override_dh_auto_clean:\n\ \tcargo clean\n", locked = locked, @@ -564,6 +571,10 @@ mod tests { let extra = template.rules_extra(&with_lock); assert!(extra.contains("\tcargo build --release --offline --locked\n")); assert!(extra.contains("\tcargo test --release --offline --locked\n")); + // debhelper refreshing embedded autotools files (e.g. `-sys` crates + // shipping config.sub/config.guess) would break cargo's per-file + // vendored checksums — the override skips the refresh entirely. + assert!(extra.contains("override_dh_update_autotools_config:\n")); } /// Package names may carry `+`/`.` (legal dpkg, rejected by cargo): the