lttng-libust: needs autoreconf
[buildroot-gz.git] / support / download / bzr
blob75b7b415c1fda0f150e92235aef3a0ef7e9f089b
1 #!/usr/bin/env bash
3 # We want to catch any unexpected failure, and exit immediately
4 set -e
6 # Download helper for bzr, to be called from the download wrapper script
8 # Call it as:
9 # .../bzr [-q] OUT_FILE REPO_URL REV BASENAME
11 # Environment:
12 # BZR : the bzr command to call
15 verbose=
16 while getopts :q OPT; do
17 case "${OPT}" in
18 q) verbose=-q;;
19 \?) printf "unknown option '%s'\n" "${OPTARG}" >&2; exit 1;;
20 esac
21 done
22 shift $((OPTIND-1))
24 output="${1}"
25 repo="${2}"
26 rev="${3}"
27 basename="${4}"
29 shift 4 # Get rid of our options
31 # Caller needs to single-quote its arguments to prevent them from
32 # being expanded a second time (in case there are spaces in them)
33 _bzr() {
34 eval ${BZR} "${@}"
37 # --per-file-timestamps comes with bzr-2.2 (released August 2010),
38 # so only pass it if bzr is recent enough. We compute versions as:
39 # major*1000 + minor
40 bzr_min_version=2002
41 bzr_version=$(($(bzr --version |
42 sed -r -n 's/^Bazaar \(bzr\) ([[:digit:]]+)\.([[:digit:]]+)\..*$/\1*1000+\2/p')
45 # If the version is recent enough, we can generate reproducible
46 # archives; otherwise, we just hope for the best (as it would
47 # be downloaded from the BR mirror if what we generate here does
48 # not match the hash we have for it).
49 if [ ${bzr_version} -ge ${bzr_min_version} ]; then
50 timestamp_opt="--per-file-timestamps"
53 _bzr export ${verbose} --root="'${basename}/'" --format=tgz \
54 ${timestamp_opt} - "${@}" "'${repo}'" -r "'${rev}'" \
55 >"${output}"