Skip to content
Snippets Groups Projects
Commit 15174309 authored by Maxim Cournoyer's avatar Maxim Cournoyer Committed by Amin Bandali
Browse files

contrib: main.mak: Guard downloads with flock.

This is to prevent resource contention on shared file systems such as
NFS.

* contrib/src/main.mak (download) <wget>: Guard with flock.
<curl>: Likewise.
<fetch> Likewise, and properly quote shell arguments.
(download_git): Likewise.

Change-Id: I8e2139d780a34ad054cfa8e188c6cbaf94df0609
parent f13474e4
No related branches found
No related tags found
No related merge requests found
......@@ -250,14 +250,12 @@ SVN ?= $(error subversion client (svn) not found!)
ifeq ($(DISABLE_CONTRIB_DOWNLOADS),TRUE)
download = $(error Trying to download $(1) but DISABLE_CONTRIB_DOWNLOADS is TRUE, aborting.)
else ifeq ($(shell wget --version >/dev/null 2>&1 || echo FAIL),)
download = wget $(if ${BATCH_MODE},-nv) -t 4 --waitretry 10 -O "$@" "$(1)"
download = flock "$@.lock" wget $(if ${BATCH_MODE},-nv) -t 4 --waitretry 10 -O "$@" "$(1)"
else ifeq ($(shell curl --version >/dev/null 2>&1 || echo FAIL),)
download = curl $(if ${BATCH_MODE},-sS) -f -L --retry-delay 10 --retry 4 -- "$(1)" > "$@"
download = flock "$@.lock" curl $(if ${BATCH_MODE},-sS) -f -L --retry-delay 10 --retry 4 -- "$(1)" > "$@"
else ifeq ($(which fetch >/dev/null 2>&1 || echo FAIL),)
download = rm -f $@.tmp && \
fetch -p -o $@.tmp "$(1)" && \
touch $@.tmp && \
mv $@.tmp $@
download = flock "$@.lock" sh -c \
'rm -f "$@.tmp" && fetch -p -o "$@.tmp" "$(1)" && touch "$@.tmp" && mv "$@.tmp" "$@"'
else
download = $(error Neither wget nor curl found!)
endif
......@@ -338,14 +336,13 @@ HOSTVARS := $(HOSTTOOLS) \
ifeq ($(DISABLE_CONTRIB_DOWNLOADS),TRUE)
download_git = $(error Trying to clone $(1) but DISABLE_CONTRIB_DOWNLOADS is TRUE, aborting.)
else
download_git = \
rm -Rf $(@:.tar.xz=) && \
$(GIT) clone $(2:%=--branch %) $(1) $(@:.tar.xz=) && \
(cd $(@:.tar.xz=) && $(GIT) checkout $(3:%= %)) && \
(test -z "$(4)" && rm -Rf $(@:%.tar.xz=%)/.git) || true && \
(cd $(dir $@) && \
tar cJ $(notdir $(@:.tar.xz=))) > $@ && \
rm -Rf $(@:.tar.xz=)
download_git = flock "$@.lock" sh -c "\
rm -Rf '$(@:.tar.xz=)' && \
$(GIT) clone $(2:%=--branch '%') '$(1)' '$(@:.tar.xz=)' && \
(cd '$(@:.tar.xz=)' && $(GIT) checkout $(3:%= '%')) && \
(test -z '$(4)' && rm -Rf $(@:%.tar.xz='%')/.git) || true && \
(cd '$(dir $@)' && tar cJ '$(notdir $(@:.tar.xz=))') > '$@' && \
rm -Rf '$(@:.tar.xz=)'"
endif
checksum = \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment