Move 'chocurl' command into chocpkg_functions.sh.

There's no reason for this to be a separate command.
This commit is contained in:
Simon Howard 2017-01-07 22:19:01 +01:00
parent 3582c01cb4
commit 5f8a01fc14
3 changed files with 26 additions and 26 deletions

View file

@ -43,3 +43,28 @@ sha256_digest() {
done
}
# Works like curl, but will try other tools.
cat_url() {
url=$1
if have_tool curl; then
curl "$url"
return
fi
if have_tool wget; then
wget "$url" -O -
return
fi
# Desperate?
for l in lynx links elinks; do
if have_tool $l; then
echo "Using $l to download $url..." >&2
$l -source "$url"
return
fi
done
error_exit "No tool install to fetch URLs. Please install curl or wget."
}

View file

@ -1,25 +0,0 @@
#!/bin/bash
. chocpkg_functions.sh
url=$1
if have_tool curl; then
exec curl $url
fi
if have_tool wget; then
exec wget $url -O -
fi
# Desperate?
for l in lynx links elinks; do
if have_tool $l; then
echo "Using $l to download $url..." >&2
exec $l -source $url
fi
done
error_exit "No tool available to retrieve URLs. Please install curl or wget."

View file

@ -27,7 +27,7 @@ download_package_file() {
local dlfile="$PACKAGES_DIR/$PACKAGE_FILENAME"
if [ ! -e "$dlfile" ]; then
local tmpfile="$dlfile.part"
if ! chocurl "$PACKAGE_URL" > $tmpfile; then
if ! cat_url "$PACKAGE_URL" > $tmpfile; then
error_exit "Failed to download $PACKAGE_URL"
fi
check_sha256_digest "$tmpfile"