build: prevent race condition between tool symlink creation

remotes/1699402720531464663/tmp_refs/heads/stable
Matthias Schiffer 2015-05-28 03:52:24 +02:00
parent 1d6bfd8eda
commit bdd0dbda1b
1 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Thu, 28 May 2015 03:48:14 +0200
Subject: build: prevent race condition between tool symlink creation
Filter out STAGING_DIR_HOST binary path to prevent picking up grep from this
path.
diff --git a/tools/Makefile b/tools/Makefile
index 137ad61..c24bca1 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -120,7 +120,7 @@ $(STAGING_DIR_HOST)/.prepared: $(TMP_DIR)/.build
define PrepareCommand
$(STAGING_DIR_HOST)/bin/$(1): $(STAGING_DIR_HOST)/.prepared
@mkdir -p "$$(dir $$@)"; rm -f "$$@"
- @export FILE="$$$$(which $(2) 2>/dev/null | grep -v 'not found' | head -n1)"; [ -n "$$$$FILE" ] || { \
+ @export PATH="$(subst $(space),:,$(filter-out $(STAGING_DIR_HOST)/%,$(subst :,$(space),$(PATH))))"; export FILE="$$$$(which $(2) 2>/dev/null | grep -v 'not found' | head -n1)"; [ -n "$$$$FILE" ] || { \
echo "Command $(1) not found."; false; \
}; ln -s "$$$$FILE" "$$@"