aboutsummaryrefslogtreecommitdiff
path: root/scripts/unpack-archive
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2012-09-13 23:53:04 +0400
committerIgor Pashev <pashev.igor@gmail.com>2012-09-13 23:53:04 +0400
commite45104d1c2e38e411a56a8083339eabc60bb3f44 (patch)
treebd7b9fed7bd4ef0b723f8bd5ef21f2e2778cd3d8 /scripts/unpack-archive
downloadcibs-e45104d1c2e38e411a56a8083339eabc60bb3f44.tar.gz
Initial commit: can build c-ares
Diffstat (limited to 'scripts/unpack-archive')
-rwxr-xr-xscripts/unpack-archive28
1 files changed, 28 insertions, 0 deletions
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
+