diff options
author | Loïc Hoguin <[email protected]> | 2018-11-26 07:57:55 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-11-26 07:57:55 +0100 |
commit | 8f8088ac4df9b4d4660f0b15d09f3fdaa991bea1 (patch) | |
tree | 8375df73408a98a1faa8dfcf6f74ebe418df2b4c /core/deps.mk | |
parent | 095dcd9b024d260b59c03894338ec7828c4f413c (diff) | |
download | erlang.mk-8f8088ac4df9b4d4660f0b15d09f3fdaa991bea1.tar.gz erlang.mk-8f8088ac4df9b4d4660f0b15d09f3fdaa991bea1.tar.bz2 erlang.mk-8f8088ac4df9b4d4660f0b15d09f3fdaa991bea1.zip |
Use flock/lockf when available to avoid a -j issue
Fetching rebar is conditional depending on the project
being built, and if two projects require it and -j is
used this could mean the fetching happens at the same
time and one would fail.
Diffstat (limited to 'core/deps.mk')
-rw-r--r-- | core/deps.mk | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/deps.mk b/core/deps.mk index d5b12a6..fa6ad84 100644 --- a/core/deps.mk +++ b/core/deps.mk @@ -198,8 +198,19 @@ define dep_autopatch_gen "include ../../erlang.mk" > $(DEPS_DIR)/$(1)/Makefile endef +# We use flock/lockf when available to avoid concurrency issues. define dep_autopatch_fetch_rebar mkdir -p $(ERLANG_MK_TMP); \ + if command -v flock >/dev/null; then \ + flock $(ERLANG_MK_TMP)/rebar.lock -c "$(call dep_autopatch_fetch_rebar2)"; \ + elif command -v lockf >/dev/null; then \ + lockf $(ERLANG_MK_TMP)/rebar.lock sh -c "$(call dep_autopatch_fetch_rebar2)"; \ + else \ + $(call dep_autopatch_fetch_rebar2); \ + fi +endef + +define dep_autopatch_fetch_rebar2 if [ ! -d $(ERLANG_MK_TMP)/rebar ]; then \ git clone -q -n -- https://github.com/rebar/rebar $(ERLANG_MK_TMP)/rebar; \ cd $(ERLANG_MK_TMP)/rebar; \ |