summaryrefslogtreecommitdiffstats
path: root/support/download/cp
diff options
context:
space:
mode:
authorYann E. MORIN <yann.morin.1998@free.fr>2018-04-02 10:14:22 +0200
committerPeter Korsgaard <peter@korsgaard.com>2018-04-02 12:22:50 +0200
commit91e776b5af11f6f98646168fc8c16254fa3bb012 (patch)
treee4d9d6499d7485df8ee7862bf0043e32753abe17 /support/download/cp
parentf03cf639cfba961ca4cbfb73435f23b951941685 (diff)
downloadbuildroot-91e776b5af11f6f98646168fc8c16254fa3bb012.tar.gz
buildroot-91e776b5af11f6f98646168fc8c16254fa3bb012.zip
core/pkg-download: change all helpers to use common options
Currently all download helpers accepts the local output file, the remote locations, the changesets and so on... as positional arguments. This was well and nice when that's was all we needed. But then we added an option to quiesce their verbosity, and that was shoehorned with a trivial getopts, still keeping all the existing positional arguments as... positional arguments. Adding yet more options while keeping positional arguments will not be very easy, even if we do not envision any new option in the foreseeable future (but 640K ought to be enough for everyone, remember? ;-) ). Change all helpers to accept a set of generic options (-q for quiet and -o for the output file) as well as helper-specific options (like -r for the repository, -c for a changeset...). Maxime: Changed -R to -r for recurse (only for the git backend) Changed -r to -u for URI (for all backend) Change -R to -c for cset (for CVS and SVN backend) Add the export of the BR_BACKEND_DL_GETOPTS so all the backend wrapper can use the same option easily Now all the backends use the same common options. Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Reviewed-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Diffstat (limited to 'support/download/cp')
-rwxr-xr-xsupport/download/cp17
1 files changed, 9 insertions, 8 deletions
diff --git a/support/download/cp b/support/download/cp
index 0ee1f3ba82..52fe2de83d 100755
--- a/support/download/cp
+++ b/support/download/cp
@@ -5,8 +5,10 @@ set -e
# Download helper for cp, to be called from the download wrapper script
#
-# Call it as:
-# .../cp [-q] OUT_FILE SRC_FILE
+# Options:
+# -q Be quiet.
+# -o FILE Copy to file FILE.
+# -u FILE Copy from file FILE.
#
# Environment:
# LOCALFILES: the cp command to call
@@ -17,18 +19,17 @@ set -e
# Make 'cp' verbose by default, so it behaves a bit like the others.
verbose=-v
-while getopts :q OPT; do
+while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do
case "${OPT}" in
q) verbose=;;
+ o) output="${OPTARG}";;
+ u) source="${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))
-output="${1}"
-source="${2}"
-
-shift 2 # Get rid of our options
+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)
OpenPOWER on IntegriCloud