Commit eecf72fa authored by Vitaly Lipatov's avatar Vitaly Lipatov

eget: lazy backend detection, only check needed downloaders

parent dae6be47
...@@ -1060,15 +1060,9 @@ fi ...@@ -1060,15 +1060,9 @@ fi
WGET="$(print_command_path wget)"
CURL="$(print_command_path curl)"
ARIA2="$(print_command_path aria2)"
AXEL="$(print_command_path axel)"
RSYNC="$(print_command_path rsync)"
ORIG_EGET_BACKEND="$EGET_BACKEND" ORIG_EGET_BACKEND="$EGET_BACKEND"
# override backend # override backend by URL type
if is_fileurl "$1" ; then if is_fileurl "$1" ; then
EGET_BACKEND="file" EGET_BACKEND="file"
elif is_ipfsurl "$1" ; then elif is_ipfsurl "$1" ; then
...@@ -1078,16 +1072,22 @@ elif is_rsyncurl "$1" || is_sshurl "$1" ; then ...@@ -1078,16 +1072,22 @@ elif is_rsyncurl "$1" || is_sshurl "$1" ; then
fi fi
orig_EGET_BACKEND="$EGET_BACKEND" orig_EGET_BACKEND="$EGET_BACKEND"
EGET_BACKEND="$(basename "$EGET_BACKEND")" EGET_BACKEND="${EGET_BACKEND##*/}"
# lazy backend detection: only check what we actually need
case "$orig_EGET_BACKEND" in case "$orig_EGET_BACKEND" in
file|ipfs|rsync) file|ipfs)
;;
rsync)
RSYNC="$(print_command_path rsync)"
[ -n "$RSYNC" ] || fatal "There are no rsync in the system. Install it with $ epm install rsync"
;; ;;
*/wget) */wget)
WGET="$orig_EGET_BACKEND" WGET="$orig_EGET_BACKEND"
[ -x "$WGET" ] || fatal "There are no $orig_EGET_BACKEND in the system but you forced using it via EGET_BACKEND. Install it with $ epm install wget" [ -x "$WGET" ] || fatal "There are no $orig_EGET_BACKEND in the system but you forced using it via EGET_BACKEND. Install it with $ epm install wget"
;; ;;
wget) wget)
WGET="$(print_command_path wget)"
[ -n "$WGET" ] || fatal "There are no wget in the system but you forced using it via EGET_BACKEND. Install it with $ epm install wget" [ -n "$WGET" ] || fatal "There are no wget in the system but you forced using it via EGET_BACKEND. Install it with $ epm install wget"
;; ;;
*/curl) */curl)
...@@ -1095,29 +1095,49 @@ case "$orig_EGET_BACKEND" in ...@@ -1095,29 +1095,49 @@ case "$orig_EGET_BACKEND" in
[ -x "$CURL" ] || fatal "There are no $orig_EGET_BACKEND in the system but you forced using it via EGET_BACKEND. Install it with $ epm install curl" [ -x "$CURL" ] || fatal "There are no $orig_EGET_BACKEND in the system but you forced using it via EGET_BACKEND. Install it with $ epm install curl"
;; ;;
curl) curl)
CURL="$(print_command_path curl)"
[ -n "$CURL" ] || fatal "There are no curl in the system but you forced using it via EGET_BACKEND. Install it with $ epm install curl" [ -n "$CURL" ] || fatal "There are no curl in the system but you forced using it via EGET_BACKEND. Install it with $ epm install curl"
;; ;;
*/aria2) */aria2)
ARIA2="$orig_EGET_BACKEND" ARIA2="$orig_EGET_BACKEND"
[ -x "$ARIA2" ] || fatal "There are no $orig_EGET_BACKEND in the system but you forced using it via EGET_BACKEND. Install it with $ epm install aria2" [ -x "$ARIA2" ] || fatal "There are no $orig_EGET_BACKEND in the system but you forced using it via EGET_BACKEND. Install it with $ epm install aria2"
# aria2 needs wget for headers and stdout
WGET="$(print_command_path wget)"
;; ;;
aria2) aria2)
ARIA2="$(print_command_path aria2)"
[ -n "$ARIA2" ] || fatal "There are no aria2 in the system but you forced using it via EGET_BACKEND. Install it with $ epm install aria2" [ -n "$ARIA2" ] || fatal "There are no aria2 in the system but you forced using it via EGET_BACKEND. Install it with $ epm install aria2"
# aria2 needs wget for headers and stdout
WGET="$(print_command_path wget)"
;; ;;
*/axel) */axel)
AXEL="$orig_EGET_BACKEND" AXEL="$orig_EGET_BACKEND"
[ -x "$AXEL" ] || fatal "There are no $orig_EGET_BACKEND in the system but you forced using it via EGET_BACKEND. Install it with $ epm install axel" [ -x "$AXEL" ] || fatal "There are no $orig_EGET_BACKEND in the system but you forced using it via EGET_BACKEND. Install it with $ epm install axel"
# axel needs wget for headers and stdout
WGET="$(print_command_path wget)"
;; ;;
axel) axel)
AXEL="$(print_command_path axel)"
[ -n "$AXEL" ] || fatal "There are no axel in the system but you forced using it via EGET_BACKEND. Install it with $ epm install axel" [ -n "$AXEL" ] || fatal "There are no axel in the system but you forced using it via EGET_BACKEND. Install it with $ epm install axel"
# axel needs wget for headers and stdout
WGET="$(print_command_path wget)"
;; ;;
'') '')
[ -n "$WGET" ] && EGET_BACKEND="wget" # default: try wget first, then curl
[ -z "$EGET_BACKEND" ] && [ -n "$CURL" ] && EGET_BACKEND="curl" WGET="$(print_command_path wget)"
[ -n "$EGET_BACKEND" ] || fatal "There are no wget nor curl in the system. Install something with $ epm install wget" if [ -n "$WGET" ] ; then
EGET_BACKEND="wget"
else
CURL="$(print_command_path curl)"
if [ -n "$CURL" ] ; then
EGET_BACKEND="curl"
else
fatal "There are no wget nor curl in the system. Install something with $ epm install wget"
fi
fi
;; ;;
*) *)
fatal "Uknown EGET_BACKEND $EGET_BACKEND" fatal "Unknown EGET_BACKEND $EGET_BACKEND"
;; ;;
esac esac
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment