From 747eab0ae111833bcbcb9f71962d6fd299b21bfe Mon Sep 17 00:00:00 2001 From: Vinicius Ruoso <vkr07@c3sl.ufpr.br> Date: Fri, 14 May 2010 11:30:29 -0300 Subject: [PATCH] Created tryWget() to allow the easy use of the package wget(1) This function will retrieve the proxy configuration and call the appropriate wget(1), i.e. the system wget(1) if available, or the package wget(1). Also, it will be easier to call wget(1) in any script of the package. Signed-off-by: Vinicius Ruoso <vkr07@c3sl.ufpr.br> Acked-by: Erik Alexandre Pucci <eap08@c3sl.ufpr.br> Acked-by: Diego Giovane Pasqualin <dgp06@c3sl.ufpr.br> Signed-off-by: Danilo K. S. Yorinori <danilok@c3sl.ufpr.br> --- common.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/common.sh b/common.sh index b070738..7794eb2 100644 --- a/common.sh +++ b/common.sh @@ -36,3 +36,24 @@ function getProxyConf() puid=$(grep "^puid=" ${PROXYCONF} | cut -f2 -d=) ppasswd=$(grep "^ppasswd=" ${PROXYCONF} | cut -f2 -d=) } + +function tryWget(){ + getProxyConf + if test -z "$phost"; then + PROXY="" + else + PROXY="http://${phost}:${pport}" + fi + + if which wget &>/dev/null; then + WGETBIN="$(which wget)" + else + WGETBIN="${PREFIX}/bin/wget" + fi + + http_proxy="${PROXY}" ${WGETBIN} --tries=${UPDATETRIES} \ + --timeout=${UPDATETIMEOUT} \ + --proxy-user="${puid}" \ + --proxy-password="${ppasswd}" \ + $* || return 1 +} -- GitLab