blob: 662a6f34c200169e8a4d3e7bcea5cfcb09ce4fc7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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"
gtar xf "$archive" -C "$sourcedir" --strip=1
;;
*)
fatal "Unsupported archive: $archive"
;;
esac
|