kumquat-buildroot/support/download/bzr
Yann E. MORIN 84d7986940 support/download: fix the bzr helper
bzr uses the name of the extension of the output file to known what
output format to use: tar, tgz, tar.bz2... If no extension is
recognised, bzr will output to a directory.

Since we use 'mktemp .XXXXXX' to generate temporary files, it obviously
never ends with a recognised extension. Thus, bzr expects the output to
be a directory, and fails since it is a file.

Fix that by forcing the output format.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2014-07-08 10:53:39 +02:00

39 lines
917 B
Bash
Executable File

#!/bin/bash
# We want to catch any command failure, and exit immediately
set -e
# Download helper for bzr
# Call it with:
# $1: bzr repo
# $2: bzr revision
# $3: output file
# And this environment:
# BZR : the bzr command to call
# BUILD_DIR: path to Buildroot's build dir
repo="${1}"
rev="${2}"
output="${3}"
tmp_dl="$( mktemp "${BUILD_DIR}/.XXXXXX" )"
tmp_output="$( mktemp "${output}.XXXXXX" )"
# Play tic-tac-toe with temp files
# - first, we download to a trashable location (the build-dir)
# - the we move to a temp file in the final location, so it is
# on the same filesystem as the final file
# - finally, we atomically rename to the final file
ret=1
if ${BZR} export --format=tgz "${tmp_dl}" "${repo}" -r "${rev}"; then
if mv "${tmp_dl}" "${tmp_output}"; then
mv "${tmp_output}" "${output}"
ret=0
fi
fi
# Cleanup
rm -f "${tmp_dl}" "${tmp_output}"
exit ${ret}