From aa0d358feecec1fcd3f0cc17db871890e2b43f1c Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Date: Wed, 17 Feb 2021 07:55:23 -0500
Subject: [PATCH] contrib: Streamline the wget options for downloading.

This brings wget performance up to par with that of curl, which makes
downloading the contrib sources via wget about a ~6X faster.  Wget is
now also made the preferred downloader, as it's a smaller than curl,
and is GNU.

* contrib/src/main.mak (download): Remove the -p option, not suitable
for single file downloads (it's meant for retrieving all the resources
of a web page).  This fixes a warning too.  Remove the --passive
option, which is not documented.  It's probably equivalent to
--passive-ftp, which is the default anyway.  Use --waitretry instead
of -w.  The later was causing the 10 s delay to be inserted on every
HTTP redirection, wasting time.

Change-Id: Ibcd6805c66da3fb0c3f37b7128a34cf6c269f400
---
 contrib/src/main.mak | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/contrib/src/main.mak b/contrib/src/main.mak
index b131b40451..8e5e2117bf 100644
--- a/contrib/src/main.mak
+++ b/contrib/src/main.mak
@@ -249,20 +249,17 @@ 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)"
 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)" > "$@"
-else ifeq ($(shell wget --version >/dev/null 2>&1 || echo FAIL),)
-download = rm -f $@.tmp && \
-	wget $(if ${BATCH_MODE},-nv) --passive -t 4 -w 10 -c -p -O $@.tmp "$(1)" && \
-	touch $@.tmp && \
-	mv $@.tmp $@
 else ifeq ($(which fetch >/dev/null 2>&1 || echo FAIL),)
 download = rm -f $@.tmp && \
 	fetch -p -o $@.tmp "$(1)" && \
 	touch $@.tmp && \
 	mv $@.tmp $@
 else
-download = $(error Neither curl nor wget found!)
+download = $(error Neither wget nor curl found!)
 endif
 
 ifeq ($(shell which bzcat >/dev/null 2>&1 || echo FAIL),)
-- 
GitLab