summaryrefslogtreecommitdiffstats
path: root/scripts/lib/ptxd_make_get.sh
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2009-05-06 08:39:32 +0000
committerMarc Kleine-Budde <mkl@pengutronix.de>2009-05-06 08:39:32 +0000
commitc4b940140f7289f081b61e6437f40c3d99baf8b6 (patch)
tree9706470b5caf1b90960235dd682639dca1f765b4 /scripts/lib/ptxd_make_get.sh
parent347dee31e5496a0d558c7d264890adfade2a4388 (diff)
downloadptxdist-c4b940140f7289f081b61e6437f40c3d99baf8b6.tar.gz
ptxdist-c4b940140f7289f081b61e6437f40c3d99baf8b6.tar.xz
[make_get] added support for https URL
the certificate check can be skipped by adding: ";no-check-certificate" to the URL, e.g.: FOOBAR_URL := https://www.example.com/download/foobar.tar.bz2;no-check-certificate Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> git-svn-id: https://svn.pengutronix.de/svn/ptxdist/trunks/ptxdist-trunk@10387 33e552b5-05e3-0310-8538-816dae2090ed
Diffstat (limited to 'scripts/lib/ptxd_make_get.sh')
-rw-r--r--scripts/lib/ptxd_make_get.sh115
1 files changed, 88 insertions, 27 deletions
diff --git a/scripts/lib/ptxd_make_get.sh b/scripts/lib/ptxd_make_get.sh
index f4cd91e15..5d3d639ac 100644
--- a/scripts/lib/ptxd_make_get.sh
+++ b/scripts/lib/ptxd_make_get.sh
@@ -1,8 +1,75 @@
#!/bin/bash
+
+#
+# in env:
+#
+# ${url} : the url to download
+# ${opts[]} : an array of options
+#
+ptxd_make_get_http() {
+ set -- "${opts[@]}"
+ unset opts
+
+ #
+ # scan for valid options
+ #
+ while [ ${#} -ne 0 ]; do
+ local opt="${1}"
+ shift
+
+ case "${opt}" in
+ no-check-certificate)
+ opts[${#opts[@]}]="--${opt}"
+ ;;
+ *)
+ ptxd_bailout "invalid option '${opt}' to ${FUNCNAME}"
+ ;;
+ esac
+ done
+ unset opt
+
+ #
+ # download to temporary file first, move it to correct
+ # file name after successfull download
+ #
+ local file="${url##*/}"
+
+ # remove any pending or half downloaded files
+ rm -f -- "${PTXDIST_SRCDIR}/${file}."*
+
+ local temp_file="$(mktemp "${PTXDIST_SRCDIR}/${file}.XXXXXXXXXX")" || ptxd_bailout "failed to create tempfile"
+ wget \
+ --passive-ftp \
+ --progress=bar:force \
+ --timeout=30 \
+ --tries=5 \
+ ${PTXDIST_QUIET:+--quiet} \
+ "${opts[@]}" \
+ -O "${temp_file}" \
+ "${url}" && {
+ chmod 644 -- "${temp_file}" &&
+ mv -- "${temp_file}" "${PTXDIST_SRCDIR}/${file}"
+ return
+ }
+
+ rm -f -- "${temp_file}"
+
+ # return with failure, we didn't manage to download the file
+ return 1
+}
+export -f ptxd_make_get_http
+
+
+
#
# $@: possible download URLs, seperated by space
#
+# options seperated from URLs by ";"
+#
+# valid options:
+# - no-check-certificate don't check server certificate (https only)
+#
ptxd_make_get() {
local orig_argv=( "${@}" )
local -a argv
@@ -15,6 +82,11 @@ ptxd_make_get() {
exit 1
fi
+ #
+ # split by spaces, etc
+ #
+ set -- ${@}
+
while [ ${#} -gt 0 ]; do
local url="${1}"
shift
@@ -32,8 +104,7 @@ ptxd_make_get() {
mrd=true
fi
;;
- http://*|ftp://*)
-
+ http://*|https://*|ftp://*)
# keep original URL
argv[${#argv[@]}]="${url}"
@@ -52,34 +123,24 @@ ptxd_make_get() {
set -- "${argv[@]}"
while [ ${#} -ne 0 ]; do
- local url="${1}"
+ #
+ # strip options which are seperated by ";" form the
+ # URL, store in "opts" array
+ #
+ local orig_ifs="${IFS}"
+ IFS=";"
+ local -a opts=( ${1} )
+ IFS="${orig_ifs}"
+ unset orig_ifs
+
+ local url="${opts[0]}"
+ unset opts[0]
+
shift
case "${url}" in
- http://*|ftp://*)
- #
- # download to temporary file first,
- # and move it to correct file name after successfull download
- #
- local file="${url##*/}"
-
- # download any pending half downloaded files
- rm -f -- "${PTXDIST_SRCDIR}/${file}."*
-
- local temp_file="$(mktemp "${PTXDIST_SRCDIR}/${file}.XXXXXXXXXX")" || ptxd_bailout "failed to create tempfile"
- wget \
- --passive-ftp \
- --progress=bar:force \
- --timeout=30 \
- --tries=5 \
- ${PTXDIST_QUIET:+--quiet} \
- -O "${temp_file}" \
- "${url}" && {
- chmod 644 -- "${temp_file}" && \
- mv -- "${temp_file}" "${PTXDIST_SRCDIR}/${file}"
- return
- }
- rm -f -- "${temp_file}"
+ http://*|https://|ftp://*)
+ ptxd_make_get_http && return
;;
file*)
local thing="${url/file:\/\///}"