Browse Source

Create a tool for downloading

Wrap curl inside a function that tries to download at least three times. Use that in hunspell and also check that the zip files are consistent.
tmp/comercial-emacs
Juan Jose Garcia-Ripoll 4 years ago
parent
commit
401eb7cc17
  1. 4
      scripts/hunspell.sh
  2. 15
      scripts/tools.sh

4
scripts/hunspell.sh

@ -6,7 +6,9 @@ function action3_hunspell ()
if test -f "$hunspell_zip_file"; then
echo File $hunspell_zip_file already exists.
else
curl -L "$hunspell_link" > $hunspell_zip_file
try_download "$hunspell_link" "$hunspell_zip_file" \
&& test -f "$hunspell_zip_file" \
&& unzip -t "$hunspell_zip_file"
if test "$?" != 0; then
echo Unable to download Hunspell from
echo " $hunspell_link"

15
scripts/tools.sh

@ -186,3 +186,18 @@ function prepare_build_dir ()
mkdir -p "$build_dir"
fi
}
function try_download ()
{
local url="$1"
local destination="$2"
local attempts="$3"
if [ -z "$attempts" ]; then
attempts=3
fi
while [ $attempts -gt 0 ]; then
curl --progress-bar --retry 3 --output "$destination" "$url" && return 0
attempts=$(($attempts - 1))
fi
return -1
}

Loading…
Cancel
Save