support/download: Add support to pass options directly to downloaders
This adds support to pass options to the underlying command that is used by downloader. Useful for retrieving data with server-side checking for user login or passwords, use a proxy or use specific options for cloning a repository via git and hg. Signed-off-by: Romain Perier <romain.perier@free-electrons.com> Acked-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
parent
721e1c1e9c
commit
ff559846fd
@ -26,6 +26,8 @@ repo="${2}"
|
|||||||
rev="${3}"
|
rev="${3}"
|
||||||
basename="${4}"
|
basename="${4}"
|
||||||
|
|
||||||
|
shift 4 # Get rid of our options
|
||||||
|
|
||||||
# Caller needs to single-quote its arguments to prevent them from
|
# Caller needs to single-quote its arguments to prevent them from
|
||||||
# being expanded a second time (in case there are spaces in them)
|
# being expanded a second time (in case there are spaces in them)
|
||||||
_bzr() {
|
_bzr() {
|
||||||
@ -49,5 +51,5 @@ if [ ${bzr_version} -ge ${bzr_min_version} ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
_bzr export ${verbose} --root="'${basename}/'" --format=tgz \
|
_bzr export ${verbose} --root="'${basename}/'" --format=tgz \
|
||||||
${timestamp_opt} - "'${repo}'" -r "'${rev}'" \
|
${timestamp_opt} - "${@}" "'${repo}'" -r "'${rev}'" \
|
||||||
>"${output}"
|
>"${output}"
|
||||||
|
@ -28,10 +28,12 @@ shift $((OPTIND-1))
|
|||||||
output="${1}"
|
output="${1}"
|
||||||
source="${2}"
|
source="${2}"
|
||||||
|
|
||||||
|
shift 2 # Get rid of our options
|
||||||
|
|
||||||
# Caller needs to single-quote its arguments to prevent them from
|
# Caller needs to single-quote its arguments to prevent them from
|
||||||
# being expanded a second time (in case there are spaces in them)
|
# being expanded a second time (in case there are spaces in them)
|
||||||
_localfiles() {
|
_localfiles() {
|
||||||
eval ${LOCALFILES} "${@}"
|
eval ${LOCALFILES} "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_localfiles ${verbose} "'${source}'" "'${output}'"
|
_localfiles ${verbose} "${@}""'${source}'" "'${output}'"
|
||||||
|
@ -26,6 +26,8 @@ rev="${3}"
|
|||||||
rawname="${4}"
|
rawname="${4}"
|
||||||
basename="${5}"
|
basename="${5}"
|
||||||
|
|
||||||
|
shift 5 # Get rid of our options
|
||||||
|
|
||||||
# Caller needs to single-quote its arguments to prevent them from
|
# Caller needs to single-quote its arguments to prevent them from
|
||||||
# being expanded a second time (in case there are spaces in them)
|
# being expanded a second time (in case there are spaces in them)
|
||||||
_cvs() {
|
_cvs() {
|
||||||
@ -48,6 +50,6 @@ fi
|
|||||||
|
|
||||||
export TZ=UTC
|
export TZ=UTC
|
||||||
_cvs ${verbose} -z3 -d"'${repo}'" \
|
_cvs ${verbose} -z3 -d"'${repo}'" \
|
||||||
co -d "'${basename}'" ${select} "'${rev}'" -P "'${rawname}'"
|
co "${@}" -d "'${basename}'" ${select} "'${rev}'" -P "'${rawname}'"
|
||||||
|
|
||||||
tar czf "${output}" "${basename}"
|
tar czf "${output}" "${basename}"
|
||||||
|
@ -30,6 +30,8 @@ repo="${2}"
|
|||||||
cset="${3}"
|
cset="${3}"
|
||||||
basename="${4}"
|
basename="${4}"
|
||||||
|
|
||||||
|
shift 4 # Get rid of our options
|
||||||
|
|
||||||
# Caller needs to single-quote its arguments to prevent them from
|
# Caller needs to single-quote its arguments to prevent them from
|
||||||
# being expanded a second time (in case there are spaces in them)
|
# being expanded a second time (in case there are spaces in them)
|
||||||
_git() {
|
_git() {
|
||||||
@ -46,7 +48,7 @@ _git() {
|
|||||||
git_done=0
|
git_done=0
|
||||||
if [ -n "$(_git ls-remote "'${repo}'" "'${cset}'" 2>&1)" ]; then
|
if [ -n "$(_git ls-remote "'${repo}'" "'${cset}'" 2>&1)" ]; then
|
||||||
printf "Doing shallow clone\n"
|
printf "Doing shallow clone\n"
|
||||||
if _git clone ${verbose} --depth 1 -b "'${cset}'" "'${repo}'" "'${basename}'"; then
|
if _git clone ${verbose} "${@}" --depth 1 -b "'${cset}'" "'${repo}'" "'${basename}'"; then
|
||||||
git_done=1
|
git_done=1
|
||||||
else
|
else
|
||||||
printf "Shallow clone failed, falling back to doing a full clone\n"
|
printf "Shallow clone failed, falling back to doing a full clone\n"
|
||||||
@ -54,7 +56,7 @@ if [ -n "$(_git ls-remote "'${repo}'" "'${cset}'" 2>&1)" ]; then
|
|||||||
fi
|
fi
|
||||||
if [ ${git_done} -eq 0 ]; then
|
if [ ${git_done} -eq 0 ]; then
|
||||||
printf "Doing full clone\n"
|
printf "Doing full clone\n"
|
||||||
_git clone ${verbose} "'${repo}'" "'${basename}'"
|
_git clone ${verbose} "${@}" "'${repo}'" "'${basename}'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pushd "${basename}" >/dev/null
|
pushd "${basename}" >/dev/null
|
||||||
|
@ -25,13 +25,15 @@ repo="${2}"
|
|||||||
cset="${3}"
|
cset="${3}"
|
||||||
basename="${4}"
|
basename="${4}"
|
||||||
|
|
||||||
|
shift 4 # Get rid of our options
|
||||||
|
|
||||||
# Caller needs to single-quote its arguments to prevent them from
|
# Caller needs to single-quote its arguments to prevent them from
|
||||||
# being expanded a second time (in case there are spaces in them)
|
# being expanded a second time (in case there are spaces in them)
|
||||||
_hg() {
|
_hg() {
|
||||||
eval ${HG} "${@}"
|
eval ${HG} "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_hg clone ${verbose} --noupdate "'${repo}'" "'${basename}'"
|
_hg clone ${verbose} "${@}" --noupdate "'${repo}'" "'${basename}'"
|
||||||
|
|
||||||
_hg archive ${verbose} --repository "'${basename}'" --type tgz \
|
_hg archive ${verbose} --repository "'${basename}'" --type tgz \
|
||||||
--prefix "'${basename}'" --rev "'${cset}'" \
|
--prefix "'${basename}'" --rev "'${cset}'" \
|
||||||
|
@ -23,10 +23,12 @@ shift $((OPTIND-1))
|
|||||||
output="${1}"
|
output="${1}"
|
||||||
url="${2}"
|
url="${2}"
|
||||||
|
|
||||||
|
shift 2 # Get rid of our options
|
||||||
|
|
||||||
# Caller needs to single-quote its arguments to prevent them from
|
# Caller needs to single-quote its arguments to prevent them from
|
||||||
# being expanded a second time (in case there are spaces in them)
|
# being expanded a second time (in case there are spaces in them)
|
||||||
_scp() {
|
_scp() {
|
||||||
eval ${SCP} "${@}"
|
eval ${SCP} "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_scp ${verbose} "'${url}'" "'${output}'"
|
_scp ${verbose} "${@}" "'${url}'" "'${output}'"
|
||||||
|
@ -25,12 +25,14 @@ repo="${2}"
|
|||||||
rev="${3}"
|
rev="${3}"
|
||||||
basename="${4}"
|
basename="${4}"
|
||||||
|
|
||||||
|
shift 4 # Get rid of our options
|
||||||
|
|
||||||
# Caller needs to single-quote its arguments to prevent them from
|
# Caller needs to single-quote its arguments to prevent them from
|
||||||
# being expanded a second time (in case there are spaces in them)
|
# being expanded a second time (in case there are spaces in them)
|
||||||
_svn() {
|
_svn() {
|
||||||
eval ${SVN} "${@}"
|
eval ${SVN} "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_svn export ${verbose} "'${repo}@${rev}'" "'${basename}'"
|
_svn export ${verbose} "${@}" "'${repo}@${rev}'" "'${basename}'"
|
||||||
|
|
||||||
tar czf "${output}" "${basename}"
|
tar czf "${output}" "${basename}"
|
||||||
|
@ -23,10 +23,12 @@ shift $((OPTIND-1))
|
|||||||
output="${1}"
|
output="${1}"
|
||||||
url="${2}"
|
url="${2}"
|
||||||
|
|
||||||
|
shift 2 # Get rid of our options
|
||||||
|
|
||||||
# Caller needs to single-quote its arguments to prevent them from
|
# Caller needs to single-quote its arguments to prevent them from
|
||||||
# being expanded a second time (in case there are spaces in them)
|
# being expanded a second time (in case there are spaces in them)
|
||||||
_wget() {
|
_wget() {
|
||||||
eval ${WGET} "${@}"
|
eval ${WGET} "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_wget ${verbose} -O "'${output}'" "'${url}'"
|
_wget ${verbose} "${@}" -O "'${output}'" "'${url}'"
|
||||||
|
Loading…
Reference in New Issue
Block a user