diff options
author | Swift Geek <swiftgeek@gmail.com> | 2017-09-20 15:03:58 +0000 |
---|---|---|
committer | Gogs <gogitservice@gmail.com> | 2017-09-20 15:03:58 +0000 |
commit | 33efc3a00d4443ecb713bf230ee7ba65b701b55b (patch) | |
tree | b631a765ea14779e84f46eceb3bc9a40ba6fbe60 /libs/common | |
parent | ca3e4a475d4fafb36e09c358c4ba86ee4e87bce0 (diff) | |
parent | cd96d96c6f43f971c688620f7f8dee2d262c81a5 (diff) | |
download | librebootfr-33efc3a00d4443ecb713bf230ee7ba65b701b55b.tar.gz librebootfr-33efc3a00d4443ecb713bf230ee7ba65b701b55b.zip |
Merge branch 'download-wrapper' of kragle/libreboot into master
Diffstat (limited to 'libs/common')
-rwxr-xr-x | libs/common | 40 |
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() { |