Просмотр исходного кода

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.
Loïc Hoguin 6 лет назад
Родитель
Сommit
8f8088ac4d
1 измененных файлов с 11 добавлено и 0 удалено
  1. 11 0
      core/deps.mk

+ 11 - 0
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; \