Skip to content

Commit 1107f69

Browse files
andreyneringodidev
andcommitted
Update install script
Closes #428 Co-authored-by: odidev <[email protected]>
1 parent b095ca5 commit 1107f69

File tree

2 files changed

+72
-86
lines changed

2 files changed

+72
-86
lines changed

docs/install.sh

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
set -e
3-
# Code generated by godownloader on 2018-04-07T17:47:38Z. DO NOT EDIT.
3+
# Code generated by godownloader on 2021-01-12T13:40:40Z. DO NOT EDIT.
44
#
55

66
usage() {
@@ -27,11 +27,12 @@ parse_args() {
2727
# over-ridden by flag below
2828

2929
BINDIR=${BINDIR:-./bin}
30-
while getopts "b:dh?" arg; do
30+
while getopts "b:dh?x" arg; do
3131
case "$arg" in
3232
b) BINDIR="$OPTARG" ;;
3333
d) log_set_priority 10 ;;
3434
h | \?) usage "$0" ;;
35+
x) set -x ;;
3536
esac
3637
done
3738
shift $((OPTIND - 1))
@@ -42,46 +43,41 @@ parse_args() {
4243
# network, either nothing will happen or will syntax error
4344
# out preventing half-done work
4445
execute() {
45-
tmpdir=$(mktmpdir)
46+
tmpdir=$(mktemp -d)
4647
log_debug "downloading files into ${tmpdir}"
4748
http_download "${tmpdir}/${TARBALL}" "${TARBALL_URL}"
4849
http_download "${tmpdir}/${CHECKSUM}" "${CHECKSUM_URL}"
4950
hash_sha256_verify "${tmpdir}/${TARBALL}" "${tmpdir}/${CHECKSUM}"
5051
srcdir="${tmpdir}"
5152
(cd "${tmpdir}" && untar "${TARBALL}")
52-
install -d "${BINDIR}"
53-
for binexe in "task" ; do
53+
test ! -d "${BINDIR}" && install -d "${BINDIR}"
54+
for binexe in $BINARIES; do
5455
if [ "$OS" = "windows" ]; then
5556
binexe="${binexe}.exe"
5657
fi
5758
install "${srcdir}/${binexe}" "${BINDIR}/"
5859
log_info "installed ${BINDIR}/${binexe}"
5960
done
60-
}
61-
is_supported_platform() {
62-
platform=$1
63-
found=1
64-
case "$platform" in
65-
windows/386) found=0 ;;
66-
windows/amd64) found=0 ;;
67-
darwin/386) found=0 ;;
68-
darwin/amd64) found=0 ;;
69-
linux/386) found=0 ;;
70-
linux/amd64) found=0 ;;
71-
esac
72-
case "$platform" in
73-
darwin/386) found=1 ;;
61+
rm -rf "${tmpdir}"
62+
}
63+
get_binaries() {
64+
case "$PLATFORM" in
65+
darwin/amd64) BINARIES="task" ;;
66+
darwin/arm64) BINARIES="task" ;;
67+
darwin/armv6) BINARIES="task" ;;
68+
linux/386) BINARIES="task" ;;
69+
linux/amd64) BINARIES="task" ;;
70+
linux/arm64) BINARIES="task" ;;
71+
linux/armv6) BINARIES="task" ;;
72+
windows/386) BINARIES="task" ;;
73+
windows/amd64) BINARIES="task" ;;
74+
windows/arm64) BINARIES="task" ;;
75+
windows/armv6) BINARIES="task" ;;
76+
*)
77+
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"
78+
exit 1
79+
;;
7480
esac
75-
return $found
76-
}
77-
check_platform() {
78-
if is_supported_platform "$PLATFORM"; then
79-
# optional logging goes here
80-
true
81-
else
82-
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"
83-
exit 1
84-
fi
8581
}
8682
tag_to_version() {
8783
if [ -z "${TAG}" ]; then
@@ -99,8 +95,8 @@ tag_to_version() {
9995
VERSION=${TAG#v}
10096
}
10197
adjust_format() {
102-
# change format (tar.gz or zip) based on ARCH
103-
case ${ARCH} in
98+
# change format (tar.gz or zip) based on OS
99+
case ${OS} in
104100
windows) FORMAT=zip ;;
105101
esac
106102
true
@@ -174,7 +170,9 @@ log_crit() {
174170
uname_os() {
175171
os=$(uname -s | tr '[:upper:]' '[:lower:]')
176172
case "$os" in
177-
msys_nt) os="windows" ;;
173+
cygwin_nt*) os="windows" ;;
174+
mingw*) os="windows" ;;
175+
msys_nt*) os="windows" ;;
178176
esac
179177
echo "$os"
180178
}
@@ -186,9 +184,9 @@ uname_arch() {
186184
i686) arch="386" ;;
187185
i386) arch="386" ;;
188186
aarch64) arch="arm64" ;;
189-
armv5*) arch="arm5" ;;
190-
armv6*) arch="arm6" ;;
191-
armv7*) arch="arm7" ;;
187+
armv5*) arch="armv5" ;;
188+
armv6*) arch="armv6" ;;
189+
armv7*) arch="armv7" ;;
192190
esac
193191
echo ${arch}
194192
}
@@ -234,20 +232,15 @@ uname_arch_check() {
234232
untar() {
235233
tarball=$1
236234
case "${tarball}" in
237-
*.tar.gz | *.tgz) tar -xzf "${tarball}" ;;
238-
*.tar) tar -xf "${tarball}" ;;
235+
*.tar.gz | *.tgz) tar --no-same-owner -xzf "${tarball}" ;;
236+
*.tar) tar --no-same-owner -xf "${tarball}" ;;
239237
*.zip) unzip "${tarball}" ;;
240238
*)
241239
log_err "untar unknown archive format for ${tarball}"
242240
return 1
243241
;;
244242
esac
245243
}
246-
mktmpdir() {
247-
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
248-
mkdir -p "${TMPDIR}"
249-
echo "${TMPDIR}"
250-
}
251244
http_download_curl() {
252245
local_file=$1
253246
source_url=$2
@@ -368,7 +361,7 @@ uname_arch_check "$ARCH"
368361

369362
parse_args "$@"
370363

371-
check_platform
364+
get_binaries
372365

373366
tag_to_version
374367

install-task.sh

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
set -e
3-
# Code generated by godownloader on 2018-04-07T17:47:38Z. DO NOT EDIT.
3+
# Code generated by godownloader on 2021-01-12T13:40:40Z. DO NOT EDIT.
44
#
55

66
usage() {
@@ -27,11 +27,12 @@ parse_args() {
2727
# over-ridden by flag below
2828

2929
BINDIR=${BINDIR:-./bin}
30-
while getopts "b:dh?" arg; do
30+
while getopts "b:dh?x" arg; do
3131
case "$arg" in
3232
b) BINDIR="$OPTARG" ;;
3333
d) log_set_priority 10 ;;
3434
h | \?) usage "$0" ;;
35+
x) set -x ;;
3536
esac
3637
done
3738
shift $((OPTIND - 1))
@@ -42,46 +43,41 @@ parse_args() {
4243
# network, either nothing will happen or will syntax error
4344
# out preventing half-done work
4445
execute() {
45-
tmpdir=$(mktmpdir)
46+
tmpdir=$(mktemp -d)
4647
log_debug "downloading files into ${tmpdir}"
4748
http_download "${tmpdir}/${TARBALL}" "${TARBALL_URL}"
4849
http_download "${tmpdir}/${CHECKSUM}" "${CHECKSUM_URL}"
4950
hash_sha256_verify "${tmpdir}/${TARBALL}" "${tmpdir}/${CHECKSUM}"
5051
srcdir="${tmpdir}"
5152
(cd "${tmpdir}" && untar "${TARBALL}")
52-
install -d "${BINDIR}"
53-
for binexe in "task" ; do
53+
test ! -d "${BINDIR}" && install -d "${BINDIR}"
54+
for binexe in $BINARIES; do
5455
if [ "$OS" = "windows" ]; then
5556
binexe="${binexe}.exe"
5657
fi
5758
install "${srcdir}/${binexe}" "${BINDIR}/"
5859
log_info "installed ${BINDIR}/${binexe}"
5960
done
60-
}
61-
is_supported_platform() {
62-
platform=$1
63-
found=1
64-
case "$platform" in
65-
windows/386) found=0 ;;
66-
windows/amd64) found=0 ;;
67-
darwin/386) found=0 ;;
68-
darwin/amd64) found=0 ;;
69-
linux/386) found=0 ;;
70-
linux/amd64) found=0 ;;
71-
esac
72-
case "$platform" in
73-
darwin/386) found=1 ;;
61+
rm -rf "${tmpdir}"
62+
}
63+
get_binaries() {
64+
case "$PLATFORM" in
65+
darwin/amd64) BINARIES="task" ;;
66+
darwin/arm64) BINARIES="task" ;;
67+
darwin/armv6) BINARIES="task" ;;
68+
linux/386) BINARIES="task" ;;
69+
linux/amd64) BINARIES="task" ;;
70+
linux/arm64) BINARIES="task" ;;
71+
linux/armv6) BINARIES="task" ;;
72+
windows/386) BINARIES="task" ;;
73+
windows/amd64) BINARIES="task" ;;
74+
windows/arm64) BINARIES="task" ;;
75+
windows/armv6) BINARIES="task" ;;
76+
*)
77+
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"
78+
exit 1
79+
;;
7480
esac
75-
return $found
76-
}
77-
check_platform() {
78-
if is_supported_platform "$PLATFORM"; then
79-
# optional logging goes here
80-
true
81-
else
82-
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"
83-
exit 1
84-
fi
8581
}
8682
tag_to_version() {
8783
if [ -z "${TAG}" ]; then
@@ -99,8 +95,8 @@ tag_to_version() {
9995
VERSION=${TAG#v}
10096
}
10197
adjust_format() {
102-
# change format (tar.gz or zip) based on ARCH
103-
case ${ARCH} in
98+
# change format (tar.gz or zip) based on OS
99+
case ${OS} in
104100
windows) FORMAT=zip ;;
105101
esac
106102
true
@@ -174,7 +170,9 @@ log_crit() {
174170
uname_os() {
175171
os=$(uname -s | tr '[:upper:]' '[:lower:]')
176172
case "$os" in
177-
msys_nt) os="windows" ;;
173+
cygwin_nt*) os="windows" ;;
174+
mingw*) os="windows" ;;
175+
msys_nt*) os="windows" ;;
178176
esac
179177
echo "$os"
180178
}
@@ -186,9 +184,9 @@ uname_arch() {
186184
i686) arch="386" ;;
187185
i386) arch="386" ;;
188186
aarch64) arch="arm64" ;;
189-
armv5*) arch="arm5" ;;
190-
armv6*) arch="arm6" ;;
191-
armv7*) arch="arm7" ;;
187+
armv5*) arch="armv5" ;;
188+
armv6*) arch="armv6" ;;
189+
armv7*) arch="armv7" ;;
192190
esac
193191
echo ${arch}
194192
}
@@ -234,20 +232,15 @@ uname_arch_check() {
234232
untar() {
235233
tarball=$1
236234
case "${tarball}" in
237-
*.tar.gz | *.tgz) tar -xzf "${tarball}" ;;
238-
*.tar) tar -xf "${tarball}" ;;
235+
*.tar.gz | *.tgz) tar --no-same-owner -xzf "${tarball}" ;;
236+
*.tar) tar --no-same-owner -xf "${tarball}" ;;
239237
*.zip) unzip "${tarball}" ;;
240238
*)
241239
log_err "untar unknown archive format for ${tarball}"
242240
return 1
243241
;;
244242
esac
245243
}
246-
mktmpdir() {
247-
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
248-
mkdir -p "${TMPDIR}"
249-
echo "${TMPDIR}"
250-
}
251244
http_download_curl() {
252245
local_file=$1
253246
source_url=$2
@@ -368,7 +361,7 @@ uname_arch_check "$ARCH"
368361

369362
parse_args "$@"
370363

371-
check_platform
364+
get_binaries
372365

373366
tag_to_version
374367

0 commit comments

Comments
 (0)