support/misc: Adding Vagrant file for provisioning
[buildroot-gz.git] / support / download / hg
blob25cb4e9d3510add52f917b79636db758fb4cd8fe
1 #!/usr/bin/env bash
3 # We want to catch any unexpected failure, and exit immediately
4 set -e
6 # Download helper for hg, to be called from the download wrapper script
8 # Call it as:
9 # .../hg [-q] OUT_FILE REPO_URL CSET BASENAME
11 # Environment:
12 # HG : the hg command to call
14 verbose=
15 while getopts :q OPT; do
16 case "${OPT}" in
17 q) verbose=-q;;
18 \?) printf "unknown option '%s'\n" "${OPTARG}" >&2; exit 1;;
19 esac
20 done
21 shift $((OPTIND-1))
23 output="${1}"
24 repo="${2}"
25 cset="${3}"
26 basename="${4}"
28 # Caller needs to single-quote its arguments to prevent them from
29 # being expanded a second time (in case there are spaces in them)
30 _hg() {
31 eval ${HG} "${@}"
34 _hg clone ${verbose} --noupdate "'${repo}'" "'${basename}'"
36 _hg archive ${verbose} --repository "'${basename}'" --type tgz \
37 --prefix "'${basename}'" --rev "'${cset}'" \
38 - >"${output}"