From 139b7a41d8cda3ba100f6a1d2ef3e4d9beed2f8e Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Wed, 20 Sep 2017 11:01:04 -0400 Subject: Quote elements of array wget_options Necessary to satiate shellcheck. --- libs/common | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/common b/libs/common index b1d2f571..9bf50ab9 100755 --- a/libs/common +++ b/libs/common @@ -76,11 +76,11 @@ download_wrapper() { # 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 - -- + '--config=/dev/null' + '--secure-protocol=PFS' + "--directory-prefix=$download_dir" + '--continue' + '--' ) wget "${wget_options[@]}" "${uris[@]}" -- cgit v1.2.3-70-g09d2 From c9a97565554a651f291a340415489e2f4ece0b28 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Wed, 20 Sep 2017 09:36:50 -0400 Subject: Declare array wget_options with local scope --- libs/common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/common b/libs/common index 9bf50ab9..87f2f364 100755 --- a/libs/common +++ b/libs/common @@ -75,7 +75,7 @@ download_wrapper() { # TODO: Add support for curl, in addition # to wget, for compatibility reasons - wget_options=( + local wget_options=( '--config=/dev/null' '--secure-protocol=PFS' "--directory-prefix=$download_dir" -- cgit v1.2.3-70-g09d2 From c3b7abbbbcb2b1fa4fa2698e77e9457b7af638a7 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Wed, 20 Sep 2017 10:31:50 -0400 Subject: Add support for curl in download_wrapper function --- libs/common | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/common b/libs/common index 87f2f364..8dff9d18 100755 --- a/libs/common +++ b/libs/common @@ -73,8 +73,6 @@ download_wrapper() { shift local uris=($@) - # TODO: Add support for curl, in addition - # to wget, for compatibility reasons local wget_options=( '--config=/dev/null' '--secure-protocol=PFS' @@ -83,6 +81,16 @@ download_wrapper() { '--' ) + local curl_options=( + '-q' + '--continue-at -' + '--remote-name' + '--retry 20' + '--ssl' + '--tlsv1.2' + '--' + ) + wget "${wget_options[@]}" "${uris[@]}" } -- cgit v1.2.3-70-g09d2 From cd96d96c6f43f971c688620f7f8dee2d262c81a5 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Wed, 20 Sep 2017 11:01:28 -0400 Subject: Conditionally use wget or curl in download_wrapper --- libs/common | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libs/common b/libs/common index 8dff9d18..db72a974 100755 --- a/libs/common +++ b/libs/common @@ -91,7 +91,21 @@ download_wrapper() { '--' ) - wget "${wget_options[@]}" "${uris[@]}" + 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() { -- cgit v1.2.3-70-g09d2