The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / support / download / git
1 #!/usr/bin/env bash
2
3 # We want to catch any unexpected failure, and exit immediately
4 set -e
5
6 # Download helper for git, to be called from the download wrapper script
7 #
8 # Call it as:
9 #   .../git [-q] OUT_FILE REPO_URL CSET BASENAME
10 #
11 # Environment:
12 #   GIT      : the git command to call
13
14 verbose=-v
15 while getopts :q OPT; do
16     case "${OPT}" in
17     q)  verbose=-q; exec >/dev/null;;
18     \?) printf "unknown option '%s'\n" "${OPTARG}" >&2; exit 1;;
19     esac
20 done
21 shift $((OPTIND-1))
22
23 output="${1}"
24 repo="${2}"
25 cset="${3}"
26 basename="${4}"
27
28 # Try a shallow clone, since it is faster than a full clone - but that only
29 # works if the version is a ref (tag or branch). Before trying to do a shallow
30 # clone we check if ${cset} is in the list provided by git ls-remote. If not
31 # we fall back on a full clone.
32 #
33 # Messages for the type of clone used are provided to ease debugging in case of
34 # problems
35 git_done=0
36 if [ -n "$(${GIT} ls-remote "${repo}" "${cset}" 2>&1)" ]; then
37     printf "Doing shallow clone\n"
38     if ${GIT} clone ${verbose} --depth 1 -b "${cset}" --bare "${repo}" "${basename}"; then
39         git_done=1
40     else
41         printf "Shallow clone failed, falling back to doing a full clone\n"
42     fi
43 fi
44 if [ ${git_done} -eq 0 ]; then
45     printf "Doing full clone\n"
46     ${GIT} clone ${verbose} --bare "${repo}" "${basename}"
47 fi
48
49 GIT_DIR="${basename}" \
50 ${GIT} archive --prefix="${basename}/" -o "${output}.tmp" --format=tar "${cset}"
51
52 gzip <"${output}.tmp" >"${output}"