From c324a834acf16216437fd05e3b2ff0d216e9aa3f Mon Sep 17 00:00:00 2001 From: Thierry Laurion Date: Mon, 5 May 2025 13:39:08 -0400 Subject: [PATCH] Makefile: make sure coreboot forks do the right thing when there is no .canary file but coreboot fork directory exists Improves collaboration with Makefile real.remove_canary_files-extract_patch_rebuild_what_changed helper: - if canary is not found but coreboot fork directory exists: do not attempt to git clone; git reset instead and reuse previous logic - if canary is not found and coreboot dir doesn't exist: git clone Signed-off-by: Thierry Laurion --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index cc6ebb235..ceaf0b61c 100644 --- a/Makefile +++ b/Makefile @@ -416,15 +416,15 @@ define define_module = # XXX: "git clean -dffx" is a hack for coreboot during commit switching, need # module-specific cleanup action to get rid of it. $(build)/$($1_base_dir)/.canary: FORCE - if [ ! -e "$$@" ]; then \ - echo "INFO: .canary file not found. Cloning repository $($1_repo) into $(build)/$($1_base_dir)" && \ + if [ ! -e "$$@" ] && [ ! -d "$(build)/$($1_base_dir)" ]; then \ + echo "INFO: .canary file and directory not found. Cloning repository $($1_repo) into $(build)/$($1_base_dir)" && \ git clone $($1_repo) "$(build)/$($1_base_dir)" && \ echo "INFO: Resetting repository to commit $($1_commit_hash)" && \ git -C "$(build)/$($1_base_dir)" reset --hard $($1_commit_hash) && \ echo "INFO: Creating .canary file with repo and commit hash" && \ echo -n '$($1_repo)|$($1_commit_hash)' > "$$@" ; \ - elif [ "$$$$(cat "$$@")" != '$($1_repo)|$($1_commit_hash)' ]; then \ - echo "INFO: Canary file differs. Switching $1 to $($1_repo) at $($1_commit_hash)" && \ + elif [ ! -e "$$@" ] || [ "$$$$(cat "$$@")" != '$($1_repo)|$($1_commit_hash)' ]; then \ + echo "INFO: .canary file missing or differs. Resetting $1 to $($1_repo) at $($1_commit_hash)" && \ git -C "$(build)/$($1_base_dir)" reset --hard HEAD^ && \ echo "INFO: Fetching commit $($1_commit_hash) from $($1_repo) (without recursing submodules)" && \ git -C "$(build)/$($1_base_dir)" fetch $($1_repo) $($1_commit_hash) --recurse-submodules=no && \