forked from oven-sh/bun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdownload-webkit.sh
57 lines (45 loc) · 1017 Bytes
/
download-webkit.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
set -e
OUTDIR="$1"
TAG="$2"
PKG="$3"
if [ -z "$OUTDIR" ]; then
echo "Missing outdir"
exit 1
fi
if [ -z "$TAG" ]; then
echo "Missing tag"
exit 1
fi
if [ -z "$PKG" ]; then
echo "Missing package"
exit 1
fi
url="https://github.com/oven-sh/WebKit/releases/download/autobuild-$TAG/$PKG.tar.gz"
old_tar_dir="$(dirname "$0")/../.webkit-cache"
tar_dir="$(dirname "$0")/../.cache"
if [ -d "$old_tar_dir" ]; then
# migration step from the old system
mkdir "$tar_dir"
mv "$old_tar_dir"/* "$tar_dir"
rm -r "$old_tar_dir"
fi
tar="$tar_dir/$PKG-$TAG.tar.gz"
mkdir -p "$OUTDIR"
mkdir -p "$tar_dir"
if [ -f "$OUTDIR/.tag" ]; then
read_tag="$(cat "$OUTDIR/.tag")"
if [ "$read_tag" == "$PKG" ]; then
exit 0
fi
fi
rm -rf "$OUTDIR"
if [ ! -f "$tar" ]; then
echo "-- Downloading WebKit"
if ! curl -o "$tar" -L "$url"; then
echo "Failed to download $url"
exit 1
fi
fi
tar -xzf "$tar" -C "$(dirname "$OUTDIR")" || (rm "$tar" && exit 1)
echo "$PKG" > "$OUTDIR/.tag"