update dist_get script to be more cross platform
License: MIT Signed-off-by: Jeromy <why@ipfs.io>
Jeromy committed
Apr 27, 2016 at 12:22 UTC
4a0882701a4143f1e58dad0fff275ccb7236e578
1 file changed
+5
-3
bin/dist_get
+5
-3
@@ -6,7 +6,7 @@ die() {
6
}
7
8
have_binary() {
9
- type "$1" > /dev/null
9
+ type "$1" > /dev/null 2> /dev/null
10
}
11
12
check_writeable() {
@@ -25,12 +25,14 @@ download() {
25
die "download error: cannot write to $output"
26
fi
27
28
- printf 'Downloading "%s" to "%s"\n' "$url" "$output"
28
if have_binary wget; then
29
+ printf 'Using wget to download "%s" to "%s"\n' "$url" "$output"
30
wget "$url" -O "$output"
31
elif have_binary curl; then
32
+ printf 'Using curl to download "%s" to "%s"\n' "$url" "$output"
33
curl --silent "$url" > "$output"
34
elif have_binary fetch; then
35
+ printf 'Using fetch to download "%s" to "%s"\n' "$url" "$output"
36
fetch "$url" -o "$output"
37
else
38
die "no binary found to download $url. exiting."
@@ -51,7 +53,7 @@ unarchive() {
53
tar.gz)
54
if have_binary tar; then
55
echo "==> using 'tar' to extract binary from archive"
54
- tar -x "$distname/$distname" -f "$infile" -O > "$outfile"
56
+ cat "$infile" | tar -O -z -x "$distname/$distname" > "$outfile"
57
else
58
die "no binary on system for extracting tar files"
59
fi