aboutsummaryrefslogtreecommitdiff
path: root/libs/common
diff options
context:
space:
mode:
authorSwift Geek <swiftgeek@gmail.com>2017-09-20 15:03:58 +0000
committerGogs <gogitservice@gmail.com>2017-09-20 15:03:58 +0000
commit33efc3a00d4443ecb713bf230ee7ba65b701b55b (patch)
treeb631a765ea14779e84f46eceb3bc9a40ba6fbe60 /libs/common
parentca3e4a475d4fafb36e09c358c4ba86ee4e87bce0 (diff)
parentcd96d96c6f43f971c688620f7f8dee2d262c81a5 (diff)
downloadlibrebootfr-33efc3a00d4443ecb713bf230ee7ba65b701b55b.tar.gz
librebootfr-33efc3a00d4443ecb713bf230ee7ba65b701b55b.zip
Merge branch 'download-wrapper' of kragle/libreboot into master
Diffstat (limited to 'libs/common')
-rwxr-xr-xlibs/common40
1 files changed, 31 insertions, 9 deletions
diff --git a/libs/common b/libs/common
index b1d2f571..db72a974 100755
--- a/libs/common
+++ b/libs/common
@@ -73,17 +73,39 @@ download_wrapper() {
shift
local uris=($@)
- # TODO: Add support for curl, in addition
- # to wget, for compatibility reasons
- wget_options=(
- --config=/dev/null
- --secure-protocol=PFS
- --directory-prefix="${download_dir}"
- --continue
- --
+ local wget_options=(
+ '--config=/dev/null'
+ '--secure-protocol=PFS'
+ "--directory-prefix=$download_dir"
+ '--continue'
+ '--'
)
- wget "${wget_options[@]}" "${uris[@]}"
+ local curl_options=(
+ '-q'
+ '--continue-at -'
+ '--remote-name'
+ '--retry 20'
+ '--ssl'
+ '--tlsv1.2'
+ '--'
+ )
+
+ if hash wget > /dev/null 2>&1; then
+
+ wget "${wget_options[@]}" "${uris[@]}"
+
+ elif hash curl > /dev/null 2>&1; then
+ (
+ cd "$download_dir"
+
+ curl "${curl_options[@]}" "${uris[@]}"
+ )
+ else
+ printf '\n%s\n\n' 'Error: Neither wget nor curl were found' 1>&2
+
+ return 1
+ fi
}
diff_patch_file() {