-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·198 lines (187 loc) · 5.92 KB
/
install.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
PWD="$(dirname $(readlink -f -- $0))"
DIST="$PWD/dist"
VERSION="1.40"
OS="$(uname -s)"
function help() {
echo "Usage: $0 <flags>"
echo
echo "flags:"
echo " --version hledger version to install. (default: $VERSION)"
echo " --dist directory to install binaries to. (default: $DIST)"
echo " --os os name to install binaries for. (default: $OS)"
echo " --help display this message."
}
function error() {
echo "error: $@"
echo
help
exit 1
}
function info() {
echo "$@"
}
while [[ $# -gt 0 ]]; do
case "$1" in
--help)
help
exit 1
;;
--version)
VERSION="$2"
shift
shift
;;
--dist)
DIST="$2"
shift
shift
;;
--os)
OS="$2"
shift
shift
;;
*)
error "unknown flag $1"
;;
esac
done
info "version: $VERSION"
info "dist: $DIST"
function download() {
info "downloading $@"
local http_code=$(curl --silent --remote-name --location --write-out "%{http_code}" "$@")
if [[ ${http_code} -ne 200 ]]; then
error "GET $@: $http_code"
fi
}
function cleanup() {
popd
rm -rf "$TMP_DIR"
}
TMP_DIR=$(mktemp -d -t ci-XXXXXXXXXX)
pushd "$TMP_DIR"
trap cleanup EXIT
case "$OS" in
Linux)
case "$VERSION" in
1.34 | 1.40)
download "https://github.com/simonmichael/hledger/releases/download/$VERSION/hledger-linux-x64.tar.gz"
mkdir -p "$DIST"
tar xvf "hledger-linux-x64.tar.gz" --directory "$DIST"
;;
1.27 | 1.27.1 | 1.28 | 1.29 | 1.29.1 | 1.29.2 | 1.30 | 1.31 | 1.32 | 1.32.1 | 1.32.2 | 1.32.3 | 1.33 | 1.33.1)
download "https://github.com/simonmichael/hledger/releases/download/$VERSION/hledger-linux-x64.zip"
unzip -o "hledger-linux-x64.zip"
mkdir -p "$DIST"
tar xvf "hledger-linux-x64.tar" --directory "$DIST"
;;
1.24.1 | 1.24.99.1 | 1.24.99.2 | 1.25 | 1.26 | 1.26.1)
download "https://github.com/simonmichael/hledger/releases/download/$VERSION/hledger-linux-x64.zip"
mkdir -p "$DIST"
unzip -o "hledger-linux-x64.zip" -d "$DIST"
mv "$DIST/hledger-linux-x64" "$DIST/hledger"
mv "$DIST/hledger-web-linux-x64" "$DIST/hledger-web"
mv "$DIST/hledger-ui-linux-x64" "$DIST/hledger-ui"
chmod +x "$DIST/hledger" "$DIST/hledger-web" "$DIST/hledger-ui"
;;
1.22.2 | 1.23 | 1.24)
download "https://github.com/simonmichael/hledger/releases/download/$VERSION/hledger-linux-static-x64.zip"
mkdir -p "$DIST"
unzip -o "hledger-linux-static-x64.zip" -d "$DIST"
mv "$DIST/hledger-linux-static-x64" "$DIST/hledger"
mv "$DIST/hledger-web-linux-static-x64" "$DIST/hledger-web"
mv "$DIST/hledger-ui-linux-static-x64" "$DIST/hledger-ui"
chmod +x "$DIST/hledger" "$DIST/hledger-web" "$DIST/hledger-ui"
;;
1.22 | 1.22.1)
download "https://github.com/simonmichael/hledger/releases/download/$VERSION/hledger-linux-static-x64.zip"
mkdir -p "$DIST"
unzip -o "hledger-linux-static-x64.zip" -d "$DIST"
mv "$DIST/hledger-static-linux-x64" "$DIST/hledger"
mv "$DIST/hledger-web-static-linux-x64" "$DIST/hledger-web"
mv "$DIST/hledger-ui-static-linux-x64" "$DIST/hledger-ui"
chmod +x "$DIST/hledger" "$DIST/hledger-web" "$DIST/hledger-ui"
;;
1.21)
download "https://github.com/simonmichael/hledger/releases/download/$VERSION/hledger-ubuntu.zip"
mkdir -p "$DIST"
unzip -o "hledger-ubuntu.zip" -d "$DIST"
chmod +x "$DIST/hledger" "$DIST/hledger-web" "$DIST/hledger-ui"
;;
1.20.1)
sudo apt install libncurses5
download "https://github.com/simonmichael/hledger/releases/download/hledger-$VERSION/hledger-ubuntu.zip"
mkdir -p "$DIST"
unzip -o "hledger-ubuntu.zip" -d "$DIST"
chmod +x "$DIST/hledger" "$DIST/hledger-web" "$DIST/hledger-ui"
;;
1.18.1 | 1.19 | 1.19.1 | 1.20 | 1.20.2 | 1.20.3 | 1.20.4)
sudo apt install libncurses5
download "https://github.com/simonmichael/hledger/releases/download/$VERSION/hledger-ubuntu.zip"
mkdir -p "$DIST"
unzip -o "hledger-ubuntu.zip" -d "$DIST"
chmod +x "$DIST/hledger" "$DIST/hledger-web" "$DIST/hledger-ui"
;;
1.18)
sudo apt install libncurses5
download "https://github.com/simonmichael/hledger/releases/download/$VERSION/hledger-ubuntu-unoptimised.zip"
mkdir -p "$DIST"
unzip -o "hledger-ubuntu-unoptimised.zip" -d "$DIST"
chmod +x "$DIST/hledger" "$DIST/hledger-web" "$DIST/hledger-ui"
;;
*)
error "$VERSION unsupported"
;;
esac
;;
Darwin)
case "$VERSION" in
1.34 | 1.40)
download "https://github.com/simonmichael/hledger/releases/download/$VERSION/hledger-mac-x64.tar.gz"
mkdir -p "$DIST"
tar xvf "hledger-mac-x64.tar.gz" --directory "$DIST"
;;
1.27 | 1.27.1 | 1.28 | 1.29 | 1.29.1 | 1.29.2 | 1.30 | 1.31 | 1.32 | 1.32.1 | 1.32.2 | 1.32.3 | 1.33 | 1.33.1)
download "https://github.com/simonmichael/hledger/releases/download/$VERSION/hledger-mac-x64.zip"
unzip -o "hledger-mac-x64.zip"
mkdir -p "$DIST"
tar xvf "hledger-mac-x64.tar" --directory "$DIST"
;;
1.26 | 1.26.1)
download "https://github.com/simonmichael/hledger/releases/download/$VERSION/hledger-mac-x64.zip"
mkdir -p "$DIST"
unzip -o "hledger-mac-x64.zip" -d "$DIST"
chmod +x "$DIST/hledger" "$DIST/hledger-web" "$DIST/hledger-ui"
;;
1.20.1)
download "https://github.com/simonmichael/hledger/releases/download/hledger-$VERSION/hledger-macos.zip"
mkdir -p "$DIST"
unzip -o "hledger-macos.zip" -d "$DIST"
chmod +x "$DIST/hledger" "$DIST/hledger-web" "$DIST/hledger-ui"
;;
1.18.1 | 1.19 | 1.19.1 | 1.20 | 1.20.2 | 1.20.3 | 1.20.4 | 1.21 | 1.22 | 1.22.1 | 1.22.2 | 1.23 | 1.24 | 1.24.1 | 1.24.99.1 | 1.24.99.2 | 1.25)
download "https://github.com/simonmichael/hledger/releases/download/$VERSION/hledger-macos.zip"
mkdir -p "$DIST"
unzip -o "hledger-macos.zip" -d "$DIST"
chmod +x "$DIST/hledger" "$DIST/hledger-web" "$DIST/hledger-ui"
;;
1.18)
download "https://github.com/simonmichael/hledger/releases/download/$VERSION/hledger-macos-unoptimised.zip"
mkdir -p "$DIST"
unzip -o "hledger-macos-unoptimised.zip" -d "$DIST"
chmod +x "$DIST/hledger" "$DIST/hledger-web" "$DIST/hledger-ui"
;;
*)
error "$VERSION unsupported"
;;
esac
;;
*)
error "$(uname -s) unsupported"
;;
esac