|
@@ -1,28 +1,16 @@
|
|
|
#!/bin/bash
|
|
|
|
|
|
-# We want to catch any command failure, and exit immediately
|
|
|
+# We want to catch any unexpected failure, and exit immediately
|
|
|
set -e
|
|
|
|
|
|
-# Download helper for scp
|
|
|
-# Call it with:
|
|
|
-# $1: URL
|
|
|
-# $2: output file
|
|
|
+# Download helper for scp, to be called from the download wrapper script
|
|
|
+# Expected arguments:
|
|
|
+# $1: output file
|
|
|
+# $2: URL
|
|
|
# And this environment:
|
|
|
# SCP : the scp command to call
|
|
|
|
|
|
-url="${1}"
|
|
|
-output="${2}"
|
|
|
-tmp_dl="$( mktemp "${BUILD_DIR}/.XXXXXX" )"
|
|
|
-tmp_output="$( mktemp "${output}.XXXXXX" )"
|
|
|
+output="${1}"
|
|
|
+url="${2}"
|
|
|
|
|
|
-ret=1
|
|
|
-if ${SCP} "${url}" "${tmp_dl}"; 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}
|
|
|
+${SCP} "${url}" "${output}"
|