From a3d9240d626eb3e5cb8aa6b28d61842c0dffb2a8 Mon Sep 17 00:00:00 2001 From: vasilito Date: Tue, 4 Aug 2026 17:50:14 +0300 Subject: [PATCH] cook: resolve symlinks before the tracked-source check The out-of-tree staging added in 221a91cba4 never actually ran. Recipes are reached through the overlay path `recipes//`, a symlink into `local/recipes/...`, and `git ls-files --error-unmatch` refuses any pathspec that traverses a symlink ("pathspec is behind a symbolic link"). The check therefore reported every tracked vendored tree as untracked, staging was skipped, and builds went on mutating git-tracked sources -- 22 dirty source files after a 42-package run. Canonicalize the path before both the git query and the copy. Verified: the check fails via the symlink, succeeds via the resolved path, and cooking kirigami now logs [out-of-tree] staged tracked source -> .../kirigami/target/.../source-staged with the recipe's sed rewriting the staged copy instead of the tracked tree. --- src/cook/cook_build.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cook/cook_build.rs b/src/cook/cook_build.rs index 5e3274dbb7..2157dc2198 100644 --- a/src/cook/cook_build.rs +++ b/src/cook/cook_build.rs @@ -979,11 +979,19 @@ pub fn build( // Only tracked trees are staged. Tarball-extracted sources are // untracked and disposable, and copying them would add cost for no // safety. Escape hatch: REDBEAR_IN_TREE_BUILD=1. + // Resolve symlinks BEFORE asking git. Recipes are reached through + // the overlay path `recipes//` which is a symlink into + // `local/recipes/...`, and `git ls-files --error-unmatch` refuses + // any pathspec that traverses a symlink ("pathspec is behind a + // symbolic link"). Passing the unresolved path made every tracked + // vendored tree look untracked, so staging silently never fired and + // builds kept mutating the git-tracked source. + let source_real = source_dir.canonicalize().unwrap_or_else(|_| source_dir.to_path_buf()); let source_is_tracked = std::env::var_os("REDBEAR_IN_TREE_BUILD").is_none() && Command::new("git") .arg("ls-files") .arg("--error-unmatch") - .arg(source_dir) + .arg(&source_real) .stdout(Stdio::null()) .stderr(Stdio::null()) .status() @@ -996,7 +1004,7 @@ pub fn build( let status = Command::new("cp") .arg("-a") .arg("--reflink=auto") - .arg(source_dir) + .arg(&source_real) .arg(&staged) .status() .map_err(|e| format!("failed to stage source out of tree: {e}"))?;