kumquat-buildroot/support/download/file
Angelo Compagnucci a9bb361435 support/download/file: fix file:// protocol handling
Since the rework of the download infrastructure, the "file" download
helper gets passed an URL that starts with file://, but forgets to
strip it before passing it to "cp", causing a failure as the "cp"
program isn't prepared for file paths starting with file://. This is
fixed by stripping the file:// at the beginning of the URL.

In addition, the path passed to cp lacked a slash between the
directory path and the filename part of the url. This is fixed by
adding a slash at the appropriate places.

Fixes the following build failure when the "file" download method is
used:

cp: cannot stat 'file:///home/angelo/DEV/TOOLCHAINSarmv7-eabihf--glibc--bleeding-edge-2017.11-1.tar.bz2': No such file or directory

Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2018-05-13 22:23:13 +02:00

44 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# We want to catch any unexpected failure, and exit immediately
set -e
set -x
# Download helper for cp, to be called from the download wrapper script
#
# Options:
# -q Be quiet.
# -o FILE Copy to file FILE.
# -f FILE Copy from basename file FILE.
# -u DIR Copy from FILE in DIR.
#
# Environment:
# LOCALFILES: the cp command to call
# 'cp' usually does not print anything on its stdout, whereas the
# other download backends, even if not verbose, at least print some
# progress information.
# Make 'cp' verbose by default, so it behaves a bit like the others.
verbose=-v
while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do
case "${OPT}" in
q) verbose=;;
o) output="${OPTARG}";;
f) file="${OPTARG}";;
u) dir="${OPTARG}";;
:) printf "option '%s' expects a mandatory argument\n" "${OPTARG}"; exit 1;;
\?) printf "unknown option '%s'\n" "${OPTARG}" >&2; exit 1;;
esac
done
shift $((OPTIND-1)) # Get rid of our options
# Caller needs to single-quote its arguments to prevent them from
# being expanded a second time (in case there are spaces in them)
_localfiles() {
eval ${LOCALFILES} "${@}"
}
_localfiles ${verbose} "'${dir##file://}/${file}'" "'${output}'"