diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2012-09-13 23:53:04 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2012-09-13 23:53:04 +0400 |
commit | e45104d1c2e38e411a56a8083339eabc60bb3f44 (patch) | |
tree | bd7b9fed7bd4ef0b723f8bd5ef21f2e2778cd3d8 /scripts | |
download | cibs-e45104d1c2e38e411a56a8083339eabc60bb3f44.tar.gz |
Initial commit: can build c-ares
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/download-archive | 25 | ||||
-rwxr-xr-x | scripts/unpack-archive | 28 | ||||
-rwxr-xr-x | scripts/validate-archive | 55 |
3 files changed, 108 insertions, 0 deletions
diff --git a/scripts/download-archive b/scripts/download-archive new file mode 100755 index 0000000..e8cce16 --- /dev/null +++ b/scripts/download-archive @@ -0,0 +1,25 @@ +#!/bin/sh + +set -e +set -u + +fatal () { + echo "$@" >&2 + exit 1 +} + +archive="$1" +url="$2" +shift 2 + +wget=`type -p wget || true` +curl=`type -p curl || true` + +if [ -n "$wget" ]; then + $wget -c -O "$archive" "$url" || rm -f "$archive" +elif [ -n "$curl" ]; then + $curl "$url" > "$archive" || rm -f "$archive" +else + fatal "Don't know howto download" +fi + diff --git a/scripts/unpack-archive b/scripts/unpack-archive new file mode 100755 index 0000000..4788fc1 --- /dev/null +++ b/scripts/unpack-archive @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e +set -u + +fatal () { + echo "$@" >&2 + exit 1 +} + +archive="$1" +sourcedir="$2" +shift 2 + +if ! [ -f "$archive" ]; then + fatal "No such file: $archive" +fi + +case "$archive" in + *.tar.*|*.t?z|*.tbz2) + [ -d "$sourcedir" ] || mkdir -p "$sourcedir" + tar xf "$archive" -C "$sourcedir" --strip=1 + ;; + *) + fatal "Unsupported archive: $archive" + ;; +esac + diff --git a/scripts/validate-archive b/scripts/validate-archive new file mode 100755 index 0000000..2d14066 --- /dev/null +++ b/scripts/validate-archive @@ -0,0 +1,55 @@ +#!/bin/sh + +set -e +set -u + +fatal () { + echo "$@" >&2 + exit 1 +} + +archive="$1" +shift + +if ! [ -f "$archive" ]; then + fatal "No such file: $archive" +fi + + +ok=0 + +for item in "$@"; do + oIFS="$IFS"; IFS=':' + set -- $item + m="$1" + v="$2" + IFS="$oIFS" + case "$m" in + sha1|sha256|md5) + printf "$m: $archive: " + sum=`${m}sum "$archive" | awk '{print $1}'` + if [ "$sum" = "$v" ]; then + echo "OK" + else + echo "FAILED (got:$sum, expected:$v)" + ok=1 + fi + ;; + size) + printf "$m: $archive: " + size=`stat -c '%s' "$archive"` + if [ "$size" = "$v" ]; then + echo "OK" + else + echo "FAILED (got:$size, expected:$v)" + ok=1 + fi + ;; + *) + fatal "Unsupported method: $m" + ;; + esac +done + +exit $ok + |