deb: strip VCS metadata from prepared build trees
CI / build (push) Successful in 2m53s
CI / test (push) Skipped
CI / snap (push) Failing after 23s

Copying a git checkout verbatim into /tmp/pkh-build-*/ ships '.git',
flipping autotools' building-from-VCS detection (GNU hello's
BUILD_FROM_GIT): the shipped man page gets cleaned and regenerated
via help2man, which is correctly not in Build-Depends. Skip VCS
dirs (.git/.hg/.svn/.bzr/CVS) in local/unshare/ssh copies, and
prune them after an unshare overlayfs mount.
This commit is contained in:
2026-08-24 17:33:44 +02:00
parent 9f47e7dae8
commit 86612efb00
4 changed files with 121 additions and 0 deletions
+22
View File
@@ -55,6 +55,14 @@ fn copy_dir_recursive(src: &Path, dest: &Path) -> io::Result<()> {
}
};
// Never ship VCS metadata into the build tree: its presence flips
// autotools 'building from VCS' detection (see is_vcs_dir_name) and
// activates maintainer-only regeneration rules requiring tools that
// are not declared build-dependencies (e.g. help2man).
if metadata.is_dir() && super::is_vcs_dir_name(&entry.file_name()) {
continue;
}
if metadata.file_type().is_symlink() {
let target = std::fs::read_link(&src_path).map_err(|e| {
io::Error::new(
@@ -428,6 +436,20 @@ impl UnshareDriver {
.lock()
.unwrap()
.push(dest_path.to_path_buf());
// The overlay exposes the source tree verbatim: strip VCS metadata
// (e.g. '.git') whose presence would flip autotools 'building from
// git' detection and activate maintainer-only regeneration rules
// (see is_vcs_dir_name). Removals land as whiteouts in the upper
// layer, leaving the lowerdir untouched.
if let Err(e) = super::prune_vcs_dirs(dest_path) {
log::warn!(
"Failed to prune VCS metadata from '{}': {}",
dest_path.display(),
e
);
}
Ok(())
}