support/misc: Adding Vagrant file for provisioning
[buildroot-gz.git] / support / download / cvs
blob7980389a4eeaf2024e6d746a4277e3ecb93ac314
1 #!/usr/bin/env bash
3 # We want to catch any unexpected failure, and exit immediately
4 set -e
6 # Download helper for cvs, to be called from the download wrapper script
8 # Call it as:
9 # .../cvs [-q] OUT_FILE CVS_URL REV PKG_NAME BASENAME
11 # Environment:
12 # CVS : the cvs 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 rev="${3}"
26 rawname="${4}"
27 basename="${5}"
29 # Caller needs to single-quote its arguments to prevent them from
30 # being expanded a second time (in case there are spaces in them)
31 _cvs() {
32 eval ${CVS} "${@}"
35 if [[ ${rev} =~ ^[0-9] ]]; then
36 # Date, because a tag or a branch cannot begin with a number
37 select="-D"
38 else
39 # Tag or branch
40 select="-r"
43 # The absence of an initial : on ${repo} means access method undefined
44 if [[ ! "${repo}" =~ ^: ]]; then
45 # defaults to anonymous pserver
46 repo=":pserver:anonymous@${repo}"
49 export TZ=UTC
50 _cvs ${verbose} -z3 -d"'${repo}'" \
51 co -d "'${basename}'" ${select} "'${rev}'" -P "'${rawname}'"
53 tar czf "${output}" "${basename}"