From 6fa045a4f95750f86e5b53724a1049c8efd0f7e2 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 19 Nov 2023 19:46:16 +0000 Subject: [PATCH] fix(busybox): prefer curl over wget, limit wget options on busybox --- _webi/curl-pipe-bootstrap.tpl.sh | 19 ++++++++++++------- _webi/package-install.tpl.sh | 19 ++++++++++++------- webi/webi.sh | 2 -- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/_webi/curl-pipe-bootstrap.tpl.sh b/_webi/curl-pipe-bootstrap.tpl.sh index be51a2c..ac1fead 100644 --- a/_webi/curl-pipe-bootstrap.tpl.sh +++ b/_webi/curl-pipe-bootstrap.tpl.sh @@ -126,9 +126,14 @@ fn_wget() { ( a_url="${1}" a_path="${2}" - cmd_wget="wget -q --user-agent" + cmd_wget="wget -c -q --user-agent" if fn_is_tty; then - cmd_wget="wget -q --show-progress --user-agent" + cmd_wget="wget -c -q --show-progress --user-agent" + fi + # busybox wget doesn't support --show-progress + # See + if readlink "$(command -v wget)" | grep -q busybox; then + cmd_wget="wget --user-agent" fi b_triple_ua="$(fn_get_target_triple_user_agent)" @@ -137,9 +142,9 @@ fn_wget() { ( b_agent="webi/wget+curl ${b_triple_ua}" fi - if ! $cmd_wget "${b_agent}" -c "${a_url}" -O "${a_path}"; then + if ! $cmd_wget "${b_agent}" "${a_url}" -O "${a_path}"; then echo >&2 " $(t_err "failed to download (wget)") '$(t_url "${a_url}")'" - echo >&2 " $cmd_wget '${b_agent}' -c '${a_url}' -O '${a_path}'" + echo >&2 " $cmd_wget '${b_agent}' '${a_url}' -O '${a_path}'" echo >&2 " $(wget -V)" return 1 fi @@ -182,10 +187,10 @@ fn_download_to_path() { ( a_path="${2}" mkdir -p "$(dirname "${a_path}")" - if command -v wget > /dev/null; then - fn_wget "${a_url}" "${a_path}.part" - elif command -v curl > /dev/null; then + if command -v curl > /dev/null; then fn_curl "${a_url}" "${a_path}.part" + elif command -v wget > /dev/null; then + fn_wget "${a_url}" "${a_path}.part" else echo >&2 " $(t_err "failed to detect HTTP client (curl, wget)")" return 1 diff --git a/_webi/package-install.tpl.sh b/_webi/package-install.tpl.sh index 179f837..72d0dd3 100644 --- a/_webi/package-install.tpl.sh +++ b/_webi/package-install.tpl.sh @@ -709,9 +709,14 @@ fn_wget() { ( a_url="${1}" a_path="${2}" - cmd_wget="wget -q --user-agent" + cmd_wget="wget -c -q --user-agent" if fn_is_tty; then - cmd_wget="wget -q --show-progress --user-agent" + cmd_wget="wget -c -q --show-progress --user-agent" + fi + # busybox wget doesn't support --show-progress + # See + if readlink "$(command -v wget)" | grep -q busybox; then + cmd_wget="wget --user-agent" fi b_triple_ua="$(fn_get_target_triple_user_agent)" @@ -720,9 +725,9 @@ fn_wget() { ( b_agent="webi/wget+curl ${b_triple_ua}" fi - if ! $cmd_wget "${b_agent}" -c "${a_url}" -O "${a_path}"; then + if ! $cmd_wget "${b_agent}" "${a_url}" -O "${a_path}"; then echo >&2 " $(t_err "failed to download (wget)") '$(t_url "${a_url}")'" - echo >&2 " $cmd_wget '${b_agent}' -c '${a_url}' -O '${a_path}'" + echo >&2 " $cmd_wget '${b_agent}' '${a_url}' -O '${a_path}'" echo >&2 " $(wget -V)" return 1 fi @@ -765,10 +770,10 @@ fn_download_to_path() { ( a_path="${2}" mkdir -p "$(dirname "${a_path}")" - if command -v wget > /dev/null; then - fn_wget "${a_url}" "${a_path}.part" - elif command -v curl > /dev/null; then + if command -v curl > /dev/null; then fn_curl "${a_url}" "${a_path}.part" + elif command -v wget > /dev/null; then + fn_wget "${a_url}" "${a_path}.part" else echo >&2 " $(t_err "failed to detect HTTP client (curl, wget)")" return 1 diff --git a/webi/webi.sh b/webi/webi.sh index 30240f2..b7197bc 100755 --- a/webi/webi.sh +++ b/webi/webi.sh @@ -61,8 +61,6 @@ __webi_main() { set +e WEBI_CURL="$(command -v curl)" export WEBI_URL - WEBI_WGET="$(command -v wget)" - export WEBI_WGET set -e my_libc=''