-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
66 lines (51 loc) · 1.29 KB
/
install
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
58
59
60
61
62
63
64
65
#!/bin/sh
set -au
get_qpm_download_url() {
local OS_ARCH="$1"
curl -sSL --url https://api.github.com/repos/anoriqq/qpm/releases/latest \
-H "Accept: application/vnd.github+json" \
-u ':${{ secrets.GITHUB_TOKEN }}' \
| grep browser_download_url \
| grep $OS_ARCH \
| sed -E 's/"//g' \
| sed -E 's/.* //'
}
install() {
local OS_ARCH="$1"
echo "OS_ARCH: $OS_ARCH"
# Get qpm download URL
local NEXT_WAIT_TIME=1
until QPM_DOWNLOAD_URL=$(get_qpm_download_url "$OS_ARCH") || [ "$NEXT_WAIT_TIME" -gt 10 ]; do
echo $NEXT_WAIT_TIME
sleep $(( NEXT_WAIT_TIME ))
NEXT_WAIT_TIME=$(( NEXT_WAIT_TIME * 2 ))
done
echo "QPM_DOWNLOAD_URL: $QPM_DOWNLOAD_URL"
if [ "$QPM_DOWNLOAD_URL" = "" ]; then
exit 1
fi
# Create tmp dir
mkdir ./tmp.qpm
# Download qpm to unarchive
(cd ./tmp.qpm && curl -sSL ${QPM_DOWNLOAD_URL} | tar -zx)
# Move Binary to PATH
sudo mv ./tmp.qpm/qpm /usr/local/bin
# Remove tmp dir
rm -rf ./tmp.qpm
# Show qpm version
/usr/local/bin/qpm -v
}
main() {
echo "uname -a: $(uname -a)"
ARCH=""
case "$(uname -m)" in
arm64) ARCH="arm64" ;;
*) ARCH="amd64" ;;
esac
case "$(uname)" in
Linux*) install "linux_${ARCH}" ;;
Darwin*) install "darwin_${ARCH}" ;;
*) echo "Unsupported OS" ;;
esac
}
main