aboutsummaryrefslogtreecommitdiff
path: root/scripts/common.sh
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-02-01 11:20:02 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-02-01 11:20:02 -0300
commit6b0b466585ea1e74f51d94dc0933f90f03366253 (patch)
tree8fdc2984ba5ce2c616f8b5796db098152290b54e /scripts/common.sh
parent3da78364cc96b97948608ff685ef8b9cac71e96e (diff)
downloadrneovim-6b0b466585ea1e74f51d94dc0933f90f03366253.tar.gz
rneovim-6b0b466585ea1e74f51d94dc0933f90f03366253.tar.bz2
rneovim-6b0b466585ea1e74f51d94dc0933f90f03366253.zip
Automate libuv download and build
Diffstat (limited to 'scripts/common.sh')
-rw-r--r--scripts/common.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/common.sh b/scripts/common.sh
new file mode 100644
index 0000000000..d7653c6aa1
--- /dev/null
+++ b/scripts/common.sh
@@ -0,0 +1,37 @@
+pkgroot="$(pwd)"
+deps="$pkgroot/.deps"
+prefix="$deps/usr"
+export PATH="$prefix/bin:$PATH"
+
+download() {
+ local url=$1
+ local tgt=$2
+ local sha1=$3
+
+ if [ ! -d "$tgt" ]; then
+ mkdir -p "$tgt"
+ 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=$(sha1sum < "$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
+ else
+ echo "Missing wget utility"
+ exit 1
+ fi
+ fi
+}
+
+github_download() {
+ local repo=$1
+ local ver=$2
+ download "https://github.com/${repo}/archive/${ver}.tar.gz" "$3" "$4"
+}