Debian Codegraph @

install.sh

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 set -e
3 # Code generated by godownloader on 2020-09-27T12:53:27Z. DO NOT EDIT.
4 #
5
6 usagescip-shell shell shell-project 0.0.0 usage().() {
7 this=$1
8 catscip-shell system . . cat. <<EOF
9 $this: download go binaries for traefik/yaegi
10
11 Usage: $this [-b] bindir [-d] [tag]
12 -b sets bindir or installation directory, Defaults to ./bin
13 -d turns on debug logging
14 [tag] is a tag from
15 https://github.com/traefik/yaegi/releases
16 If tag is missing, then the latest will be used.
17
18 Generated by godownloader
19 https://github.com/goreleaser/godownloader
20
21 EOF
22 exit 2
23 }
24
25 parse_argsscip-shell shell shell-project 0.0.0 parse_args().() {
26 #BINDIR is ./bin unless set be ENV
27 # over-ridden by flag below
28
29 BINDIR=${BINDIR:-./bin}
30 while getopts "b:dh?x" arg; do
31 case "$arg" in
32 b) BINDIR="$OPTARG" ;;
33 d) log_set_priorityscip-shell shell shell-project 0.0.0 log_set_priority(). 10 ;;
34 h | \?) usagescip-shell shell shell-project 0.0.0 usage(). "$0" ;;
35 x) set -x ;;
36 esac
37 done
38 shift $((OPTIND - 1))
39 TAG=$1
40 }
41 # this function wraps all the destructive operations
42 # if a curl|bash cuts off the end of the script due to
43 # network, either nothing will happen or will syntax error
44 # out preventing half-done work
45 executescip-shell shell shell-project 0.0.0 execute().() {
46 tmpdir=$(mktempscip-shell system . . mktemp. -d)
47 log_debugscip-shell shell shell-project 0.0.0 log_debug(). "downloading files into ${tmpdir}"
48 http_downloadscip-shell shell shell-project 0.0.0 http_download(). "${tmpdir}/${TARBALL}" "${TARBALL_URL}"
49 http_downloadscip-shell shell shell-project 0.0.0 http_download(). "${tmpdir}/${CHECKSUM}" "${CHECKSUM_URL}"
50 hash_sha256_verifyscip-shell shell shell-project 0.0.0 hash_sha256_verify(). "${tmpdir}/${TARBALL}" "${tmpdir}/${CHECKSUM}"
51 srcdir="${tmpdir}"
52 (cd "${tmpdir}" && untarscip-shell shell shell-project 0.0.0 untar(). "${TARBALL}")
53 testscip-shell system . . test. ! -d "${BINDIR}" && installscip-shell system . . install. -d "${BINDIR}"
54 for binexe in $BINARIES; do
55 if [scip-shell system . . `[`. "$OS" = "windows" ]; then
56 binexe="${binexe}.exe"
57 fi
58 installscip-shell system . . install. "${srcdir}/${binexe}" "${BINDIR}/"
59 log_infoscip-shell shell shell-project 0.0.0 log_info(). "installed ${BINDIR}/${binexe}"
60 done
61 rmscip-shell system . . rm. -rf "${tmpdir}"
62 }
63 get_binariesscip-shell shell shell-project 0.0.0 get_binaries().() {
64 case "$PLATFORM" in
65 darwin/amd64) BINARIES="yaegi" ;;
66 darwin/arm64) BINARIES="yaegi" ;;
67 darwin/armv5) BINARIES="yaegi" ;;
68 darwin/armv6) BINARIES="yaegi" ;;
69 darwin/armv7) BINARIES="yaegi" ;;
70 freebsd/386) BINARIES="yaegi" ;;
71 freebsd/amd64) BINARIES="yaegi" ;;
72 freebsd/arm64) BINARIES="yaegi" ;;
73 freebsd/armv5) BINARIES="yaegi" ;;
74 freebsd/armv6) BINARIES="yaegi" ;;
75 freebsd/armv7) BINARIES="yaegi" ;;
76 linux/386) BINARIES="yaegi" ;;
77 linux/amd64) BINARIES="yaegi" ;;
78 linux/arm64) BINARIES="yaegi" ;;
79 linux/armv5) BINARIES="yaegi" ;;
80 linux/armv6) BINARIES="yaegi" ;;
81 linux/armv7) BINARIES="yaegi" ;;
82 openbsd/386) BINARIES="yaegi" ;;
83 openbsd/amd64) BINARIES="yaegi" ;;
84 openbsd/arm64) BINARIES="yaegi" ;;
85 openbsd/armv5) BINARIES="yaegi" ;;
86 openbsd/armv6) BINARIES="yaegi" ;;
87 openbsd/armv7) BINARIES="yaegi" ;;
88 solaris/386) BINARIES="yaegi" ;;
89 solaris/amd64) BINARIES="yaegi" ;;
90 solaris/arm64) BINARIES="yaegi" ;;
91 solaris/armv5) BINARIES="yaegi" ;;
92 solaris/armv6) BINARIES="yaegi" ;;
93 solaris/armv7) BINARIES="yaegi" ;;
94 *)
95 log_critscip-shell shell shell-project 0.0.0 log_crit(). "platform $PLATFORM is not supported. Make sure this script is up-to-date and file request at https://github.com/${PREFIX}/issues/new"
96 exit 1
97 ;;
98 esac
99 }
100 tag_to_versionscip-shell shell shell-project 0.0.0 tag_to_version().() {
101 if [scip-shell system . . `[`. -z "${TAG}" ]; then
102 log_infoscip-shell shell shell-project 0.0.0 log_info(). "checking GitHub for latest tag"
103 else
104 log_infoscip-shell shell shell-project 0.0.0 log_info(). "checking GitHub for tag '${TAG}'"
105 fi
106 REALTAG=$(github_release "$OWNER/$REPO" "${TAG}") && truescip-shell system . . true.
107 if testscip-shell system . . test. -z "$REALTAG"; then
108 log_critscip-shell shell shell-project 0.0.0 log_crit(). "unable to find '${TAG}' - use 'latest' or see https://github.com/${PREFIX}/releases for details"
109 exit 1
110 fi
111 # if version starts with 'v', remove it
112 TAG="$REALTAG"
113 VERSION=${TAG#v}
114 }
115 adjust_formatscip-shell shell shell-project 0.0.0 adjust_format().() {
116 # change format (tar.gz or zip) based on OS
117 case ${OS} in
118 windows) FORMAT=zip ;;
119 esac
120 truescip-shell system . . true.
121 }
122 adjust_osscip-shell shell shell-project 0.0.0 adjust_os().() {
123 # adjust archive name based on OS
124 truescip-shell system . . true.
125 }
126 adjust_archscip-shell shell shell-project 0.0.0 adjust_arch().() {
127 # adjust archive name based on ARCH
128 truescip-shell system . . true.
129 }
130
131 catscip-shell system . . cat. /dev/nullscip-shell filesystem . . `/dev/null`. <<EOF
132 ------------------------------------------------------------------------
133 https://github.com/client9/shlib - portable posix shell functions
134 Public domain - http://unlicense.org
135 https://github.com/client9/shlib/blob/master/LICENSE.md
136 but credit (and pull requests) appreciated.
137 ------------------------------------------------------------------------
138 EOF
139 is_commandscip-shell shell shell-project 0.0.0 is_command().() {
140 command -v "$1" >/dev/nullscip-shell filesystem . . `/dev/null`.
141 }
142 echoerrscip-shell shell shell-project 0.0.0 echoerr().() {
143 echoscip-shell system . . echo. "$@" 1>&2
144 }
145 log_prefixscip-shell shell shell-project 0.0.0 log_prefix().() {
146 echoscip-shell system . . echo. "$0"
147 }
148 _logp=6
149 log_set_priorityscip-shell shell shell-project 0.0.0 log_set_priority().() {
150 _logp="$1"
151 }
152 log_priorityscip-shell shell shell-project 0.0.0 log_priority().() {
153 if testscip-shell system . . test. -z "$1"; then
154 echoscip-shell system . . echo. "$_logp"
155 return
156 fi
157 [scip-shell system . . `[`. "$1" -le "$_logp" ]
158 }
159 log_tagscip-shell shell shell-project 0.0.0 log_tag().() {
160 case $1 in
161 0) echoscip-shell system . . echo. "emerg" ;;
162 1) echoscip-shell system . . echo. "alert" ;;
163 2) echoscip-shell system . . echo. "crit" ;;
164 3) echoscip-shell system . . echo. "err" ;;
165 4) echoscip-shell system . . echo. "warning" ;;
166 5) echoscip-shell system . . echo. "notice" ;;
167 6) echoscip-shell system . . echo. "info" ;;
168 7) echoscip-shell system . . echo. "debug" ;;
169 *) echoscip-shell system . . echo. "$1" ;;
170 esac
171 }
172 log_debugscip-shell shell shell-project 0.0.0 log_debug().() {
173 log_priorityscip-shell shell shell-project 0.0.0 log_priority(). 7 || return 0
174 echoerrscip-shell shell shell-project 0.0.0 echoerr(). "$(log_prefixscip-shell shell shell-project 0.0.0 log_prefix().)" "$(log_tagscip-shell shell shell-project 0.0.0 log_tag(). 7)" "$@"
175 }
176 log_infoscip-shell shell shell-project 0.0.0 log_info().() {
177 log_priorityscip-shell shell shell-project 0.0.0 log_priority(). 6 || return 0
178 echoerrscip-shell shell shell-project 0.0.0 echoerr(). "$(log_prefixscip-shell shell shell-project 0.0.0 log_prefix().)" "$(log_tagscip-shell shell shell-project 0.0.0 log_tag(). 6)" "$@"
179 }
180 log_errscip-shell shell shell-project 0.0.0 log_err().() {
181 log_priorityscip-shell shell shell-project 0.0.0 log_priority(). 3 || return 0
182 echoerrscip-shell shell shell-project 0.0.0 echoerr(). "$(log_prefixscip-shell shell shell-project 0.0.0 log_prefix().)" "$(log_tagscip-shell shell shell-project 0.0.0 log_tag(). 3)" "$@"
183 }
184 log_critscip-shell shell shell-project 0.0.0 log_crit().() {
185 log_priorityscip-shell shell shell-project 0.0.0 log_priority(). 2 || return 0
186 echoerrscip-shell shell shell-project 0.0.0 echoerr(). "$(log_prefixscip-shell shell shell-project 0.0.0 log_prefix().)" "$(log_tagscip-shell shell shell-project 0.0.0 log_tag(). 2)" "$@"
187 }
188 uname_osscip-shell shell shell-project 0.0.0 uname_os().() {
189 os=$(unamescip-shell system . . uname. -s | trscip-shell system . . tr. '[:upper:]' '[:lower:]')
190 case "$os" in
191 cygwin_nt*) os="windows" ;;
192 mingw*) os="windows" ;;
193 msys_nt*) os="windows" ;;
194 esac
195 echoscip-shell system . . echo. "$os"
196 }
197 uname_archscip-shell shell shell-project 0.0.0 uname_arch().() {
198 arch=$(unamescip-shell system . . uname. -m)
199 case $arch in
200 x86_64) arch="amd64" ;;
201 x86) arch="386" ;;
202 i686) arch="386" ;;
203 i386) arch="386" ;;
204 aarch64) arch="arm64" ;;
205 armv5*) arch="armv5" ;;
206 armv6*) arch="armv6" ;;
207 armv7*) arch="armv7" ;;
208 esac
209 echoscip-shell system . . echo. ${arch}
210 }
211 uname_os_checkscip-shell shell shell-project 0.0.0 uname_os_check().() {
212 os=$(uname_osscip-shell shell shell-project 0.0.0 uname_os().)
213 case "$os" in
214 darwin) return 0 ;;
215 dragonfly) return 0 ;;
216 freebsd) return 0 ;;
217 linux) return 0 ;;
218 android) return 0 ;;
219 nacl) return 0 ;;
220 netbsd) return 0 ;;
221 openbsd) return 0 ;;
222 plan9) return 0 ;;
223 solaris) return 0 ;;
224 windows) return 0 ;;
225 esac
226 log_critscip-shell shell shell-project 0.0.0 log_crit(). "uname_os_check '$(uname -s)' got converted to '$os' which is not a GOOS value. Please file bug at https://github.com/client9/shlib"
227 return 1
228 }
229 uname_arch_checkscip-shell shell shell-project 0.0.0 uname_arch_check().() {
230 arch=$(uname_archscip-shell shell shell-project 0.0.0 uname_arch().)
231 case "$arch" in
232 386) return 0 ;;
233 amd64) return 0 ;;
234 arm64) return 0 ;;
235 armv5) return 0 ;;
236 armv6) return 0 ;;
237 armv7) return 0 ;;
238 ppc64) return 0 ;;
239 ppc64le) return 0 ;;
240 mips) return 0 ;;
241 mipsle) return 0 ;;
242 mips64) return 0 ;;
243 mips64le) return 0 ;;
244 s390x) return 0 ;;
245 amd64p32) return 0 ;;
246 esac
247 log_critscip-shell shell shell-project 0.0.0 log_crit(). "uname_arch_check '$(uname -m)' got converted to '$arch' which is not a GOARCH value. Please file bug report at https://github.com/client9/shlib"
248 return 1
249 }
250 untarscip-shell shell shell-project 0.0.0 untar().() {
251 tarball=$1
252 case "${tarball}" in
253 *.tar.gz | *.tgz) tarscip-shell system . . tar. --no-same-owner -xzf "${tarball}" ;;
254 *.tar) tarscip-shell system . . tar. --no-same-owner -xf "${tarball}" ;;
255 *.zip) unzip "${tarball}" ;;
256 *)
257 log_errscip-shell shell shell-project 0.0.0 log_err(). "untar unknown archive format for ${tarball}"
258 return 1
259 ;;
260 esac
261 }
262 http_download_curlscip-shell shell shell-project 0.0.0 http_download_curl().() {
263 local_file=$1
264 source_url=$2
265 header=$3
266 if [scip-shell system . . `[`. -z "$header" ]; then
267 code=$(curlscip-shell system . . curl. -w '%{http_code}' -sL -o "$local_file" "$source_url")
268 else
269 code=$(curlscip-shell system . . curl. -w '%{http_code}' -sL -H "$header" -o "$local_file" "$source_url")
270 fi
271 if [scip-shell system . . `[`. "$code" != "200" ]; then
272 log_debugscip-shell shell shell-project 0.0.0 log_debug(). "http_download_curl received HTTP status $code"
273 return 1
274 fi
275 return 0
276 }
277 http_download_wgetscip-shell shell shell-project 0.0.0 http_download_wget().() {
278 local_file=$1
279 source_url=$2
280 header=$3
281 if [scip-shell system . . `[`. -z "$header" ]; then
282 wget -q -O "$local_file" "$source_url"
283 else
284 wget -q --header "$header" -O "$local_file" "$source_url"
285 fi
286 }
287 http_downloadscip-shell shell shell-project 0.0.0 http_download().() {
288 log_debugscip-shell shell shell-project 0.0.0 log_debug(). "http_download $2"
289 if is_commandscip-shell shell shell-project 0.0.0 is_command(). curl; then
290 http_download_curlscip-shell shell shell-project 0.0.0 http_download_curl(). "$@"
291 return
292 elif is_commandscip-shell shell shell-project 0.0.0 is_command(). wget; then
293 http_download_wgetscip-shell shell shell-project 0.0.0 http_download_wget(). "$@"
294 return
295 fi
296 log_critscip-shell shell shell-project 0.0.0 log_crit(). "http_download unable to find wget or curl"
297 return 1
298 }
299 http_copyscip-shell shell shell-project 0.0.0 http_copy().() {
300 tmp=$(mktempscip-shell system . . mktemp.)
301 http_downloadscip-shell shell shell-project 0.0.0 http_download(). "${tmp}" "$1" "$2" || return 1
302 body=$(catscip-shell system . . cat. "$tmp")
303 rmscip-shell system . . rm. -f "${tmp}"
304 echoscip-shell system . . echo. "$body"
305 }
306 github_releasescip-shell shell shell-project 0.0.0 github_release().() {
307 owner_repo=$1
308 version=$2
309 testscip-shell system . . test. -z "$version" && version="latest"
310 giturl="https://github.com/${owner_repo}/releases/${version}"
311 json=$(http_copyscip-shell shell shell-project 0.0.0 http_copy(). "$giturl" "Accept:application/json")
312 testscip-shell system . . test. -z "$json" && return 1
313 version=$(echoscip-shell system . . echo. "$json" | trscip-shell system . . tr. -s '\n' ' ' | sedscip-shell system . . sed. 's/.*"tag_name":"//' | sedscip-shell system . . sed. 's/".*//')
314 testscip-shell system . . test. -z "$version" && return 1
315 echoscip-shell system . . echo. "$version"
316 }
317 hash_sha256scip-shell shell shell-project 0.0.0 hash_sha256().() {
318 TARGET=${1:-/dev/stdin}
319 if is_commandscip-shell shell shell-project 0.0.0 is_command(). gsha256sum; then
320 hash=$(gsha256sum "$TARGET") || return 1
321 echoscip-shell system . . echo. "$hash" | cutscip-shell system . . cut. -d ' ' -f 1
322 elif is_commandscip-shell shell shell-project 0.0.0 is_command(). sha256sum; then
323 hash=$(sha256sumscip-shell system . . sha256sum. "$TARGET") || return 1
324 echoscip-shell system . . echo. "$hash" | cutscip-shell system . . cut. -d ' ' -f 1
325 elif is_commandscip-shell shell shell-project 0.0.0 is_command(). shasum; then
326 hash=$(shasumscip-shell system . . shasum. -a 256 "$TARGET" 2>/dev/nullscip-shell filesystem . . `/dev/null`.) || return 1
327 echoscip-shell system . . echo. "$hash" | cutscip-shell system . . cut. -d ' ' -f 1
328 elif is_commandscip-shell shell shell-project 0.0.0 is_command(). openssl; then
329 hash=$(opensslscip-shell system . . openssl. -dst openssl dgst -sha256 "$TARGET") || return 1
330 echoscip-shell system . . echo. "$hash" | cutscip-shell system . . cut. -d ' ' -f a
331 else
332 log_critscip-shell shell shell-project 0.0.0 log_crit(). "hash_sha256 unable to find command to compute sha-256 hash"
333 return 1
334 fi
335 }
336 hash_sha256_verifyscip-shell shell shell-project 0.0.0 hash_sha256_verify().() {
337 TARGET=$1
338 checksums=$2
339 if [scip-shell system . . `[`. -z "$checksums" ]; then
340 log_errscip-shell shell shell-project 0.0.0 log_err(). "hash_sha256_verify checksum file not specified in arg2"
341 return 1
342 fi
343 BASENAME=${TARGET##*/}
344 want=$(grepscip-shell system . . grep. "${BASENAME}" "${checksums}" 2>/dev/nullscip-shell filesystem . . `/dev/null`. | trscip-shell system . . tr. '\t' ' ' | cutscip-shell system . . cut. -d ' ' -f 1)
345 if [scip-shell system . . `[`. -z "$want" ]; then
346 log_errscip-shell shell shell-project 0.0.0 log_err(). "hash_sha256_verify unable to find checksum for '${TARGET}' in '${checksums}'"
347 return 1
348 fi
349 got=$(hash_sha256scip-shell shell shell-project 0.0.0 hash_sha256(). "$TARGET")
350 if [scip-shell system . . `[`. "$want" != "$got" ]; then
351 log_errscip-shell shell shell-project 0.0.0 log_err(). "hash_sha256_verify checksum for '$TARGET' did not verify ${want} vs $got"
352 return 1
353 fi
354 }
355 catscip-shell system . . cat. /dev/nullscip-shell filesystem . . `/dev/null`. <<EOF
356 ------------------------------------------------------------------------
357 End of functions from https://github.com/client9/shlib
358 ------------------------------------------------------------------------
359 EOF
360
361 PROJECT_NAME="yaegi"
362 OWNER=traefik
363 REPO="yaegi"
364 BINARY=yaegi
365 FORMAT=tar.gz
366 OS=$(uname_osscip-shell shell shell-project 0.0.0 uname_os().)
367 ARCH=$(uname_archscip-shell shell shell-project 0.0.0 uname_arch().)
368 PREFIX="$OWNER/$REPO"
369
370 # use in logging routines
371 log_prefixscip-shell shell shell-project 0.0.0 log_prefix().() {
372 echoscip-shell system . . echo. "$PREFIX"
373 }
374 PLATFORM="${OS}/${ARCH}"
375 GITHUB_DOWNLOAD=https://github.com/${OWNER}/${REPO}/releases/download
376
377 uname_os_checkscip-shell shell shell-project 0.0.0 uname_os_check(). "$OS"
378 uname_arch_checkscip-shell shell shell-project 0.0.0 uname_arch_check(). "$ARCH"
379
380 parse_argsscip-shell shell shell-project 0.0.0 parse_args(). "$@"
381
382 get_binariesscip-shell shell shell-project 0.0.0 get_binaries().
383
384 tag_to_versionscip-shell shell shell-project 0.0.0 tag_to_version().
385
386 adjust_formatscip-shell shell shell-project 0.0.0 adjust_format().
387
388 adjust_osscip-shell shell shell-project 0.0.0 adjust_os().
389
390 adjust_archscip-shell shell shell-project 0.0.0 adjust_arch().
391
392 log_infoscip-shell shell shell-project 0.0.0 log_info(). "found version: ${VERSION} for ${TAG}/${OS}/${ARCH}"
393
394 NAME=${PROJECT_NAME}_v${VERSION}_${OS}_${ARCH}
395 TARBALL=${NAME}.${FORMAT}
396 TARBALL_URL=${GITHUB_DOWNLOAD}/${TAG}/${TARBALL}
397 CHECKSUM=${PROJECT_NAME}_${VERSION}_checksums.txt
398 CHECKSUM_URL=${GITHUB_DOWNLOAD}/${TAG}/${CHECKSUM}
399
400
401 executescip-shell shell shell-project 0.0.0 execute().