Skip to content
Snippets Groups Projects
Unverified Commit 1d4dc978 authored by Maxim Cournoyer's avatar Maxim Cournoyer
Browse files

contrib: Make flock optional.

* contrib/src/main.mak (TARBALLS_DEFAULT): New variable.
(TARBALLS): Define in terms of the above.
(FLOCK, FLOCK_PREFIX): New variables.
(download): Use $(FLOCK_PREFIX), which may be empty when flock is not
available and a default TARBALLS location is used.

Change-Id: I95ca0ec0cdd893fc50f3924619cc87fe8cd6a5b7
parent 4bf9d5c0
No related branches found
No related tags found
No related merge requests found
...@@ -33,7 +33,8 @@ SRC := $(TOPSRC)/src ...@@ -33,7 +33,8 @@ SRC := $(TOPSRC)/src
# 1. Environment variable # 1. Environment variable
# 2. Configured value at bootstrap time # 2. Configured value at bootstrap time
# 3. Default value # 3. Default value
TARBALLS := $(or $(TARBALLS),$(CONF_TARBALLS),$(TOPSRC)/tarballs) TARBALLS_DEFAULT := $(TOPSRC)/tarballs
TARBALLS := $(or $(TARBALLS),$(CONF_TARBALLS),$(TARBALLS_DEFAULT))
PATH :=$(abspath $(TOPSRC)/../extras/tools/build/bin):$(PATH) PATH :=$(abspath $(TOPSRC)/../extras/tools/build/bin):$(PATH)
export PATH export PATH
...@@ -247,14 +248,25 @@ endif ...@@ -247,14 +248,25 @@ endif
endif endif
SVN ?= $(error subversion client (svn) not found!) SVN ?= $(error subversion client (svn) not found!)
ifndef FLOCK
ifeq ($(shell flock --version >/dev/null 2>&1 || echo FAIL),)
FLOCK = flock
endif
endif
ifneq ($(TARBALLS_DEFAULT),$(TARBALLS))
FLOCK ?= $(error custom TARBALLS location requires flock)
endif
FLOCK_PREFIX := $(and $(FLOCK),$(FLOCK) "$@.lock")
ifeq ($(DISABLE_CONTRIB_DOWNLOADS),TRUE) ifeq ($(DISABLE_CONTRIB_DOWNLOADS),TRUE)
download = $(error Trying to download $(1) but DISABLE_CONTRIB_DOWNLOADS is TRUE, aborting.) download = $(error Trying to download $(1) but DISABLE_CONTRIB_DOWNLOADS is TRUE, aborting.)
else ifeq ($(shell wget --version >/dev/null 2>&1 || echo FAIL),) else ifeq ($(shell wget --version >/dev/null 2>&1 || echo FAIL),)
download = flock "$@.lock" wget $(if ${BATCH_MODE},-nv) -t 4 --waitretry 10 -O "$@" "$(1)" download = $(FLOCK_PREFIX) wget $(if ${BATCH_MODE},-nv) -t 4 --waitretry 10 -O "$@" "$(1)"
else ifeq ($(shell curl --version >/dev/null 2>&1 || echo FAIL),) else ifeq ($(shell curl --version >/dev/null 2>&1 || echo FAIL),)
download = flock "$@.lock" curl $(if ${BATCH_MODE},-sS) -f -L --retry-delay 10 --retry 4 -- "$(1)" > "$@" download = $(FLOCK_PREFIX) curl $(if ${BATCH_MODE},-sS) -f -L --retry-delay 10 --retry 4 -- "$(1)" > "$@"
else ifeq ($(which fetch >/dev/null 2>&1 || echo FAIL),) else ifeq ($(which fetch >/dev/null 2>&1 || echo FAIL),)
download = flock "$@.lock" sh -c \ download = $(FLOCK_PREFIX) sh -c \
'rm -f "$@.tmp" && fetch -p -o "$@.tmp" "$(1)" && touch "$@.tmp" && mv "$@.tmp" "$@"' 'rm -f "$@.tmp" && fetch -p -o "$@.tmp" "$(1)" && touch "$@.tmp" && mv "$@.tmp" "$@"'
else else
download = $(error Neither wget nor curl found!) download = $(error Neither wget nor curl found!)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment