[Buildroot] [PATCHv4 4/8] support/download/file: implement source-check

Thomas De Schampheleire patrickdepinguin at gmail.com
Fri Feb 15 21:07:59 UTC 2019


From: Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
---
 support/download/file | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

v4:
- use true/false as values to 'checkonly' (Yann E. Morin)
- replace incorrect 'exit $?' by explicit 'exit 0' (Yann E. Morin)
- replace 'test -e' by 'test -f' which is more specific

v3: no changes

diff --git a/support/download/file b/support/download/file
index e52fcf2c8c..059a8dde4c 100755
--- a/support/download/file
+++ b/support/download/file
@@ -7,6 +7,7 @@ set -e
 #
 # Options:
 #   -q          Be quiet.
+#   -C          Only check that the source file exists.
 #   -o FILE     Copy to file FILE.
 #   -f FILE     Copy from basename file FILE.
 #   -u DIR      Copy from FILE in DIR.
@@ -20,9 +21,11 @@ set -e
 # Make 'cp' verbose by default, so it behaves a bit like the others.
 verbose=-v
 
+checkonly=false
 while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do
     case "${OPT}" in
     q)  verbose=;;
+    C)  checkonly=true;;
     o)  output="${OPTARG}";;
     f)  file="${OPTARG}";;
     u)  dir="${OPTARG}";;
@@ -39,4 +42,12 @@ _localfiles() {
     eval ${LOCALFILES} "${@}"
 }
 
-_localfiles ${verbose} "'${dir##file://}/${file}'" "'${output}'"
+# Remove any scheme prefix
+dir="${dir##file://}"
+
+if ${checkonly}; then
+    test -f "'${dir}/${file}'"
+    exit 0
+fi
+
+_localfiles ${verbose} "'${dir}/${file}'" "'${output}'"
-- 
2.19.2




More information about the buildroot mailing list