diff options
author | Theo Belaire <theobelaire@khanacademy.org> | 2014-02-22 14:49:53 -0800 |
---|---|---|
committer | ash-lshift <ash@lshift.net> | 2014-02-25 09:06:15 +0000 |
commit | e7b0aa224a2a873ad9da05776e26793eb5c882e6 (patch) | |
tree | 2aff4dbecf00e4477ce5ac705f75fc57f8c13ce8 /scripts/common.sh | |
parent | d5f74cf8bbfd9b4b3dce756756dd09de98da3458 (diff) | |
download | rneovim-e7b0aa224a2a873ad9da05776e26793eb5c882e6.tar.gz rneovim-e7b0aa224a2a873ad9da05776e26793eb5c882e6.tar.bz2 rneovim-e7b0aa224a2a873ad9da05776e26793eb5c882e6.zip |
Added curl support and one test
Now it checks for the existance of curl after
failing to find wget.
Note that I ended up removing the quotes around $url
when referencing it in the call to wget, since urls can't have spaces
anyways, and the correct quoting was messy.
To test, I did
rm -r .deps
make clean
make cmake
make
And it worked.
Diffstat (limited to 'scripts/common.sh')
-rw-r--r-- | scripts/common.sh | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/scripts/common.sh b/scripts/common.sh index f42c000c6f..eb2d05c48c 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -23,21 +23,29 @@ download() { if [ ! -d "$tgt" ]; then mkdir -p "$tgt" + local download_command="" if which wget > /dev/null 2>&1; then - tmp_dir=$(mktemp -d "/tmp/download_sha1check_XXXXXXX") - fifo="$tmp_dir/fifo" - mkfifo "$fifo" - # download, untar and calculate sha1 sum in one pass - (wget "$url" -O - | tee "$fifo" | \ - (cd "$tgt"; tar --strip-components=1 -xvzf -)) & - sum=$("$sha1sumcmd" < "$fifo" | cut -d ' ' -f1) - rm -rf "$tmp_dir" - if [ "$sum" != "$sha1" ]; then - echo "SHA1 sum doesn't match, expected '$sha1' got '$sum'" - exit 1 - fi + # -O - to send output to stdout + download_command="wget $url -O -" + elif which curl >/dev/null 2>&1; then + # -L to follow the redirects that github will send us + # -sS to supress the progress bar, but show errors + # curl sends output to stdout by default + download_command="curl -L -sS $url" else - echo "Missing wget utility" + echo "Missing wget utility and curl utility" + exit 1 + fi + local tmp_dir=$(mktemp -d "/tmp/download_sha1check_XXXXXXX") + local fifo="$tmp_dir/fifo" + mkfifo "$fifo" + # download, untar and calculate sha1 sum in one pass + ($download_command | tee "$fifo" | \ + (cd "$tgt"; tar --strip-components=1 -xvzf -)) & + local sum=$("$sha1sumcmd" < "$fifo" | cut -d ' ' -f1) + rm -rf "$tmp_dir" + if [ "$sum" != "$sha1" ]; then + echo "SHA1 sum doesn't match, expected '$sha1' got '$sum'" exit 1 fi fi |