summaryrefslogtreecommitdiff
path: root/jenkins-helpers.sh
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@linaro.org>2018-10-25 09:13:53 +0000
committerChristophe Lyon <christophe.lyon@linaro.org>2018-10-25 09:13:53 +0000
commitb0f37d5d763557b9b669f72711792b65f69ce738 (patch)
tree87b73fd07c745e6be6d662a31ff26b67890ebe68 /jenkins-helpers.sh
parent9f4aa1837f28eda954d65f1516cd2b69d21df6e1 (diff)
jenkins-helpers.sh: Download URLs more safely
wget_wildcard_url would try to access potentially invalid URLs as it uses $(dirname $url) to handle possible wildcards in $url. Since we only use '*', check if it is present in $url, otherwise we can directly download $url. This helps download GCC releases from ARM, for instance https://developer.arm.com/-/media/Files/downloads/gnu-a/8.2-2018.08/gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabihf.tar.xz since https://developer.arm.com/-/media/Files/downloads/gnu-a/8.2-2018.08/ is not a valid URL. Also restore output from wget_wildcard_url() to help debug issues. Change-Id: I1078b0f292a6bde5194f795fc4ef556624ee4aa5
Diffstat (limited to 'jenkins-helpers.sh')
-rw-r--r--jenkins-helpers.sh11
1 files changed, 9 insertions, 2 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh
index 458df056..82b94ef5 100644
--- a/jenkins-helpers.sh
+++ b/jenkins-helpers.sh
@@ -303,7 +303,14 @@ wget_wildcard_url ()
*".tcwglab") wget_opts="$wget_opts --no-check-certificate" ;;
esac
- wget --progress=dot:giga -r --no-parent --no-directories --level 1 "--directory-prefix=$tmpdir" -A "$url_basename" $wget_opts "$@" "$(dirname "$url")/"
+ # $(dirname "$url") may not be a valid URL. Since we only use '*'
+ # as wildcards, check if a '*' is present in $url_basename, and if
+ # not, do a direct wget on $url to avoid accessing $(dirname "$url")
+ if echo "$url_basename" | grep '*' ; then
+ wget --progress=dot:giga -r --no-parent --no-directories --level 1 "--directory-prefix=$tmpdir" -A "$url_basename" $wget_opts "$@" "$(dirname "$url")/"
+ else
+ wget --progress=dot:giga -r --no-parent --no-directories --level 1 "--directory-prefix=$tmpdir" $wget_opts "$@" "$url"
+ fi
local count=-1
for i in "$tmpdir"/$url_basename; do
@@ -332,7 +339,7 @@ untar_url ()
local tarball
local dirname
- wget_wildcard_url "$url" > /dev/null 2>&1
+ wget_wildcard_url "$url"
# shellcheck disable=SC2046
tarball="$(ls $(basename "$url"))"
dirname="$basedir/${tarball%.tar*}"